| Index: trunk/phase3/tests/phpunit/includes/specials/SpecialSearchTest.php |
| — | — | @@ -14,11 +14,12 @@ |
| 15 | 15 | function tearDown() { } |
| 16 | 16 | |
| 17 | 17 | /** |
| | 18 | + * @covers SpecialSearch::load |
| 18 | 19 | * @dataProvider provideSearchOptionsTests |
| 19 | 20 | * @param $requested Array Request parameters. For example array( 'ns5' => true, 'ns6' => true). NULL to use default options. |
| 20 | 21 | * @param $userOptions Array User options to test with. For example array('searchNs5' => 1 );. NULL to use default options. |
| 21 | 22 | */ |
| 22 | | - function testFoobar( |
| | 23 | + function testProfileAndNamespaceLoading( |
| 23 | 24 | $requested, $userOptions, $expectedProfile, $expectedNS, |
| 24 | 25 | $message = 'Profile name andnamespaces mismatches!' |
| 25 | 26 | ) { |
| — | — | @@ -79,14 +80,11 @@ |
| 80 | 81 | 'advanced', array( 5), |
| 81 | 82 | 'Web request with specific NS should override user preference' |
| 82 | 83 | ), |
| 83 | | - /* FIXME this test is for bug 33583 |
| 84 | | - array( |
| 85 | | - $EMPTY_REQUEST, array( 'searchNs2' ), |
| 86 | | - 'advanced', array( 2 ), |
| 87 | | - 'Bug 33583: search with no option should honor User search preferences' |
| 88 | | - ), |
| 89 | | - */ |
| 90 | | - |
| | 84 | + array( |
| | 85 | + $EMPTY_REQUEST, array( 'searchNs2' => 1, 'searchNs14' => 1 ), |
| | 86 | + 'advanced', array( 2, 14 ), |
| | 87 | + 'Bug 33583: search with no option should honor User search preferences' |
| | 88 | + ), |
| 91 | 89 | ); |
| 92 | 90 | } |
| 93 | 91 | |
| Index: trunk/phase3/includes/specials/SpecialSearch.php |
| — | — | @@ -110,6 +110,8 @@ |
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * Set up basic search parameters from the request and user settings. |
| | 114 | + * |
| | 115 | + * @see tests/phpunit/includes/specials/SpecialSearchTest.php |
| 114 | 116 | */ |
| 115 | 117 | public function load() { |
| 116 | 118 | $request = $this->getRequest(); |
| — | — | @@ -117,27 +119,30 @@ |
| 118 | 120 | $this->mPrefix = $request->getVal( 'prefix', '' ); |
| 119 | 121 | |
| 120 | 122 | $user = $this->getUser(); |
| | 123 | + |
| 121 | 124 | # Extract manually requested namespaces |
| 122 | 125 | $nslist = $this->powerSearch( $request ); |
| | 126 | + if ( !count( $nslist ) ) { |
| | 127 | + # Fallback to user preference |
| | 128 | + $nslist = SearchEngine::userNamespaces( $user ); |
| | 129 | + } |
| | 130 | + |
| 123 | 131 | $profile = null; |
| 124 | 132 | if ( !count( $nslist ) ) { |
| 125 | 133 | $profile = 'default'; |
| 126 | 134 | } |
| | 135 | + |
| 127 | 136 | $profile = $request->getVal( 'profile', $profile ); |
| 128 | 137 | $profiles = $this->getSearchProfiles(); |
| 129 | 138 | if ( $profile === null ) { |
| 130 | 139 | // BC with old request format |
| 131 | 140 | $profile = 'advanced'; |
| 132 | | - if ( count( $nslist ) ) { |
| 133 | | - foreach( $profiles as $key => $data ) { |
| 134 | | - if ( $nslist === $data['namespaces'] && $key !== 'advanced') { |
| 135 | | - $profile = $key; |
| 136 | | - } |
| | 141 | + foreach( $profiles as $key => $data ) { |
| | 142 | + if ( $nslist === $data['namespaces'] && $key !== 'advanced') { |
| | 143 | + $profile = $key; |
| 137 | 144 | } |
| 138 | | - $this->namespaces = $nslist; |
| 139 | | - } else { |
| 140 | | - $this->namespaces = SearchEngine::userNamespaces( $user ); |
| 141 | 145 | } |
| | 146 | + $this->namespaces = $nslist; |
| 142 | 147 | } elseif ( $profile === 'advanced' ) { |
| 143 | 148 | $this->namespaces = $nslist; |
| 144 | 149 | } else { |