Page MenuHomePhabricator

Abusefilter: update.php fails to auto create table - 1.33.1
Closed, ResolvedPublic

Description

I installed Extension AbuseFilter on MediaWiki 1.33.1 and ran update.php. While there were no errors in cli, I see the following error in my browser console. This error shows up in Google Chrome and Mozilla FireFox.

[ee4e504f377fd935d279ebe5] /wiki/load.php?lang=en&modules=startup&only=scripts&skin=vector   Wikimedia\Rdbms\DBQueryError from line 1587 of /var/www/html/wiki/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  afa_parameters  FROM `wikidb`.`abuse_filter_action` INNER JOIN `wikidb`.`abuse_filter` ON ((afa_filter=af_id))   WHERE afa_consequence = 'tag' AND af_deleted = '0' AND af_enabled = '1'  
Function: AbuseFilterHooks::fetchAllTags
Error: 1146 Table 'wikidb.abuse_filter_action' doesn't exist (165.227.197.92)

Backtrace:
#0 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1556): Wikimedia\Rdbms\Database->getQueryExceptionAndLog(string, integer, string, string)
#1 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1274): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
#2 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1784): Wikimedia\Rdbms\Database->query(string, string)
#3 /var/www/html/wiki/extensions/AbuseFilter/includes/AbuseFilterHooks.php(475): Wikimedia\Rdbms\Database->select(array, string, array, string, array, array)
#4 /var/www/html/wiki/includes/libs/objectcache/WANObjectCache.php(1414): AbuseFilterHooks::{closure}(boolean, integer, array, NULL)
#5 /var/www/html/wiki/includes/libs/objectcache/WANObjectCache.php(1275): WANObjectCache->doGetWithSetCallback(string, integer, Closure, array)
#6 /var/www/html/wiki/extensions/AbuseFilter/includes/AbuseFilterHooks.php(504): WANObjectCache->getWithSetCallback(string, integer, Closure)
#7 /var/www/html/wiki/extensions/AbuseFilter/includes/AbuseFilterHooks.php(521): AbuseFilterHooks::fetchAllTags(array, boolean)
#8 /var/www/html/wiki/includes/Hooks.php(174): AbuseFilterHooks::onChangeTagsListActive(array)
#9 /var/www/html/wiki/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#10 /var/www/html/wiki/includes/changetags/ChangeTags.php(1355): Hooks::run(string, array)
#11 /var/www/html/wiki/includes/libs/objectcache/WANObjectCache.php(1414): ChangeTags::{closure}(boolean, integer, array, NULL)
#12 /var/www/html/wiki/includes/libs/objectcache/WANObjectCache.php(1275): WANObjectCache->doGetWithSetCallback(string, integer, Closure, array)
#13 /var/www/html/wiki/includes/changetags/ChangeTags.php(1361): WANObjectCache->getWithSetCallback(string, integer, Closure, array)
#14 /var/www/html/wiki/includes/specialpage/ChangesListSpecialPage.php(853): ChangeTags::listSoftwareActivatedTags()
#15 /var/www/html/wiki/includes/libs/objectcache/WANObjectCache.php(1414): ChangesListSpecialPage::{closure}(boolean, integer, array, NULL)
#16 /var/www/html/wiki/includes/libs/objectcache/WANObjectCache.php(1275): WANObjectCache->doGetWithSetCallback(string, integer, Closure, array)
#17 /var/www/html/wiki/includes/specialpage/ChangesListSpecialPage.php(902): WANObjectCache->getWithSetCallback(string, integer, Closure, array)
#18 /var/www/html/wiki/includes/specialpage/ChangesListSpecialPage.php(834): ChangesListSpecialPage::getChangeTagList(ResourceLoaderContext)
#19 /var/www/html/wiki/includes/resourceloader/ResourceLoaderFileModule.php(1122): ChangesListSpecialPage::getRcFiltersConfigVars(ResourceLoaderContext)
#20 /var/www/html/wiki/includes/resourceloader/ResourceLoaderFileModule.php(624): ResourceLoaderFileModule->expandPackageFiles(ResourceLoaderContext)
#21 /var/www/html/wiki/includes/resourceloader/ResourceLoaderModule.php(833): ResourceLoaderFileModule->getDefinitionSummary(ResourceLoaderContext)
#22 /var/www/html/wiki/includes/resourceloader/ResourceLoaderStartUpModule.php(255): ResourceLoaderModule->getVersionHash(ResourceLoaderContext)
#23 /var/www/html/wiki/includes/resourceloader/ResourceLoaderStartUpModule.php(438): ResourceLoaderStartUpModule->getModuleRegistrations(ResourceLoaderContext)
#24 /var/www/html/wiki/includes/resourceloader/ResourceLoaderModule.php(727): ResourceLoaderStartUpModule->getScript(ResourceLoaderContext)
#25 /var/www/html/wiki/includes/resourceloader/ResourceLoaderModule.php(694): ResourceLoaderModule->buildContent(ResourceLoaderContext)
#26 /var/www/html/wiki/includes/resourceloader/ResourceLoaderModule.php(830): ResourceLoaderModule->getModuleContent(ResourceLoaderContext)
#27 /var/www/html/wiki/includes/resourceloader/ResourceLoader.php(656): ResourceLoaderModule->getVersionHash(ResourceLoaderContext)
#28 [internal function]: ResourceLoader->{closure}(string)
#29 /var/www/html/wiki/includes/resourceloader/ResourceLoader.php(668): array_map(Closure, array)
#30 /var/www/html/wiki/includes/resourceloader/ResourceLoader.php(749): ResourceLoader->getCombinedVersion(ResourceLoaderContext, array)
#31 /var/www/html/wiki/load.php(46): ResourceLoader->respond(ResourceLoaderContext)
#32 {main}

Event Timeline

Sounds like there's a missing table in your schema... Weird! Probably the update/install script was interrupted when you first installed AbuseFilter on your wiki. I'm afraid the solution will involve manually changing the DB, so you have two alternatives.

Alternative 1

Use if: No abuse filters exist on your wiki (which is very likely, given that a table is missing) and you can re-install the extension
What to do: Run the following SQL (assuming MySQL):

DROP TABLE IF EXISTS abuse_filter, abuse_filter_action, abuse_filter_log, abuse_filter_history;

Then re-install AbuseFilter with the normal process.

Alternative 2

Use if: You don't want to lose existing AbuseFilter data (assuming there is data)
What to do: Tell me about that on this task :) We'd have to find an ad-hoc solution

@Daimona I tried alternative 1, it sort of worked - its showing up in special:version. database errors remain...I removed all of the abusefilter tables from all the wikis installed and ran update.php again. I am trying to install on my own wikifarm, doubt that would complicate things. using alternative equivalent to MySQL.

Special:AbuseFilter

[c4a4bc4869cf7883d676ee24] /wiki/Special:AbuseFilter Wikimedia\Rdbms\DBQueryError from line 1587 of /var/www/html/wiki/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 af_id,af_enabled,af_deleted,af_pattern,af_global,af_public_comments,af_hidden,af_hit_count,af_timestamp,af_user_text,af_user,af_actions,af_group,af_throttled FROM `wikidb`.`abuse_filter` WHERE af_deleted = '0' AND (LOWER( CAST( af_pattern AS char ) ) LIKE '%%' ESCAPE '`' ) ORDER BY af_id LIMIT 51
Function: IndexPager::buildQueryInfo (AbuseFilterPager)
Error: 1146 Table 'wikidb.abuse_filter' doesn't exist (165.227.197.92)
Backtrace:

#0 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1556): Wikimedia\Rdbms\Database->getQueryExceptionAndLog(string, integer, string, string)
#1 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1274): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
#2 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1784): Wikimedia\Rdbms\Database->query(string, string)
#3 /var/www/html/wiki/includes/pager/IndexPager.php(411): Wikimedia\Rdbms\Database->select(array, array, array, string, array, array)
#4 /var/www/html/wiki/includes/pager/IndexPager.php(254): IndexPager->reallyDoQuery(string, integer, boolean)
#5 /var/www/html/wiki/includes/pager/IndexPager.php(653): IndexPager->doQuery()
#6 /var/www/html/wiki/includes/pager/TablePager.php(295): IndexPager->isNavigationBarShown()
#7 /var/www/html/wiki/extensions/AbuseFilter/includes/Views/AbuseFilterViewList.php(270): TablePager->getNavigationBar()
#8 /var/www/html/wiki/extensions/AbuseFilter/includes/Views/AbuseFilterViewList.php(141): AbuseFilterViewList->showList(array, array)
#9 /var/www/html/wiki/extensions/AbuseFilter/includes/special/SpecialAbuseFilter.php(122): AbuseFilterViewList->show()
#10 /var/www/html/wiki/includes/specialpage/SpecialPage.php(569): SpecialAbuseFilter->execute(NULL)
#11 /var/www/html/wiki/includes/specialpage/SpecialPageFactory.php(558): SpecialPage->run(NULL)
#12 /var/www/html/wiki/includes/MediaWiki.php(288): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)
#13 /var/www/html/wiki/includes/MediaWiki.php(865): MediaWiki->performRequest()
#14 /var/www/html/wiki/includes/MediaWiki.php(515): MediaWiki->main()
#15 /var/www/html/wiki/index.php(42): MediaWiki->run()
#16 {main}

Special:Contributions/username

[17d9223ee12c205dd8592b21] /wiki/Special:Contributions/AW_Staff Wikimedia\Rdbms\DBQueryError from line 1587 of /var/www/html/wiki/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 afa_parameters FROM `wikidb`.`abuse_filter_action` INNER JOIN `wikidb`.`abuse_filter` ON ((afa_filter=af_id)) WHERE afa_consequence = 'tag' AND af_deleted = '0'
Function: AbuseFilterHooks::fetchAllTags
Error: 1146 Table 'wikidb.abuse_filter_action' doesn't exist (165.227.197.92)
Backtrace:

#0 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1556): Wikimedia\Rdbms\Database->getQueryExceptionAndLog(string, integer, string, string)
#1 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1274): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
#2 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1784): Wikimedia\Rdbms\Database->query(string, string)
#3 /var/www/html/wiki/extensions/AbuseFilter/includes/AbuseFilterHooks.php(475): Wikimedia\Rdbms\Database->select(array, string, array, string, array, array)
#4 /var/www/html/wiki/includes/libs/objectcache/WANObjectCache.php(1414): AbuseFilterHooks::{closure}(boolean, integer, array, NULL)
#5 /var/www/html/wiki/includes/libs/objectcache/WANObjectCache.php(1275): WANObjectCache->doGetWithSetCallback(string, integer, Closure, array)
#6 /var/www/html/wiki/extensions/AbuseFilter/includes/AbuseFilterHooks.php(504): WANObjectCache->getWithSetCallback(string, integer, Closure)
#7 /var/www/html/wiki/extensions/AbuseFilter/includes/AbuseFilterHooks.php(514): AbuseFilterHooks::fetchAllTags(array, boolean)
#8 /var/www/html/wiki/includes/Hooks.php(174): AbuseFilterHooks::onListDefinedTags(array)
#9 /var/www/html/wiki/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#10 /var/www/html/wiki/includes/changetags/ChangeTags.php(1437): Hooks::run(string, array)
#11 /var/www/html/wiki/includes/libs/objectcache/WANObjectCache.php(1414): ChangeTags::{closure}(boolean, integer, array, NULL)
#12 /var/www/html/wiki/includes/libs/objectcache/WANObjectCache.php(1275): WANObjectCache->doGetWithSetCallback(string, integer, Closure, array)
#13 /var/www/html/wiki/includes/changetags/ChangeTags.php(1443): WANObjectCache->getWithSetCallback(string, integer, Closure, array)
#14 /var/www/html/wiki/includes/changetags/ChangeTags.php(1374): ChangeTags::listSoftwareDefinedTags()
#15 /var/www/html/wiki/includes/changetags/ChangeTags.php(838): ChangeTags::listDefinedTags()
#16 /var/www/html/wiki/includes/specials/SpecialContributions.php(561): ChangeTags::buildTagFilterSelector(string, boolean, RequestContext)
#17 /var/www/html/wiki/includes/specials/SpecialContributions.php(214): SpecialContributions->getForm()
#18 /var/www/html/wiki/includes/specialpage/SpecialPage.php(569): SpecialContributions->execute(string)
#19 /var/www/html/wiki/includes/specialpage/SpecialPageFactory.php(558): SpecialPage->run(string)
#20 /var/www/html/wiki/includes/MediaWiki.php(288): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)
#21 /var/www/html/wiki/includes/MediaWiki.php(865): MediaWiki->performRequest()
#22 /var/www/html/wiki/includes/MediaWiki.php(515): MediaWiki->main()
#23 /var/www/html/wiki/index.php(42): MediaWiki->run()
#24 {main}

I can always just directly run the sql commands to create the tables required.

@Daimona I tried alternative 1, it sort of worked - its showing up in special:version. database errors remain...I removed all of the abusefilter tables from all the wikis installed and ran update.php again.

So, you have:

  • deleted all AF tables
  • re-ran update.php

and the errors still remain? That would be weird. May you please paste the output of update.php in that case?


If you need a quick solution, after deleting all tables you could re-create them manually by applying the SQL file for your DBMS. For MySQL it's abusefilter.tables.sql.

Is it possible that update.php is forgetting about the actor table migration?

Is it possible that update.php is forgetting about the actor table migration?

In what sense? Either way, I don't think this is related to the actor table.

though this doesn't explain why when running update.php that the required tables are not being created. whether I have a single wiki or a group of wikis shouldn't make an impact...

though this doesn't explain why when running update.php that the required tables are not being created. whether I have a single wiki or a group of wikis shouldn't make an impact...

I agree with that, but I cannot tell anything more without further information (cfr T238616#5677878). At least, the output of update.php to see why it's not creating the tables.

It appears after running update.php multiple times, the tables are now created...not sure what happened - resolved issues for both Abusefilter and Checkuser