Page MenuHomePhabricator

Proofread Page extension inconsistently expects escaped spaces in namespaces
Closed, ResolvedPublic

Description

The Vietnamese localization of the Proofread Page extension uses "Mục lục" as the index namespace. However, the extension sometimes expects the space to be replaced with an underscore.

If the "proofreadpage index namespace" message is localized as "Mục lục", with a space, then things like the "Source" tab and quality bar in the main namespace break, because the following line in prepareArticle() in ProofreadPage_body.php evaluates to null:

$index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $index_namespace ) );

On the other hand, if the "proofreadpage index namespace" message is localized as "Mục_lục", with an underscore, the index page edit form breaks, because expressions like the following in ProofreadPage_body.php evaluate to 0:

preg_match( "/^$index_namespace:(.*)$/", $ref_title->getPrefixedText() )

For instance, [[s:vi:MediaWiki:Proofreadpage index namespace]] is currently set to "Mục_lục", but that causes the edit page for [[s:vi:Mục lục:Viet Nam Su Luoc 1.djvu]] to use the normal wiki editor.

It doesn't really matter which style the extension settles on, as long as it treats "proofreadpage index namespace" and "proofreadpage page namespace" consistently.


Version: unspecified
Severity: major
URL: http://vi.wikisource.org/w/index.php?title=Mục_lục:Viet_Nam_Su_Luoc_1.djvu&&action=edit

Details

Reference
bz32792

Event Timeline

bzimport raised the priority of this task from to High.Nov 21 2014, 11:59 PM
bzimport added projects: ProofreadPage, I18n.
bzimport set Reference to bz32792.
bzimport added a subscriber: Unknown Object (MLST).

It's worse than that, actually: if the namespace messages use underscores, index pages like [[s:vi:Mục lục:Viet Nam Su Luoc 1.djvu]] no longer turn <pagelist> into a color-coded sea of Page: links, because renderPageList()'s call to getPageAndIndexNamespace() comes back empty-handed. As a result, prepareArticle() fails to add a "Source" tab to articles, because prepareArticle() can't find the Index: page that links to the same Page: as the article.

The "Source" tab was previously working at the Vietnamese Wikisource because the Index: pages hadn't been purged following our switch to underscores. The outdated pagelinks table happened to contain entries for "Mục lục:...".

So Vietnamese-language wikis are left with two choices: either use spaces and get working Index: pages, or use underscores and get the quality bar on articles. Either way, we can't get a "Source" tab.

Raising the severity to major because this breaks Wikisource's workflow.

Some of the shared Wikisource scripts, such as [[OldWikisource:PageNumbers.js]], depend on the Proofread Page extension loading the ext.proofreadpage.article module. In case anyone uses the Vietnamese Wikisource to investigate this issue, please note that we've added a hacky JavaScript workaround to load the module and add the "Source" tab ourselves, but the quality bar and index pages are actually still broken.

Created attachment 9626
Patch for calls to MWNamespace::getCanonicalIndex()

This patch modifies all calls to MWNamespace::getCanonicalIndex() to not only lowercase the namespace name but also replace spaces with underscores. getCanonicalIndex() appears to be the only problematic API used by this extension.

This is my first patch; please be gentle. :-)

Attached:

Adding the "patch" and "need-review" keywords so a developer can take a look.

I would like to apply this patch. When I ran the parser and unit tests, it didn't cause a problem. However, I would like to have some tests to add for this new functionality.

Would you write some?

(In reply to comment #5)

I would like to apply this patch. When I ran the parser and unit tests, it
didn't cause a problem. However, I would like to have some tests to add for
this new functionality.

Would you write some?

Just realized ProofReadPage doesn't have any tests currently. Doh!

Applied in r106021