r106021 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106020‎ | r106021 | r106022 >
Date:14:10, 13 December 2011
Author:mah
Status:ok (Comments)
Tags:
Comment:
Fix Bug #32792 - Proofread Page extension inconsistently expects escaped spaces in namespaces

Patch from Minh Nguyễn:

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.

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.
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage_body.php (modified) (history)
  • /trunk/extensions/ProofreadPage/SpecialPagesWithoutScans.php (modified) (history)
  • /trunk/extensions/ProofreadPage/SpecialProofreadPages.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage_body.php
@@ -35,7 +35,7 @@
3636 if ( $namespace !== null ) {
3737 return $namespace;
3838 }
39 - $namespaceText = strtolower( wfMsgForContent( 'proofreadpage_namespace' ) );
 39+ $namespaceText = strtolower( str_replace( ' ', '_', wfMsgForContent( 'proofreadpage_namespace' ) ) );
4040 $namespace = MWNamespace::getCanonicalIndex( $namespaceText );
4141 return $namespace;
4242 }
@@ -50,7 +50,7 @@
5151 if ( $namespace !== null ) {
5252 return $namespace;
5353 }
54 - $namespaceText = strtolower( wfMsgForContent( 'proofreadpage_index_namespace' ) );
 54+ $namespaceText = strtolower( str_replace( ' ', '_', wfMsgForContent( 'proofreadpage_index_namespace' ) ) );
5555 $namespace = MWNamespace::getCanonicalIndex( $namespaceText );
5656 return $namespace;
5757 }
@@ -841,7 +841,7 @@
842842 list( $page, $pagenum ) = $item;
843843 $pp[] = $page;
844844 }
845 - $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $page_namespace ) );
 845+ $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( str_replace( ' ', '_', $page_namespace ) ) );
846846 $dbr = wfGetDB( DB_SLAVE );
847847 $cat = str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality0_category' ) );
848848 $res = $dbr->select(
@@ -1352,7 +1352,7 @@
13531353 */
13541354 private static function update_pr_index( $index, $deletedpage = null ) {
13551355 list( $page_namespace, $index_namespace ) = self::getPageAndIndexNamespace();
1356 - $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $page_namespace ) );
 1356+ $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( str_replace( ' ', '_', $page_namespace ) ) );
13571357 if ( $page_ns_index == null ) {
13581358 return;
13591359 }
@@ -1442,8 +1442,8 @@
14431443 return true;
14441444 }
14451445 list( $page_namespace, $index_namespace ) = self::getPageAndIndexNamespace();
1446 - $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $page_namespace ) );
1447 - $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $index_namespace ) );
 1446+ $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( str_replace( ' ', '_', $page_namespace ) ) );
 1447+ $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( str_replace( ' ', '_', $index_namespace ) ) );
14481448 if( $page_ns_index == null || $index_ns_index == null ) {
14491449 return true;
14501450 }
Index: trunk/extensions/ProofreadPage/SpecialProofreadPages.php
@@ -35,7 +35,7 @@
3636 );
3737 if( $this->searchTerm ) {
3838 $index_namespace = $this->index_namespace;
39 - $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $index_namespace ) );
 39+ $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( str_replace( ' ', '_', $index_namespace ) ) );
4040 $searchEngine = SearchEngine::create();
4141 $searchEngine->setLimitOffset( $limit, $offset );
4242 $searchEngine->setNamespaces( array( $index_ns_index ) );
@@ -89,7 +89,7 @@
9090 if ( $this->searchTerm ) {
9191 if ( $this->searchList !== null ) {
9292 $index_namespace = $this->index_namespace;
93 - $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $index_namespace ) );
 93+ $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( str_replace( ' ', '_', $index_namespace ) ) );
9494 $conds = array( 'page_namespace' => $index_ns_index );
9595 if ( $this->searchList ) {
9696 $conds['page_title'] = $this->searchList;
Index: trunk/extensions/ProofreadPage/SpecialPagesWithoutScans.php
@@ -76,7 +76,7 @@
7777
7878 function getQueryInfo() {
7979 $dbr = wfGetDB( DB_SLAVE );
80 - $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $this->page_namespace ) );
 80+ $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( str_replace( ' ', '_', $this->page_namespace ) ) );
8181
8282 // Construct subqueries
8383 $pagesWithScansSubquery = $dbr->selectSQLText(

Comments

#Comment by 😂 (talk | contribs)   04:53, 6 January 2012

The amount of duplication in this extension is atrocious :\

#Comment by Johnduhart (talk | contribs)   04:54, 6 January 2012

Agreed, it was not fun to work with when I made a patch back in august.

Status & tagging log