bovender / LinkTitles

MediaWiki extension that automatically adds links to words that match titles of existing pages.
https://www.mediawiki.org/wiki/Extension:LinkTitles
GNU General Public License v2.0
20 stars 14 forks source link

Blacklisted values cause database query error (PostgreSQL, ParseOnRender) #57

Open zyzzyxdonta opened 3 years ago

zyzzyxdonta commented 3 years ago

Hi,

I came across a database query error when trying to blacklist certain words. I tried to blacklist the word "Water" which then was assumed to be a column. The "Water" page is inside a custom namespace "FWDT" which has number 264.

Here are my settings:

wfLoadExtension( 'LinkTitles' );
$wgLinkTitlesParseOnEdit = false;
$wgLinkTitlesParseOnRender = true;
$wgLinkTitlesSourceNamespaces = array_merge(
        [ NS_MAIN, NS_USER ],
        array_keys( $customNamespaces )  # keys are numbers
);
$wgLinkTitlesTargetNamespaces = [ NS_MAIN, NS_USER, 2000 ];
$wgLinkTitlesBlackList = [ 'Water' ];

and the error page:

MediaWiki internal error.

Original exception: [1826e69aa243464ffb6b1bde] /wiki/FWDT:Water Wikimedia\Rdbms\DBQueryError from line 1699 of /opt/mediawiki-1.35/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?

Error 42703: ERROR: column "Water" does not exist
LINE 5: ..._LENGTH(page_title) >= 4) AND (page_title NOT IN ("Water")) ...
^

Function: LinkTitles\Targets::fetch
Query: SELECT page_title,page_namespace,CASE page_namespace WHEN 264 THEN 100
WHEN 0 THEN 200
WHEN 2 THEN 300
WHEN 2000 THEN 400
END AS "weight" FROM "page" WHERE (page_namespace IN (264, 0, 2, 2000)) AND (CHAR_LENGTH(page_title) >= 4) AND (page_title NOT IN ("Water")) ORDER BY weight ASC, CHAR_LENGTH(page_title) ASC

Backtrace:
#0 /opt/mediawiki-1.35/includes/libs/rdbms/database/Database.php(1683): Wikimedia\Rdbms\Database->getQueryException()
#1 /opt/mediawiki-1.35/includes/libs/rdbms/database/Database.php(1658): Wikimedia\Rdbms\Database->getQueryExceptionAndLog()
#2 /opt/mediawiki-1.35/includes/libs/rdbms/database/Database.php(1227): Wikimedia\Rdbms\Database->reportQueryError()
#3 /opt/mediawiki-1.35/includes/libs/rdbms/database/Database.php(1907): Wikimedia\Rdbms\Database->query()
#4 /opt/mediawiki-1.35/includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->select()
#5 /opt/mediawiki-1.35/includes/libs/rdbms/database/DBConnRef.php(313): Wikimedia\Rdbms\DBConnRef->__call()
#6 /opt/mediawiki-1.35/extensions/LinkTitles/includes/Targets.php(150): Wikimedia\Rdbms\DBConnRef->select()
#7 /opt/mediawiki-1.35/extensions/LinkTitles/includes/Targets.php(91): LinkTitles\Targets->fetch()
#8 /opt/mediawiki-1.35/extensions/LinkTitles/includes/Targets.php(46): LinkTitles\Targets->__construct()
#9 /opt/mediawiki-1.35/extensions/LinkTitles/includes/Linker.php(83): LinkTitles\Targets::singleton()
#10 /opt/mediawiki-1.35/extensions/LinkTitles/includes/Extension.php(86): LinkTitles\Linker->linkContent()
#11 /opt/mediawiki-1.35/includes/HookContainer/HookContainer.php(321): LinkTitles\Extension::onInternalParseBeforeLinks()
#12 /opt/mediawiki-1.35/includes/HookContainer/HookContainer.php(132): MediaWiki\HookContainer\HookContainer->callLegacyHook()
#13 /opt/mediawiki-1.35/includes/HookContainer/HookRunner.php(2212): MediaWiki\HookContainer\HookContainer->run()
#14 /opt/mediawiki-1.35/includes/parser/Parser.php(1572): MediaWiki\HookContainer\HookRunner->onInternalParseBeforeLinks()
#15 /opt/mediawiki-1.35/includes/parser/Parser.php(850): Parser->internalParse()
#16 /opt/mediawiki-1.35/extensions/PageForms/includes/PF_ParserFunctions.php(700): Parser->recursiveTagParse()
#17 /opt/mediawiki-1.35/extensions/PageForms/includes/PF_ParserFunctions.php(197): PFParserFunctions::createFormLink()
#18 /opt/mediawiki-1.35/includes/parser/Parser.php(3340): PFParserFunctions::renderFormLink()
#19 /opt/mediawiki-1.35/includes/parser/Parser.php(3047): Parser->callParserFunction()
#20 /opt/mediawiki-1.35/includes/parser/PPFrame_Hash.php(253): Parser->braceSubstitution()
#21 /opt/mediawiki-1.35/includes/parser/Parser.php(3225): PPFrame_Hash->expand()
#22 /opt/mediawiki-1.35/includes/parser/PPFrame_Hash.php(253): Parser->braceSubstitution()
#23 /opt/mediawiki-1.35/includes/parser/Parser.php(2887): PPFrame_Hash->expand()
#24 /opt/mediawiki-1.35/includes/parser/Parser.php(1556): Parser->replaceVariables()
#25 /opt/mediawiki-1.35/includes/parser/Parser.php(651): Parser->internalParse()
#26 /opt/mediawiki-1.35/includes/content/WikitextContent.php(374): Parser->parse()
#27 /opt/mediawiki-1.35/includes/content/AbstractContent.php(590): WikitextContent->fillParserOutput()
#28 /opt/mediawiki-1.35/includes/Revision/RenderedRevision.php(263): AbstractContent->getParserOutput()
#29 /opt/mediawiki-1.35/includes/Revision/RenderedRevision.php(235): MediaWiki\Revision\RenderedRevision->getSlotParserOutputUncached()
#30 /opt/mediawiki-1.35/includes/Revision/RevisionRenderer.php(215): MediaWiki\Revision\RenderedRevision->getSlotParserOutput()
#31 /opt/mediawiki-1.35/includes/Revision/RevisionRenderer.php(152): MediaWiki\Revision\RevisionRenderer->combineSlotOutput()
#32 [internal function]: MediaWiki\Revision\RevisionRenderer->MediaWiki\Revision\{closure}()
#33 /opt/mediawiki-1.35/includes/Revision/RenderedRevision.php(197): call_user_func()
#34 /opt/mediawiki-1.35/includes/poolcounter/PoolWorkArticleView.php(216): MediaWiki\Revision\RenderedRevision->getRevisionParserOutput()
#35 /opt/mediawiki-1.35/includes/poolcounter/PoolCounterWork.php(162): PoolWorkArticleView->doWork()
#36 /opt/mediawiki-1.35/includes/page/Article.php(810): PoolCounterWork->execute()
#37 /opt/mediawiki-1.35/includes/actions/ViewAction.php(74): Article->view()
#38 /opt/mediawiki-1.35/includes/MediaWiki.php(527): ViewAction->show()
#39 /opt/mediawiki-1.35/includes/MediaWiki.php(313): MediaWiki->performAction()
#40 /opt/mediawiki-1.35/includes/MediaWiki.php(940): MediaWiki->performRequest()
#41 /opt/mediawiki-1.35/includes/MediaWiki.php(543): MediaWiki->main()
#42 /opt/mediawiki-1.35/index.php(53): MediaWiki->run()
#43 /opt/mediawiki-1.35/index.php(46): wfIndexMain()
#44 {main}

Exception caught inside exception handler: [1826e69aa243464ffb6b1bde] /wiki/FWDT:Water Wikimedia\Rdbms\DBQueryError from line 1699 of /opt/mediawiki-1.35/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?

Error 42703: ERROR: column "Water" does not exist
LINE 5: ..._LENGTH(page_title) >= 4) AND (page_title NOT IN ("Water")) ...
^

Function: LinkTitles\Targets::fetch
Query: SELECT page_title,page_namespace,CASE page_namespace WHEN 264 THEN 100
WHEN 0 THEN 200
WHEN 2 THEN 300
WHEN 2000 THEN 400
END AS "weight" FROM "page" WHERE (page_namespace IN (264, 0, 2, 2000)) AND (CHAR_LENGTH(page_title) >= 4) AND (page_title NOT IN ("Water")) ORDER BY weight ASC, CHAR_LENGTH(page_title) ASC

Backtrace:
#0 /opt/mediawiki-1.35/includes/libs/rdbms/database/Database.php(1683): Wikimedia\Rdbms\Database->getQueryException()
#1 /opt/mediawiki-1.35/includes/libs/rdbms/database/Database.php(1658): Wikimedia\Rdbms\Database->getQueryExceptionAndLog()
#2 /opt/mediawiki-1.35/includes/libs/rdbms/database/Database.php(1227): Wikimedia\Rdbms\Database->reportQueryError()
#3 /opt/mediawiki-1.35/includes/libs/rdbms/database/Database.php(1907): Wikimedia\Rdbms\Database->query()
#4 /opt/mediawiki-1.35/includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->select()
#5 /opt/mediawiki-1.35/includes/libs/rdbms/database/DBConnRef.php(313): Wikimedia\Rdbms\DBConnRef->__call()
#6 /opt/mediawiki-1.35/extensions/LinkTitles/includes/Targets.php(150): Wikimedia\Rdbms\DBConnRef->select()
#7 /opt/mediawiki-1.35/extensions/LinkTitles/includes/Targets.php(91): LinkTitles\Targets->fetch()
#8 /opt/mediawiki-1.35/extensions/LinkTitles/includes/Targets.php(46): LinkTitles\Targets->__construct()
#9 /opt/mediawiki-1.35/extensions/LinkTitles/includes/Linker.php(83): LinkTitles\Targets::singleton()
#10 /opt/mediawiki-1.35/extensions/LinkTitles/includes/Extension.php(86): LinkTitles\Linker->linkContent()
#11 /opt/mediawiki-1.35/includes/HookContainer/HookContainer.php(321): LinkTitles\Extension::onInternalParseBeforeLinks()
#12 /opt/mediawiki-1.35/includes/HookContainer/HookContainer.php(132): MediaWiki\HookContainer\HookContainer->callLegacyHook()
#13 /opt/mediawiki-1.35/includes/HookContainer/HookRunner.php(2212): MediaWiki\HookContainer\HookContainer->run()
#14 /opt/mediawiki-1.35/includes/parser/Parser.php(1572): MediaWiki\HookContainer\HookRunner->onInternalParseBeforeLinks()
#15 /opt/mediawiki-1.35/includes/parser/Parser.php(651): Parser->internalParse()
#16 /opt/mediawiki-1.35/includes/cache/MessageCache.php(1301): Parser->parse()
#17 /opt/mediawiki-1.35/includes/language/Message.php(1258): MessageCache->parse()
#18 /opt/mediawiki-1.35/includes/language/Message.php(889): Message->parseText()
#19 /opt/mediawiki-1.35/includes/language/Message.php(942): Message->toString()
#20 /opt/mediawiki-1.35/includes/skins/Skin.php(956): Message->parse()
#21 /opt/mediawiki-1.35/includes/skins/Skin.php(2514): Skin->lastModified()
#22 /opt/mediawiki-1.35/includes/skins/SkinTemplate.php(340): Skin->getFooterLinks()
#23 /opt/mediawiki-1.35/includes/skins/SkinTemplate.php(127): SkinTemplate->prepareQuickTemplate()
#24 /opt/mediawiki-1.35/includes/skins/SkinTemplate.php(144): SkinTemplate->generateHTML()
#25 /opt/mediawiki-1.35/includes/OutputPage.php(2622): SkinTemplate->outputPage()
#26 /opt/mediawiki-1.35/includes/exception/MWExceptionRenderer.php(153): OutputPage->output()
#27 /opt/mediawiki-1.35/includes/exception/MWExceptionRenderer.php(65): MWExceptionRenderer::reportHTML()
#28 /opt/mediawiki-1.35/includes/exception/MWExceptionHandler.php(106): MWExceptionRenderer::output()
#29 /opt/mediawiki-1.35/includes/exception/MWExceptionHandler.php(185): MWExceptionHandler::report()
#30 /opt/mediawiki-1.35/includes/MediaWiki.php(576): MWExceptionHandler::handleException()
#31 /opt/mediawiki-1.35/index.php(53): MediaWiki->run()
#32 /opt/mediawiki-1.35/index.php(46): wfIndexMain()
#33 {main}
bovender commented 3 years ago

Thanks for reporting this. Could you please tell me what kind of database you use?

zyzzyxdonta commented 3 years ago

Oh sorry, I only put it in the title and forgot to add it to the issue text. Database is PostgreSQL (12.7).

bovender commented 3 years ago

My bad... Did not properly read the title ;-) Will investigate, but not this weekend, too busy, sorry.

zyzzyxdonta commented 3 years ago

Oh and the title was also wrong, of course 😅