Page MenuHomePhabricator

Translation page not created when <1% translated
Closed, ResolvedPublic1 Estimated Story Points

Description

https://meta.wikimedia.org/wiki/Wikimedia_Foundation_Annual_Plan/2017-2018/Mid-year_review/ar does not exist, despite https://meta.wikimedia.org/wiki/Translations:Wikimedia_Foundation_Annual_Plan/2017-2018/Mid-year_review/342/ar existing, and wasn't created when I edited that page.

Could someone please look into the logs and figure out what happened here?

Details

Event Timeline

In the logs I see:

RenderTranslationPageJob [Wikimedia Foundation Annual Plan/2017-2018/Mid-year review/ar]: No translations found and translation page does not exist. Nothing to do.

On same request id later I see errors from MySQL server has gone away errors.

https://meta.wikimedia.org/wiki/Special:MessageGroupStats?group=page-Wikimedia+Foundation+Annual+Plan%2F2017-2018%2FFinal&messages=&language=ar&x=D shows nothing to show... which is weird. Maybe because the page is discouraged?

https://meta.wikimedia.org/wiki/Special:ApiSandbox#action=query&format=json&meta=messagegroupstats&formatversion=2&mgsgroup=page-Wikimedia%20Foundation%20Annual%20Plan%2F2017-2018%2FFinal shows:

{
    "total": 49,
    "translated": 1,
    "fuzzy": 0,
    "proofread": 1,
    "code": "ar",
    "language": "ar"
},

https://meta.wikimedia.org/w/index.php?title=Special%3ATranslate&group=page-Wikimedia+Foundation+Annual+Plan%2F2017-2018%2FMid-year+review&language=ar&filter=translated&optional=1&action=page does show one translation.

Debugging further:

nikerabbit@deploy1003:~$ mwscript-k8s --attach -- shell.php --wiki=metawiki
⏳ Starting shell.php on Kubernetes as job mw-script.eqiad.eazuorwm ...
🚀 Job is running.
ℹ Expecting a prompt but don't see it? Due to a race condition, the beginning of the output might be missing. Try pressing enter.
📜 Attached to stdin/stdout:

> $t = \MediaWiki\Title\Title::newFromText( 'Wikimedia Foundation Annual Plan/2017-2018/Mid-year review/ar' );
= MediaWiki\Title\Title {#5465
    +mArticleID: -1,
    +prefixedText: null,
    +mRedirect: null,
  }

> $tpPage = \MediaWiki\Extension\Translate\PageTranslation\TranslatablePage::getTranslationPageFromTitle( $t );
= MediaWiki\Extension\Translate\PageTranslation\TranslationPage {#7248}

> $mwServices = \MediaWiki\MediaWikiServices::getInstance();
= MediaWiki\MediaWikiServices {#189}

> $c = $tpPage->getPageContent( $mwServices->getParser(), $p );
= MediaWiki\Content\WikitextContent {#41126}

> var_dump( $p);
int(0)

And further:

> $collection = $tpPage->getMessageCollection();
= MediaWiki\Extension\Translate\MessageLoading\MessageCollection {#42042
    +code: "ar",
  }

> count( $collection );
= 736

> $tpPage->filterMessageCollection( $collection );
= null

> count( $collection );
= 1

> $percentageTranslated = (int)(( 1 / 736 ) * 100 );
= 0

The conclusion is that the translation percentage rounds to zero.

Since there is only one caller, maybe it could return a float instead.

If there’s only one caller, which only checks whether the result is zero or not, why does it return a percentage at all? It could return the number of translated units (i.e. $keysWithTranslation) as an integer, without any floating-point operations and thus with absolutely no risk of rounding issues (and without the need to branch on $allKeys being zero), or even simply a boolean telling if count($collection) === 0.

Pppery renamed this task from Translation page inexplicably not created to Translation page not created when <1% translate.Apr 24 2026, 6:34 AM
Pppery renamed this task from Translation page not created when <1% translate to Translation page not created when <1% translated.

Change #1288355 had a related patch set uploaded (by Pppery; author: Pppery):

[mediawiki/extensions/Translate@master] Avoid computing unneeded percentaged

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

Change #1288355 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Avoid computing unneeded percentages

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

With ?uselang=hu, I do see Arabic on the Arabic page. Maybe the canonical English parse was done before the row of the page was inserted in the database?