2012-01-09 11:41:13 +00:00
|
|
|
<?php
|
2019-05-28 14:04:23 +00:00
|
|
|
|
2016-04-03 08:37:11 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
|
2012-01-09 11:41:13 +00:00
|
|
|
/**
|
|
|
|
|
* Test class for SpecialSearch class
|
|
|
|
|
* Copyright © 2012, Antoine Musso
|
|
|
|
|
*
|
|
|
|
|
* @author Antoine Musso
|
|
|
|
|
* @group Database
|
|
|
|
|
*/
|
|
|
|
|
class SpecialSearchTest extends MediaWikiTestCase {
|
|
|
|
|
|
2019-07-22 19:10:54 +00:00
|
|
|
/**
|
|
|
|
|
* @covers SpecialSearch::load
|
|
|
|
|
* @covers SpecialSearch::showResults
|
|
|
|
|
*/
|
|
|
|
|
public function testValidateSortOrder() {
|
|
|
|
|
$ctx = new RequestContext();
|
|
|
|
|
$ctx->setRequest( new FauxRequest( [
|
|
|
|
|
'search' => 'foo',
|
|
|
|
|
'fulltext' => 1,
|
|
|
|
|
'sort' => 'invalid',
|
|
|
|
|
] ) );
|
|
|
|
|
$sp = Title::makeTitle( NS_SPECIAL, 'Search' );
|
|
|
|
|
MediaWikiServices::getInstance()
|
|
|
|
|
->getSpecialPageFactory()
|
|
|
|
|
->executePath( $sp, $ctx );
|
|
|
|
|
$html = $ctx->getOutput()->getHTML();
|
|
|
|
|
$this->assertRegExp( '/class="warningbox"/', $html, 'must contain warnings' );
|
|
|
|
|
$this->assertRegExp( '/Sort order of invalid is unrecognized/',
|
|
|
|
|
$html, 'must tell user sort order is invalid' );
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-09 11:41:13 +00:00
|
|
|
/**
|
2012-01-12 09:03:38 +00:00
|
|
|
* @covers SpecialSearch::load
|
2012-01-09 11:41:13 +00:00
|
|
|
* @dataProvider provideSearchOptionsTests
|
2014-04-24 17:52:34 +00:00
|
|
|
* @param array $requested Request parameters. For example:
|
2017-01-16 15:42:53 +00:00
|
|
|
* [ 'ns5' => true, 'ns6' => true ]. Null to use default options.
|
2014-04-24 17:52:34 +00:00
|
|
|
* @param array $userOptions User options to test with. For example:
|
2017-01-16 15:42:53 +00:00
|
|
|
* [ 'searchNs5' => 1 ];. Null to use default options.
|
2014-04-17 18:43:42 +00:00
|
|
|
* @param string $expectedProfile An expected search profile name
|
2014-08-15 16:22:34 +00:00
|
|
|
* @param array $expectedNS Expected namespaces
|
|
|
|
|
* @param string $message
|
2012-01-09 11:41:13 +00:00
|
|
|
*/
|
2014-04-24 17:52:34 +00:00
|
|
|
public function testProfileAndNamespaceLoading( $requested, $userOptions,
|
|
|
|
|
$expectedProfile, $expectedNS, $message = 'Profile name and namespaces mismatches!'
|
2012-01-09 11:41:13 +00:00
|
|
|
) {
|
|
|
|
|
$context = new RequestContext;
|
|
|
|
|
$context->setUser(
|
|
|
|
|
$this->newUserWithSearchNS( $userOptions )
|
2012-01-09 14:42:02 +00:00
|
|
|
);
|
2012-01-09 11:41:13 +00:00
|
|
|
/*
|
2016-07-10 15:23:29 +00:00
|
|
|
$context->setRequest( new FauxRequest( [
|
2012-01-09 11:41:13 +00:00
|
|
|
'ns5'=>true,
|
|
|
|
|
'ns6'=>true,
|
2016-07-10 15:23:29 +00:00
|
|
|
] ));
|
2012-01-09 11:41:13 +00:00
|
|
|
*/
|
2013-02-15 10:24:31 +00:00
|
|
|
$context->setRequest( new FauxRequest( $requested ) );
|
2012-01-09 11:41:13 +00:00
|
|
|
$search = new SpecialSearch();
|
|
|
|
|
$search->setContext( $context );
|
|
|
|
|
$search->load();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verify profile name and namespace in the same assertion to make
|
|
|
|
|
* sure we will be able to fully compare the above code. PHPUnit stop
|
|
|
|
|
* after an assertion fail.
|
|
|
|
|
*/
|
|
|
|
|
$this->assertEquals(
|
2016-02-17 09:09:32 +00:00
|
|
|
[ /** Expected: */
|
2012-01-09 11:41:13 +00:00
|
|
|
'ProfileName' => $expectedProfile,
|
2013-02-15 10:24:31 +00:00
|
|
|
'Namespaces' => $expectedNS,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[ /** Actual: */
|
2012-01-09 11:41:13 +00:00
|
|
|
'ProfileName' => $search->getProfile(),
|
2013-02-15 10:24:31 +00:00
|
|
|
'Namespaces' => $search->getNamespaces(),
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2013-12-01 19:58:51 +00:00
|
|
|
$message
|
2012-01-09 11:41:13 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-22 02:12:37 +00:00
|
|
|
public static function provideSearchOptionsTests() {
|
2016-04-03 08:37:11 +00:00
|
|
|
$defaultNS = MediaWikiServices::getInstance()->getSearchEngineConfig()->defaultNamespaces();
|
2016-02-17 09:09:32 +00:00
|
|
|
$EMPTY_REQUEST = [];
|
2013-02-15 10:24:31 +00:00
|
|
|
$NO_USER_PREF = null;
|
2012-01-09 11:41:13 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2012-01-09 14:42:02 +00:00
|
|
|
/**
|
|
|
|
|
* Parameters:
|
2013-02-15 10:24:31 +00:00
|
|
|
* <Web Request>, <User options>
|
2012-01-09 14:42:02 +00:00
|
|
|
* Followed by expected values:
|
2013-02-15 10:24:31 +00:00
|
|
|
* <ProfileName>, <NSList>
|
2012-01-09 14:42:02 +00:00
|
|
|
* Then an optional message.
|
|
|
|
|
*/
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2012-01-09 14:42:02 +00:00
|
|
|
$EMPTY_REQUEST, $NO_USER_PREF,
|
|
|
|
|
'default', $defaultNS,
|
2017-02-20 23:45:58 +00:00
|
|
|
'T35270: No request nor user preferences should give default profile'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
[ 'ns5' => 1 ], $NO_USER_PREF,
|
|
|
|
|
'advanced', [ 5 ],
|
2012-01-09 14:42:02 +00:00
|
|
|
'Web request with specific NS should override user preference'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
$EMPTY_REQUEST, [
|
2013-02-15 10:24:31 +00:00
|
|
|
'searchNs2' => 1,
|
|
|
|
|
'searchNs14' => 1,
|
2016-02-17 09:09:32 +00:00
|
|
|
] + array_fill_keys( array_map( function ( $ns ) {
|
2013-02-15 10:24:31 +00:00
|
|
|
return "searchNs$ns";
|
|
|
|
|
}, $defaultNS ), 0 ),
|
2016-02-17 09:09:32 +00:00
|
|
|
'advanced', [ 2, 14 ],
|
2017-02-20 23:45:58 +00:00
|
|
|
'T35583: search with no option should honor User search preferences'
|
2013-02-15 10:24:31 +00:00
|
|
|
. ' and have all other namespace disabled'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
];
|
2012-01-09 11:41:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Helper to create a new User object with given options
|
|
|
|
|
* User remains anonymous though
|
2014-08-15 16:22:34 +00:00
|
|
|
* @param array|null $opt
|
2012-01-09 11:41:13 +00:00
|
|
|
*/
|
2019-10-09 18:24:07 +00:00
|
|
|
protected function newUserWithSearchNS( $opt = null ) {
|
2013-02-15 10:24:31 +00:00
|
|
|
$u = User::newFromId( 0 );
|
|
|
|
|
if ( $opt === null ) {
|
2012-01-09 11:41:13 +00:00
|
|
|
return $u;
|
|
|
|
|
}
|
2013-02-15 10:24:31 +00:00
|
|
|
foreach ( $opt as $name => $value ) {
|
2012-01-09 11:41:13 +00:00
|
|
|
$u->setOption( $name, $value );
|
|
|
|
|
}
|
2013-04-26 12:00:22 +00:00
|
|
|
|
2012-01-09 11:41:13 +00:00
|
|
|
return $u;
|
|
|
|
|
}
|
2012-04-13 10:08:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verify we do not expand search term in <title> on search result page
|
|
|
|
|
* https://gerrit.wikimedia.org/r/4841
|
2019-02-01 20:57:58 +00:00
|
|
|
* @covers SpecialSearch::setupPage
|
2012-04-13 10:08:45 +00:00
|
|
|
*/
|
2013-10-23 22:51:31 +00:00
|
|
|
public function testSearchTermIsNotExpanded() {
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->setMwGlobals( [
|
2014-07-08 03:30:18 +00:00
|
|
|
'wgSearchType' => null,
|
2016-02-17 09:09:32 +00:00
|
|
|
] );
|
2012-04-13 10:08:45 +00:00
|
|
|
|
|
|
|
|
# Initialize [[Special::Search]]
|
2016-11-15 01:11:43 +00:00
|
|
|
$ctx = new RequestContext();
|
|
|
|
|
$term = '{{SITENAME}}';
|
|
|
|
|
$ctx->setRequest( new FauxRequest( [ 'search' => $term, 'fulltext' => 1 ] ) );
|
|
|
|
|
$ctx->setTitle( Title::newFromText( 'Special:Search' ) );
|
2012-04-13 10:08:45 +00:00
|
|
|
$search = new SpecialSearch();
|
2016-11-15 01:11:43 +00:00
|
|
|
$search->setContext( $ctx );
|
2012-04-13 10:08:45 +00:00
|
|
|
|
|
|
|
|
# Simulate a user searching for a given term
|
2016-11-15 01:11:43 +00:00
|
|
|
$search->execute( '' );
|
2012-04-13 10:08:45 +00:00
|
|
|
|
|
|
|
|
# Lookup the HTML page title set for that page
|
|
|
|
|
$pageTitle = $search
|
|
|
|
|
->getContext()
|
|
|
|
|
->getOutput()
|
|
|
|
|
->getHTMLTitle();
|
|
|
|
|
|
|
|
|
|
# Compare :-]
|
2012-10-10 09:48:20 +00:00
|
|
|
$this->assertRegExp(
|
2015-06-25 17:43:56 +00:00
|
|
|
'/' . preg_quote( $term, '/' ) . '/',
|
2012-04-13 10:08:45 +00:00
|
|
|
$pageTitle,
|
2012-10-10 09:48:20 +00:00
|
|
|
"Search term '{$term}' should not be expanded in Special:Search <title>"
|
2012-04-13 10:08:45 +00:00
|
|
|
);
|
|
|
|
|
}
|
2015-07-09 18:43:04 +00:00
|
|
|
|
|
|
|
|
public function provideRewriteQueryWithSuggestion() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
|
|
|
|
[
|
2015-07-28 18:26:21 +00:00
|
|
|
'With suggestion and no rewritten query shows did you mean',
|
2015-07-09 18:43:04 +00:00
|
|
|
'/Did you mean: <a[^>]+>first suggestion/',
|
2017-03-18 19:42:09 +00:00
|
|
|
'first suggestion',
|
|
|
|
|
null,
|
|
|
|
|
[ Title::newMainPage() ]
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2015-07-09 18:43:04 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2015-07-28 18:26:21 +00:00
|
|
|
'With rewritten query informs user of change',
|
2015-07-09 18:43:04 +00:00
|
|
|
'/Showing results for <a[^>]+>first suggestion/',
|
2017-03-18 19:42:09 +00:00
|
|
|
'asdf',
|
|
|
|
|
'first suggestion',
|
|
|
|
|
[ Title::newMainPage() ]
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2015-07-09 18:43:04 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2015-07-09 18:43:04 +00:00
|
|
|
'When both queries have no results user gets no results',
|
|
|
|
|
'/There were no results matching the query/',
|
2017-03-18 19:42:09 +00:00
|
|
|
'first suggestion',
|
|
|
|
|
'first suggestion',
|
|
|
|
|
[]
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
];
|
2015-07-09 18:43:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideRewriteQueryWithSuggestion
|
2019-02-01 20:57:58 +00:00
|
|
|
* @covers SpecialSearch::showResults
|
2015-07-09 18:43:04 +00:00
|
|
|
*/
|
2017-03-18 19:42:09 +00:00
|
|
|
public function testRewriteQueryWithSuggestion(
|
|
|
|
|
$message,
|
|
|
|
|
$expectRegex,
|
|
|
|
|
$suggestion,
|
|
|
|
|
$rewrittenQuery,
|
|
|
|
|
array $resultTitles
|
|
|
|
|
) {
|
2017-06-26 16:35:31 +00:00
|
|
|
$results = array_map( function ( $title ) {
|
2017-03-18 19:42:09 +00:00
|
|
|
return SearchResult::newFromTitle( $title );
|
|
|
|
|
}, $resultTitles );
|
|
|
|
|
|
|
|
|
|
$searchResults = new SpecialSearchTestMockResultSet(
|
|
|
|
|
$suggestion,
|
|
|
|
|
$rewrittenQuery,
|
|
|
|
|
$results
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$mockSearchEngine = $this->mockSearchEngine( $searchResults );
|
2018-01-13 00:02:09 +00:00
|
|
|
$search = $this->getMockBuilder( SpecialSearch::class )
|
2016-02-17 09:09:32 +00:00
|
|
|
->setMethods( [ 'getSearchEngine' ] )
|
2015-07-09 18:43:04 +00:00
|
|
|
->getMock();
|
|
|
|
|
$search->expects( $this->any() )
|
|
|
|
|
->method( 'getSearchEngine' )
|
|
|
|
|
->will( $this->returnValue( $mockSearchEngine ) );
|
|
|
|
|
|
|
|
|
|
$search->getContext()->setTitle( Title::makeTitle( NS_SPECIAL, 'Search' ) );
|
2019-08-26 12:24:37 +00:00
|
|
|
$search->getContext()->setLanguage( 'en' );
|
2015-07-09 18:43:04 +00:00
|
|
|
$search->load();
|
|
|
|
|
$search->showResults( 'this is a fake search' );
|
|
|
|
|
|
|
|
|
|
$html = $search->getContext()->getOutput()->getHTML();
|
|
|
|
|
foreach ( (array)$expectRegex as $regex ) {
|
|
|
|
|
$this->assertRegExp( $regex, $html, $message );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-28 18:26:21 +00:00
|
|
|
protected function mockSearchEngine( $results ) {
|
2018-01-13 00:02:09 +00:00
|
|
|
$mock = $this->getMockBuilder( SearchEngine::class )
|
2019-10-11 14:06:13 +00:00
|
|
|
->setMethods( [ 'searchText', 'searchTitle', 'getNearMatcher' ] )
|
2015-07-09 18:43:04 +00:00
|
|
|
->getMock();
|
|
|
|
|
|
|
|
|
|
$mock->expects( $this->any() )
|
|
|
|
|
->method( 'searchText' )
|
2015-07-28 18:26:21 +00:00
|
|
|
->will( $this->returnValue( $results ) );
|
2015-07-09 18:43:04 +00:00
|
|
|
|
2019-10-11 14:06:13 +00:00
|
|
|
$nearMatcherMock = $this->getMockBuilder( SearchNearMatcher::class )
|
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->setMethods( [ 'getNearMatch' ] )
|
|
|
|
|
->getMock();
|
|
|
|
|
|
|
|
|
|
$nearMatcherMock->expects( $this->any() )
|
|
|
|
|
->method( 'getNearMatch' )
|
|
|
|
|
->willReturn( $results->getFirstResult() );
|
|
|
|
|
|
|
|
|
|
$mock->expects( $this->any() )
|
|
|
|
|
->method( 'getNearMatcher' )
|
|
|
|
|
->willReturn( $nearMatcherMock );
|
|
|
|
|
|
2015-07-09 18:43:04 +00:00
|
|
|
return $mock;
|
|
|
|
|
}
|
2017-01-31 13:54:35 +00:00
|
|
|
|
2019-02-01 20:57:58 +00:00
|
|
|
/**
|
|
|
|
|
* @covers SpecialSearch::execute
|
|
|
|
|
*/
|
2017-01-31 13:54:35 +00:00
|
|
|
public function testSubPageRedirect() {
|
|
|
|
|
$this->setMwGlobals( [
|
|
|
|
|
'wgScript' => '/w/index.php',
|
|
|
|
|
] );
|
|
|
|
|
|
|
|
|
|
$ctx = new RequestContext;
|
|
|
|
|
$sp = Title::newFromText( 'Special:Search/foo_bar' );
|
2018-08-12 09:08:58 +00:00
|
|
|
MediaWikiServices::getInstance()->getSpecialPageFactory()->executePath( $sp, $ctx );
|
2017-01-31 13:54:35 +00:00
|
|
|
$url = $ctx->getOutput()->getRedirect();
|
|
|
|
|
|
|
|
|
|
$parts = parse_url( $url );
|
|
|
|
|
$this->assertEquals( '/w/index.php', $parts['path'] );
|
|
|
|
|
parse_str( $parts['query'], $query );
|
|
|
|
|
$this->assertEquals( 'Special:Search', $query['title'] );
|
|
|
|
|
$this->assertEquals( 'foo bar', $query['search'] );
|
|
|
|
|
}
|
2019-10-11 14:06:13 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If the 'search-match-redirect' user pref is false, then SpecialSearch::goResult() should
|
|
|
|
|
* return null
|
|
|
|
|
*
|
|
|
|
|
* @covers SpecialSearch::goResult
|
|
|
|
|
*/
|
|
|
|
|
public function testGoResult_userPrefRedirectOn() {
|
|
|
|
|
$context = new RequestContext;
|
|
|
|
|
$context->setUser(
|
|
|
|
|
$this->newUserWithSearchNS( [ 'search-match-redirect' => false ] )
|
|
|
|
|
);
|
|
|
|
|
$context->setRequest(
|
|
|
|
|
new FauxRequest( [ 'search' => 'TEST_SEARCH_PARAM', 'fulltext' => 1 ] )
|
|
|
|
|
);
|
|
|
|
|
$search = new SpecialSearch();
|
|
|
|
|
$search->setContext( $context );
|
|
|
|
|
$search->load();
|
|
|
|
|
|
|
|
|
|
$this->assertNull( $search->goResult( 'TEST_SEARCH_PARAM' ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If the 'search-match-redirect' user pref is true, then SpecialSearch::goResult() should
|
|
|
|
|
* NOT return null if there is a near match found for the search term
|
|
|
|
|
*
|
|
|
|
|
* @covers SpecialSearch::goResult
|
|
|
|
|
*/
|
|
|
|
|
public function testGoResult_userPrefRedirectOff() {
|
|
|
|
|
// mock the search engine so it returns a near match for an arbitrary search term
|
|
|
|
|
$searchResults = new SpecialSearchTestMockResultSet(
|
|
|
|
|
'TEST_SEARCH_SUGGESTION',
|
|
|
|
|
'',
|
|
|
|
|
[ SearchResult::newFromTitle( Title::newMainPage() ) ]
|
|
|
|
|
);
|
|
|
|
|
$mockSearchEngine = $this->mockSearchEngine( $searchResults );
|
|
|
|
|
$search = $this->getMockBuilder( SpecialSearch::class )
|
|
|
|
|
->setMethods( [ 'getSearchEngine' ] )
|
|
|
|
|
->getMock();
|
|
|
|
|
$search->expects( $this->any() )
|
|
|
|
|
->method( 'getSearchEngine' )
|
|
|
|
|
->will( $this->returnValue( $mockSearchEngine ) );
|
|
|
|
|
|
|
|
|
|
// set up a mock user with 'search-match-redirect' set to true
|
|
|
|
|
$context = new RequestContext;
|
|
|
|
|
$context->setUser(
|
|
|
|
|
$this->newUserWithSearchNS( [ 'search-match-redirect' => true ] )
|
|
|
|
|
);
|
|
|
|
|
$context->setRequest(
|
|
|
|
|
new FauxRequest( [ 'search' => 'TEST_SEARCH_PARAM', 'fulltext' => 1 ] )
|
|
|
|
|
);
|
|
|
|
|
$search->setContext( $context );
|
|
|
|
|
$search->load();
|
|
|
|
|
|
|
|
|
|
$this->assertNotNull( $search->goResult( 'TEST_SEARCH_PARAM' ) );
|
|
|
|
|
}
|
2015-07-09 18:43:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class SpecialSearchTestMockResultSet extends SearchResultSet {
|
|
|
|
|
protected $results;
|
|
|
|
|
protected $suggestion;
|
|
|
|
|
|
2015-09-26 13:06:47 +00:00
|
|
|
public function __construct(
|
|
|
|
|
$suggestion = null,
|
|
|
|
|
$rewrittenQuery = null,
|
2016-02-17 09:09:32 +00:00
|
|
|
array $results = [],
|
2015-09-26 13:06:47 +00:00
|
|
|
$containedSyntax = false
|
|
|
|
|
) {
|
2015-07-09 18:43:04 +00:00
|
|
|
$this->suggestion = $suggestion;
|
2015-07-28 18:26:21 +00:00
|
|
|
$this->rewrittenQuery = $rewrittenQuery;
|
|
|
|
|
$this->results = $results;
|
2015-07-09 18:43:04 +00:00
|
|
|
$this->containedSyntax = $containedSyntax;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-10 22:03:55 +00:00
|
|
|
public function expandResults() {
|
|
|
|
|
return $this->results;
|
2015-07-09 18:43:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getTotalHits() {
|
|
|
|
|
return $this->numRows();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function hasSuggestion() {
|
|
|
|
|
return $this->suggestion !== null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getSuggestionQuery() {
|
|
|
|
|
return $this->suggestion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getSuggestionSnippet() {
|
|
|
|
|
return $this->suggestion;
|
|
|
|
|
}
|
2015-07-28 18:26:21 +00:00
|
|
|
|
|
|
|
|
public function hasRewrittenQuery() {
|
|
|
|
|
return $this->rewrittenQuery !== null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getQueryAfterRewrite() {
|
|
|
|
|
return $this->rewrittenQuery;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getQueryAfterRewriteSnippet() {
|
|
|
|
|
return htmlspecialchars( $this->rewrittenQuery );
|
|
|
|
|
}
|
2019-10-11 14:06:13 +00:00
|
|
|
|
|
|
|
|
public function getFirstResult() {
|
|
|
|
|
if ( count( $this->results ) === 0 ) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return $this->results[0]->getTitle();
|
|
|
|
|
}
|
2012-01-09 11:41:13 +00:00
|
|
|
}
|