Page MenuHomePhabricator

update.php doesn't create table securepoll_elections on SQLite database
Closed, ResolvedPublic

Description

When I go to 'Special:SecurePoll' after installing SecurePoll, it shows following error:

[1d43a37c73e94f167b60fcaf] /w/index.php?title=Special:SecurePoll Wikimedia\Rdbms\DBQueryError from line 1458 of /var/www/html/w/includes/libs/rdbms/database/Database.php: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading?
Query: SELECT * FROM securepoll_elections ORDER BY el_start_date LIMIT 51
Function: IndexPager::buildQueryInfo (SecurePoll_ElectionPager)
Error: 1 no such table: securepoll_elections

Backtrace:

#0 /var/www/html/w/includes/libs/rdbms/database/Database.php(1428): Wikimedia\Rdbms\Database->makeQueryException(string, integer, string, string)
#1 /var/www/html/w/includes/libs/rdbms/database/Database.php(1198): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
#2 /var/www/html/w/includes/libs/rdbms/database/Database.php(1655): Wikimedia\Rdbms\Database->query(string, string)
#3 /var/www/html/w/includes/pager/IndexPager.php(369): Wikimedia\Rdbms\Database->select(string, string, array, string, array, array)
#4 /var/www/html/w/includes/pager/IndexPager.php(225): IndexPager->reallyDoQuery(string, integer, boolean)
#5 /var/www/html/w/includes/pager/IndexPager.php(423): IndexPager->doQuery()
#6 /var/www/html/w/includes/pager/TablePager.php(69): IndexPager->getBody()
#7 /var/www/html/w/extensions/SecurePoll/includes/pages/EntryPage.php(16): TablePager->getBody()
#8 /var/www/html/w/extensions/SecurePoll/includes/main/SpecialSecurePoll.php(72): SecurePoll_EntryPage->execute(array)
#9 /var/www/html/w/includes/specialpage/SpecialPage.php(569): SecurePoll_SpecialSecurePoll->execute(string)
#10 /var/www/html/w/includes/specialpage/SpecialPageFactory.php(568): SpecialPage->run(NULL)
#11 /var/www/html/w/includes/MediaWiki.php(288): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)
#12 /var/www/html/w/includes/MediaWiki.php(868): MediaWiki->performRequest()
#13 /var/www/html/w/includes/MediaWiki.php(525): MediaWiki->main()
#14 /var/www/html/w/index.php(42): MediaWiki->run()
#15 {main}

Also update.php doesn't create tables related to SecurePoll:

/var/www/html/w>php maintenance/update.php
MediaWiki 1.32.0-wmf.23 Updater

Your composer.lock file is up to date with current dependencies!
Going to run database updates for database
Using SQLite file: '/var/www/data/w/database.sqlite'
Depending on the size of your database this may take a while!
Abort with control-c in the next five seconds (skip this countdown with --quick) ... 0
Turning off Content Handler DB fields for this part of upgrade.
...have ss_active_users field in site_stats table.
...ss_active_users user count set...
...have ipb_allow_usertalk field in ipblocks table.
...have initial indexes
...change_tag table already exists.
...tag_summary table already exists.
...valid_tag table already exists.
...user_properties table already exists.
...log_search table already exists.
...have log_user_text field in logging table.
...l10n_cache table already exists.
...index tag_summary_rc_id already set on tag_summary table.
...have rd_interwiki field in redirect table.
...fulltext search table appears to be in order.
...iwlinks table already exists.
...index iwl_prefix_title_from already set on iwlinks table.
...have ul_value field in updatelog table.
...have iw_api field in interwiki table.
...iwl_prefix key doesn't exist.
...have cl_collation field in categorylinks table.
...module_deps table already exists.
...ar_page_revid key doesn't exist.
...skipping index ar_revid because index ar_revid_uniq already set on archive table.
...index user_email already set on user table.
...uploadstash table already exists.
...user_former_groups table already exists.
...batch conversion of user_options: nothing to migrate. done.
...user table does not contain user_options field.
...have rev_sha1 field in revision table.
...have ar_sha1 field in archive table.
...index page_redirect_namespace_len already set on page table.
...have us_chunk_inx field in uploadstash table.
...have job_timestamp field in job table.
...index page_user_timestamp already set on revision table.
...have ipb_parent_block_id field in ipblocks table.
...index ipb_parent_block_id already set on ipblocks table.
...category table does not contain cat_hidden field.
...have rev_content_format field in revision table.
...have rev_content_model field in revision table.
...have ar_content_format field in archive table.
...have ar_content_model field in archive table.
...have page_content_model field in page table.
Content Handler DB fields should be usable now.
...site_stats table does not contain ss_admins field.
...recentchanges table does not contain rc_moved_to_title field.
...sites table already exists.
...have fa_sha1 field in filearchive table.
...have job_token field in job table.
...have job_attempts field in job table.
...have us_props field in uploadstash table.
...ug_group in table user_groups already modified by patch patch-ug_group-length-increase-255.sql.
...ufg_group in table user_former_groups already modified by patch patch-ufg_group-length-increase-255.sql.
...index pp_propname_page already set on page_props table.
...index img_media_mime already set on image table.
...index iwl_prefix_from_title already set on iwlinks table.
...have ar_id field in archive table.
...have el_id field in externallinks table.
...have rc_source field in recentchanges table.
...index log_user_text_type_time already set on logging table.
...index log_user_text_time already set on logging table.
...have page_links_updated field in page table.
...have user_password_expires field in user table.
...have pp_sortkey field in page_props table.
...recentchanges table does not contain rc_cur_time field.
...index wl_user_notificationtimestamp already set on watchlist table.
...have page_lang field in page table.
...have pl_from_namespace field in pagelinks table.
...have tl_from_namespace field in templatelinks table.
...have il_from_namespace field in imagelinks table.
...hitcounter doesn't exist.
...site_stats table does not contain ss_total_views field.
...page table does not contain page_counter field.
...fa_deleted_reason in table filearchive already modified by patch patch-editsummary-length.sql.
...msg_resource_links doesn't exist.
...msg_resource doesn't exist.
...bot_passwords table already exists.
...have wl_id field in watchlist table.
...cl_collation key doesn't exist.
...index cl_collation_ext already set on categorylinks table.
...collations up-to-date.
...index rc_name_type_patrolled_timestamp already set on recentchanges table.
...have ct_id field in change_tag table.
...have ts_id field in tag_summary table.
...have el_index_60 field in externallinks table.
...have ug_expiry field in user_groups table.
...index img_user_timestamp already set on image table.
...img_media_type in table image already modified by patch patch-add-3d.sql.
...ip_changes table already exists.
...skipping: index cl_from doesn't exist.
...skipping: index tl_from doesn't exist.
...skipping: index pl_from doesn't exist.
...skipping: index old_id doesn't exist.
...skipping: index il_from doesn't exist.
...skipping: index iwl_from doesn't exist.
...skipping: index ll_from doesn't exist.
...skipping: index ls_field_val doesn't exist.
...skipping: index md_module_skin doesn't exist.
...skipping: index keyname doesn't exist.
...skipping: index qci_type doesn't exist.
...skipping: index ss_row_id doesn't exist.
...skipping: index ufg_user_group doesn't exist.
...skipping: index user_properties_user_property doesn't exist.
...comment table already exists.
...have img_description_id field in image table.
...skipping: index lc_lang_key doesn't exist.
...content table already exists.
...content_models table already exists.
...slots table already exists.
...have slot_origin field in slots table.
...slot_roles table already exists.
...actor table already exists.
...rev_text_id in table revision already modified by patch patch-rev_text_id-default.sql.
...table site_stats already modified by patch patch-site_stats-modify.sql.
...index rc_namespace_title_timestamp already set on recentchanges table.
...change_tag_def table already exists.
...el_index_60 in table externallinks already modified by patch patch-externallinks-el_index_60-drop-default.sql.
Running maintenance/deduplicateArchiveRevId.php...
...Update 'DeduplicateArchiveRevId' already logged as completed.
done.
...have ct_tag_id field in change_tag table.
...index ar_revid_uniq already set on archive table.
...index log_type_action already set on logging table.
...type_action key doesn't exist.
...skipping: index iw_prefix doesn't exist.
...skipping: index pp_page_propname doesn't exist.
...skipping: index pt_namespace_title doesn't exist.
...skipping: index site_ids_type doesn't exist.
...index rc_this_oldid already set on recentchanges table.
...transcache doesn't exist.
Running maintenance/populateChangeTagDef.php...
...Update 'PopulateChangeTagDef' already logged as completed.
done.
...index change_tag_rc_tag_id already set on change_tag table.
...have ipb_sitewide field in ipblocks table.
...ipblocks_restrictions table already exists.
...abuse_filter table already exists.
...abuse_filter_history table already exists.
...have afh_changed_fields field in abuse_filter_history table.
...have af_deleted field in abuse_filter table.
...have af_actions field in abuse_filter table.
...have af_global field in abuse_filter table.
...have afl_rev_id field in abuse_filter_log table.
...index afl_filter_timestamp already set on abuse_filter_log table.
...have af_group field in abuse_filter table.
...index afl_wiki_timestamp already set on abuse_filter_log table.
...spoofuser table already exists.
...cu_changes table already exists.
...cu_log table already exists.
...site_stats is populated...done.
...Update 'populate rev_len and ar_len' already logged as completed.
...Update 'populate rev_sha1' already logged as completed.
...img_sha1 column of image table already populated.
...protocol-relative URLs in externallinks table already fixed.
...fa_sha1 column of filearchive table already populated.
...*_from_namespace column of backlink tables already populated.
...Update 'FixDefaultJsonContentPages' already logged as completed.
...Update 'cleanup empty categories' already logged as completed.
...RFC and PMID already added to interwiki database table.
Populating page_props.pp_sortkey...
Populating page_props.pp_sortkey complete.
...Update 'populate ip_changes' already logged as completed.
Purging caches...done.

Done in 0.5 s.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 2 2018, 5:10 AM

Looking at https://phabricator.wikimedia.org/diffusion/ESPO/browse/master/includes/SecurePollHooks.php, this is no surprise. The LoadExtensionSchemaUpdates hook does only support MySQL and PostgreSQL for SecurePoll. It uses a switch block for the database type name, which doesn't include an entry for SQLite.

D3r1ck01 renamed this task from update.php doesn't create table securepoll_elections to update.php doesn't create table securepoll_elections on SQLite database.Oct 2 2018, 9:27 AM

Running mwscript sqlite.php --check-syntax /vagrant/mediawiki/extensions/SecurePoll/SecurePoll.sql reports:
SQL syntax check: no errors detected.. This would imply that inserting a line above line 23 SecurePollHooks.php containing case 'sqlite': would fix this.
@PlavorSeol Could you test this?

@Mainframe98 at the moment, maybe what can be done is the exception handled letting the user know that SQLite is not a supported DB type? Then if someone wants to add support for SQLite can do so? Or any suggestions?

The exception in the task description can't let the user know about that, as that is not something that part of MediaWiki handles. This is something that should be documented on the extension page. Considering support for SQLite should be trivial, that would be a solution for this task. If it is desirable to have the extension show a message (not throw an exception in the script, that would cause trouble) then that is something to address in a separate task.

@Mainframe98 When I run update.php after inserting `case "sqlite":` in SecurePollHooks.php, following error occurs:

PS C:\nginx\web\PlavorEXITBeta\mediawiki\maintenance> php update.php                                                                                                             MediaWiki 1.33.0-alpha Updater

Your composer.lock file is up to date with current dependencies!
Going to run database updates for database
Using SQLite file: 'C:/nginx/data/PlavorEXITBeta/database.sqlite'
Depending on the size of your database this may take a while!
Abort with control-c in the next five seconds (skip this countdown with --quick) ... 0
Turning off Content Handler DB fields for this part of upgrade.
...have ss_active_users field in site_stats table.
...ss_active_users user count set...
...have ipb_allow_usertalk field in ipblocks table.
...have initial indexes
...change_tag table already exists.
...tag_summary table already exists.
...valid_tag table already exists.
...user_properties table already exists.
...log_search table already exists.
...have log_user_text field in logging table.
...l10n_cache table already exists.
...index tag_summary_rc_id already set on tag_summary table.
...have rd_interwiki field in redirect table.
...fulltext search table appears to be in order.
...iwlinks table already exists.
...index iwl_prefix_title_from already set on iwlinks table.
...have ul_value field in updatelog table.
...have iw_api field in interwiki table.
...iwl_prefix key doesn't exist.
...have cl_collation field in categorylinks table.
...module_deps table already exists.
...ar_page_revid key doesn't exist.
...skipping index ar_revid because index ar_revid_uniq already set on archive table.
...index user_email already set on user table.
...uploadstash table already exists.
...user_former_groups table already exists.
...batch conversion of user_options: nothing to migrate. done.
...user table does not contain user_options field.
...have rev_sha1 field in revision table.
...have ar_sha1 field in archive table.
...index page_redirect_namespace_len already set on page table.
...have us_chunk_inx field in uploadstash table.
...have job_timestamp field in job table.
...index page_user_timestamp already set on revision table.
...have ipb_parent_block_id field in ipblocks table.
...index ipb_parent_block_id already set on ipblocks table.
...category table does not contain cat_hidden field.
...have rev_content_format field in revision table.
...have rev_content_model field in revision table.
...have ar_content_format field in archive table.
...have ar_content_model field in archive table.
...have page_content_model field in page table.
Content Handler DB fields should be usable now.
...site_stats table does not contain ss_admins field.
...recentchanges table does not contain rc_moved_to_title field.
...sites table already exists.
...have fa_sha1 field in filearchive table.
...have job_token field in job table.
...have job_attempts field in job table.
...have us_props field in uploadstash table.
...ug_group in table user_groups already modified by patch patch-ug_group-length-increase-255.sql.
...ufg_group in table user_former_groups already modified by patch patch-ufg_group-length-increase-255.sql.
...index pp_propname_page already set on page_props table.
...index img_media_mime already set on image table.
...index iwl_prefix_from_title already set on iwlinks table.
...have ar_id field in archive table.
...have el_id field in externallinks table.
...have rc_source field in recentchanges table.
...index log_user_text_type_time already set on logging table.
...index log_user_text_time already set on logging table.
...have page_links_updated field in page table.
...have user_password_expires field in user table.
...have pp_sortkey field in page_props table.
...recentchanges table does not contain rc_cur_time field.
...index wl_user_notificationtimestamp already set on watchlist table.
...have page_lang field in page table.
...have pl_from_namespace field in pagelinks table.
...have tl_from_namespace field in templatelinks table.
...have il_from_namespace field in imagelinks table.
...hitcounter doesn't exist.
...site_stats table does not contain ss_total_views field.
...page table does not contain page_counter field.
...fa_deleted_reason in table filearchive already modified by patch patch-editsummary-length.sql.
...msg_resource_links doesn't exist.
...msg_resource doesn't exist.
...bot_passwords table already exists.
...have wl_id field in watchlist table.
...cl_collation key doesn't exist.
...index cl_collation_ext already set on categorylinks table.
...collations up-to-date.
...index rc_name_type_patrolled_timestamp already set on recentchanges table.
...have ct_id field in change_tag table.
...have ts_id field in tag_summary table.
...have el_index_60 field in externallinks table.
...have ug_expiry field in user_groups table.
...index img_user_timestamp already set on image table.
...img_media_type in table image already modified by patch patch-add-3d.sql.
...ip_changes table already exists.
...skipping: index cl_from doesn't exist.
...skipping: index tl_from doesn't exist.
...skipping: index pl_from doesn't exist.
...skipping: index old_id doesn't exist.
...skipping: index il_from doesn't exist.
...skipping: index iwl_from doesn't exist.
...skipping: index ll_from doesn't exist.
...skipping: index ls_field_val doesn't exist.
...skipping: index md_module_skin doesn't exist.
...skipping: index keyname doesn't exist.
...skipping: index qci_type doesn't exist.
...skipping: index ss_row_id doesn't exist.
...skipping: index ufg_user_group doesn't exist.
...skipping: index user_properties_user_property doesn't exist.
...comment table already exists.
...have img_description_id field in image table.
...skipping: index lc_lang_key doesn't exist.
...content table already exists.
...content_models table already exists.
...slots table already exists.
...have slot_origin field in slots table.
...slot_roles table already exists.
...actor table already exists.
...rev_text_id in table revision already modified by patch patch-rev_text_id-default.sql.
...table site_stats already modified by patch patch-site_stats-modify.sql.
...index rc_namespace_title_timestamp already set on recentchanges table.
...change_tag_def table already exists.
...el_index_60 in table externallinks already modified by patch patch-externallinks-el_index_60-drop-default.sql.
Running maintenance/deduplicateArchiveRevId.php...
...Update 'DeduplicateArchiveRevId' already logged as completed.
done.
...have ct_tag_id field in change_tag table.
...index ar_revid_uniq already set on archive table.
...index log_type_action already set on logging table.
...type_action key doesn't exist.
...skipping: index iw_prefix doesn't exist.
...skipping: index pp_page_propname doesn't exist.
...skipping: index pt_namespace_title doesn't exist.
...skipping: index site_ids_type doesn't exist.
...index rc_this_oldid already set on recentchanges table.
...transcache doesn't exist.
Running maintenance/populateChangeTagDef.php...
...Update 'PopulateChangeTagDef' already logged as completed.
done.
...index change_tag_rc_tag_id already set on change_tag table.
...have ipb_sitewide field in ipblocks table.
...ipblocks_restrictions table already exists.
...abuse_filter table already exists.
...abuse_filter_history table already exists.
...have afh_changed_fields field in abuse_filter_history table.
...have af_deleted field in abuse_filter table.
...have af_actions field in abuse_filter table.
...have af_global field in abuse_filter table.
...have afl_rev_id field in abuse_filter_log table.
...index afl_filter_timestamp already set on abuse_filter_log table.
...have af_group field in abuse_filter table.
...index afl_wiki_timestamp already set on abuse_filter_log table.
...spoofuser table already exists.
...cu_changes table already exists.
...cu_log table already exists.
...echo_event table already exists.
...echo_email_batch table already exists.
...echo_target_page table already exists.
...event_agent field does not exist in echo_event table, skipping modify field patch.
...event_variant in table echo_event already modified by patch C:\nginx\web\PlavorEXITBeta\mediawiki\extensions\Echo/db_patches/patch-event_variant_nullability.sqlite.sql.
...have etp_id field in echo_target_page table.
...echo_target_page table does not contain etp_user field.
...have notification_bundle_base field in echo_notification table.
...echo_subscription doesn't exist.
...echo_event table does not contain event_timestamp field.
...have eeb_event_hash field in echo_email_batch table.
...have event_page_id field in echo_event table.
...index echo_event_type already set on echo_event table.
...index echo_user_timestamp already set on echo_notification table.
...index echo_notification_event already set on echo_notification table.
...have event_deleted field in echo_event table.
...index echo_notification_user_read_timestamp already set on echo_notification table.
...index echo_target_page_page_event already set on echo_target_page table.
...index echo_event_page_id already set on echo_event table.
...user_event key doesn't exist.
...securepoll_entity table already exists.
Modifying vote_ip field of table securepoll_votes ...[43780775bbe0fcf0ad641587] [no req]   Wikimedia\Rdbms\DBQueryError from line 1506 of C:\nginx\web\PlavorEXITBeta\mediawiki\includes\libs\rdbms\database\Database.php: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading?
Query: ALTER TABLE securepoll_votes MODIFY COLUMN vote_ip BLOB NOT NULL

Function: Wikimedia\Rdbms\Database::sourceFile( C:\nginx\web\PlavorEXITBeta\mediawiki\extensions\SecurePoll/patches/patch-vote_ip-extend.sql )
Error: 1 near "MODIFY": syntax error

Backtrace:
#0 C:\nginx\web\PlavorEXITBeta\mediawiki\includes\libs\rdbms\database\Database.php(1476): Wikimedia\Rdbms\Database->makeQueryException(string, integer, string, string)
#1 C:\nginx\web\PlavorEXITBeta\mediawiki\includes\libs\rdbms\database\Database.php(1236): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
#2 C:\nginx\web\PlavorEXITBeta\mediawiki\includes\libs\rdbms\database\Database.php(4354): Wikimedia\Rdbms\Database->query(string, string)
#3 C:\nginx\web\PlavorEXITBeta\mediawiki\includes\libs\rdbms\database\Database.php(4289): Wikimedia\Rdbms\Database->sourceStream(resource (closed), NULL, NULL, string, NULL)
#4 C:\nginx\web\PlavorEXITBeta\mediawiki\includes\installer\DatabaseUpdater.php(683): Wikimedia\Rdbms\Database->sourceFile(string)
#5 C:\nginx\web\PlavorEXITBeta\mediawiki\includes\installer\DatabaseUpdater.php(972): DatabaseUpdater->applyPatch(string, boolean, string)
#6 C:\nginx\web\PlavorEXITBeta\mediawiki\includes\installer\DatabaseUpdater.php(482): DatabaseUpdater->modifyField(string, string, string, boolean)
#7 C:\nginx\web\PlavorEXITBeta\mediawiki\includes\installer\DatabaseUpdater.php(450): DatabaseUpdater->runUpdates(array, boolean)
#8 C:\nginx\web\PlavorEXITBeta\mediawiki\maintenance\update.php(203): DatabaseUpdater->doUpdates(array)
#9 C:\nginx\web\PlavorEXITBeta\mediawiki\maintenance\doMaintenance.php(94): UpdateMediaWiki->execute()
#10 C:\nginx\web\PlavorEXITBeta\mediawiki\maintenance\update.php(248): require_once(string)
#11 {main}
PS C:\nginx\web\PlavorEXITBeta\mediawiki\maintenance>
PS C:\nginx\web\PlavorEXITBeta\mediawiki\maintenance> php sqlite.php --check-syntax "C:\nginx\web\PlavorEXITBeta\mediawiki\extensions\SecurePoll\SecurePoll.sql"
SQL syntax check: no errors detected.
PS C:\nginx\web\PlavorEXITBeta\mediawiki\maintenance>

@PlavorSeol, thank you for testing.
It appears that patch-vote_ip-extend.sql isn't SQLite compatible.

Luckily, this should be resolvable:
Adding an additional case statement to the switch case, something like

case 'sqlite':
    $update->addExtensionTable( 'securepoll_entity', "$base/SecurePoll.sql" );
    break;

should allow for SQLite support.

@Mainframe98 Yes, it works well after adding that line, but I think SecurePoll itself should support that.

Change 479980 had a related patch set uploaded (by Mainframe98; owner: Mainframe98):
[mediawiki/extensions/SecurePoll@master] Add support for SQLite

https://gerrit.wikimedia.org/r/479980

@PlavorSeol, then lets make that happen!

When it can be merged?

Change 479980 had a related patch set uploaded (by Mainframe98; owner: Mainframe98):
[mediawiki/extensions/SecurePoll@master] Add support for SQLite

https://gerrit.wikimedia.org/r/479980

Change 479980 merged by jenkins-bot:
[mediawiki/extensions/SecurePoll@master] Add support for SQLite

https://gerrit.wikimedia.org/r/479980

Mainframe98 closed this task as Resolved.Jul 27 2019, 8:08 PM