Aude has uploaded a new change for review.
https://gerrit.wikimedia.org/r/138602
Change subject: Fix undefined index notice in Special:Search
......................................................................
Fix undefined index notice in Special:Search
instead of insert after 'help' (which has been removed),
insert before 'all'.
also added test cases.
Bug: 66410
Change-Id: I17cc79cf8fd004b3d21110d685ebcba47e88b268
---
M TranslateHooks.php
M tests/phpunit/TranslateHooksTest.php
2 files changed, 39 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate
refs/changes/02/138602/1
diff --git a/TranslateHooks.php b/TranslateHooks.php
index 2cf85b1..6202365 100644
--- a/TranslateHooks.php
+++ b/TranslateHooks.php
@@ -364,7 +364,18 @@
'namespaces' => $wgTranslateMessageNamespaces,
);
- $profiles = wfArrayInsertAfter( $profiles, $insert, 'help' );
+ // insert translations before 'all'
+ $index = array_search( 'all', array_keys( $profiles ) );
+
+ if ( !$index ) {
+ throw new MWException( "'all' not found in $profiles" );
+ }
+
+ $profiles = array_merge(
+ array_slice( $profiles, 0, $index ),
+ $insert,
+ array_slice( $profiles, 0 )
+ );
return true;
}
diff --git a/tests/phpunit/TranslateHooksTest.php
b/tests/phpunit/TranslateHooksTest.php
index bab4743..93d1dcb 100644
--- a/tests/phpunit/TranslateHooksTest.php
+++ b/tests/phpunit/TranslateHooksTest.php
@@ -75,4 +75,31 @@
$wikipage->doEditContent( $content, __METHOD__, 0, false, $user
);
$this->assertEquals( array(), $title->getParentCategories(),
'unknown message' );
}
+
+ public function testSearchProfile() {
+ $profiles = array(
+ 'files' => array(),
+ 'all' => array(),
+ 'advanced' => array()
+ );
+
+ $expected = array( 'files', 'translation', 'all', 'advanced' );
+
+ TranslateHooks::searchProfile( $profiles );
+
+ $this->assertEquals( $expected, array_keys( $profiles ) );
+ }
+
+ public function testSearchProfileThrowsException() {
+ $profiles = array(
+ 'files' => array(),
+ 'help' => array(),
+ 'advanced' => array()
+ );
+
+ $this->setExpectedException( 'MWException' );
+
+ TranslateHooks::searchProfile( $profiles );
+ }
+
}
--
To view, visit https://gerrit.wikimedia.org/r/138602
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I17cc79cf8fd004b3d21110d685ebcba47e88b268
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits