Page MenuHomePhabricator

"Key contains invalid characters" exception when purging pages with a "ä" in the title
Open, Needs TriagePublic

Description

When I try to purge a page that has a German umlaut "ä" in its title (did not test other umlauts or non-ascii characters) I see this exception:

Exception encountered, of type "Exception"
[V7QXVEkhP8fHD-f90@J1YgAAAAQ] /ccc_test/_-_/index.php?title=Bachelor_Europ%C3%A4ische_Energiewirtschaft&action=purge Exception from line 151 of .../mediawiki/includes/libs/objectcache/MemcachedBagOStuff.php: Key contains invalid characters: wf_ccc_test:wikiarticlefeedsextension:Bachelor_Europäische_Energiewirtschaft:atom:timestamp
Backtrace:
#0 .../mediawiki/includes/libs/objectcache/MemcachedBagOStuff.php(70): MemcachedBagOStuff->validateKeyEncoding(string)
#1 .../mediawiki/extensions/WikiArticleFeeds/WikiArticleFeeds_body.php(288): MemcachedBagOStuff->delete(string)
#2 .../mediawiki/includes/Hooks.php(195): WikiArticleFeeds::wfPurgeFeedsOnArticlePurge(WikiPage)
#3 .../mediawiki/includes/page/WikiPage.php(1106): Hooks::run(string, array)
#4 .../mediawiki/includes/page/Article.php(2166): WikiPage->doPurge()
#5 .../mediawiki/includes/actions/PurgeAction.php(48): Article->doPurge()
#6 .../mediawiki/includes/actions/PurgeAction.php(77): PurgeAction->onSubmit(array)
#7 .../mediawiki/includes/MediaWiki.php(503): PurgeAction->show()
#8 .../mediawiki/includes/MediaWiki.php(288): MediaWiki->performAction(Article, Title)
#9 .../mediawiki/includes/MediaWiki.php(745): MediaWiki->performRequest()
#10 .../mediawiki/includes/MediaWiki.php(519): MediaWiki->main()
#11 .../mediawiki/index.php(43): MediaWiki->run()
#12 {main}

Setup:
MediaWiki 1.27.0
HHVM 3.12.0 (srv)
WikiArticleFeeds 0.73.0 20150316

$wgMainCacheType = CACHE_MEMCACHED;

My quick and dirty workaround for the problem is this but I am sure there are other better solutions..,

--- WikiArticleFeeds_body.php.orig      2016-08-17 09:21:35.116832538 +0200
+++ WikiArticleFeeds_body.php   2016-08-17 09:38:01.185091931 +0200
@@ -283,7 +283,7 @@
         */
        static function wfPurgeFeedsOnArticlePurge( $article ) {
                global $messageMemc, $wgDBname;
-               $titleDBKey = $article->mTitle->getPrefixedDBkey();
+               $titleDBKey = preg_replace("/[^A-Za-z0-9]/", "", $article->mTitle->getPrefixedDBkey());
                $keyPrefix = "{$wgDBname}:wikiarticlefeedsextension:{$titleDBKey}";
                $messageMemc->delete( "{$keyPrefix}:atom:timestamp" );
                $messageMemc->delete( "{$keyPrefix}:atom" );

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 17 2016, 7:59 AM
SamanthaNguyen moved this task from Backlog to Bugs on the WikiArticleFeeds board.Jan 2 2017, 7:50 AM
brion added a subscriber: brion.Jun 15 2017, 2:24 AM

Similar symptoms and root problem to T167465 (incorrectly escaped key values), though with a twist -- WikiArticleFeeds appears to be generating its own keys here, without using any key-creation function. This is probably solvable using $messageMemc->makeKey() (1.27 or later) or the older wfMemcKey() function with relevant parameters.