X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fsearch%2FSearchMySQL.php;h=7e823786c22030a141e333f6b95c0dc1913728de;hb=58cb1f824ac75c3b58ba19d1e88c1b38f9dc1fab;hp=246f115546d547579584180b2db08f7871b9fd13;hpb=08db2b721e95395842bb4972ab89a5bd7ec09c7e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/search/SearchMySQL.php b/includes/search/SearchMySQL.php index 246f115546..7e823786c2 100644 --- a/includes/search/SearchMySQL.php +++ b/includes/search/SearchMySQL.php @@ -47,10 +47,10 @@ class SearchMySQL extends SearchDatabase { $lc = $this->legalSearchChars(); // Minus format chars $searchon = ''; - $this->searchTerms = array(); + $this->searchTerms = []; # @todo FIXME: This doesn't handle parenthetical expressions. - $m = array(); + $m = []; if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $filteredText, $m, PREG_SET_ORDER ) ) { foreach ( $m as $bits ) { @@ -80,7 +80,7 @@ class SearchMySQL extends SearchDatabase { if ( is_array( $convertedVariants ) ) { $variants = array_unique( array_values( $convertedVariants ) ); } else { - $variants = array( $term ); + $variants = [ $term ]; } // The low-level search index does some processing on input to work @@ -88,7 +88,7 @@ class SearchMySQL extends SearchDatabase { // fulltext engine. // For Chinese this also inserts spaces between adjacent Han characters. $strippedVariants = array_map( - array( $wgContLang, 'normalizeForSearch' ), + [ $wgContLang, 'normalizeForSearch' ], $variants ); // Some languages such as Chinese force all variants to a canonical @@ -257,13 +257,13 @@ class SearchMySQL extends SearchDatabase { * @since 1.18 (changed) */ function getQuery( $filteredTerm, $fulltext ) { - $query = array( - 'tables' => array(), - 'fields' => array(), - 'conds' => array(), - 'options' => array(), - 'joins' => array(), - ); + $query = [ + 'tables' => [], + 'fields' => [], + 'conds' => [], + 'options' => [], + 'joins' => [], + ]; $this->queryMain( $query, $filteredTerm, $fulltext ); $this->queryFeatures( $query ); @@ -310,13 +310,13 @@ class SearchMySQL extends SearchDatabase { function getCountQuery( $filteredTerm, $fulltext ) { $match = $this->parseQuery( $filteredTerm, $fulltext ); - $query = array( - 'tables' => array( 'page', 'searchindex' ), - 'fields' => array( 'COUNT(*) as c' ), - 'conds' => array( 'page_id=si_page', $match ), - 'options' => array(), - 'joins' => array(), - ); + $query = [ + 'tables' => [ 'page', 'searchindex' ], + 'fields' => [ 'COUNT(*) as c' ], + 'conds' => [ 'page_id=si_page', $match ], + 'options' => [], + 'joins' => [], + ]; $this->queryFeatures( $query ); $this->queryNamespaces( $query ); @@ -335,12 +335,12 @@ class SearchMySQL extends SearchDatabase { function update( $id, $title, $text ) { $dbw = wfGetDB( DB_MASTER ); $dbw->replace( 'searchindex', - array( 'si_page' ), - array( + [ 'si_page' ], + [ 'si_page' => $id, 'si_title' => $this->normalizeText( $title ), 'si_text' => $this->normalizeText( $text ) - ), __METHOD__ ); + ], __METHOD__ ); } /** @@ -354,10 +354,10 @@ class SearchMySQL extends SearchDatabase { $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'searchindex', - array( 'si_title' => $this->normalizeText( $title ) ), - array( 'si_page' => $id ), + [ 'si_title' => $this->normalizeText( $title ) ], + [ 'si_page' => $id ], __METHOD__, - array( $dbw->lowPriorityOption() ) ); + [ $dbw->lowPriorityOption() ] ); } /** @@ -370,7 +370,7 @@ class SearchMySQL extends SearchDatabase { function delete( $id, $title ) { $dbw = wfGetDB( DB_MASTER ); - $dbw->delete( 'searchindex', array( 'si_page' => $id ), __METHOD__ ); + $dbw->delete( 'searchindex', [ 'si_page' => $id ], __METHOD__ ); } /** @@ -388,7 +388,7 @@ class SearchMySQL extends SearchDatabase { // need to fold cases and convert to hex $out = preg_replace_callback( "/([\\xc0-\\xff][\\x80-\\xbf]*)/", - array( $this, 'stripForSearchCallback' ), + [ $this, 'stripForSearchCallback' ], $wgContLang->lc( $out ) ); // And to add insult to injury, the default indexing @@ -406,7 +406,6 @@ class SearchMySQL extends SearchDatabase { // Periods within things like hostnames and IP addresses // are also important -- we want a search for "example.com" // or "192.168.1.1" to work sanely. - // // MySQL's search seems to ignore them, so you'd match on // "example.wikipedia.com" and "192.168.83.1" as well. $out = preg_replace(