w/s fixups
[lhc/web/wiklou.git] / includes / parser / LinkHolderArray.php
index f879a65..4104289 100644 (file)
@@ -28,6 +28,7 @@ class LinkHolderArray {
 
        /**
         * Merge another LinkHolderArray into this one
+        * @param $other LinkHolderArray
         */
        function merge( $other ) {
                foreach ( $other->internals as $ns => $entries ) {
@@ -105,9 +106,8 @@ class LinkHolderArray {
         * Get the stub threshold
         */
        function getStubThreshold() {
-               global $wgUser;
                if ( !isset( $this->stubThreshold ) ) {
-                       $this->stubThreshold = $wgUser->getStubThreshold();
+                       $this->stubThreshold = $this->parent->getUser()->getStubThreshold();
                }
                return $this->stubThreshold;
        }
@@ -158,8 +158,7 @@ class LinkHolderArray {
                $query = false;
                $current = null;
                foreach ( $this->internals as $ns => $entries ) {
-                       foreach ( $entries as $index => $entry ) {
-                               $key = "$ns:$index";
+                       foreach ( $entries as $entry ) {
                                $title = $entry['title'];
                                $pdbk = $entry['pdbk'];
 
@@ -308,7 +307,7 @@ class LinkHolderArray {
                $threshold = $this->getStubThreshold();
                $titlesToBeConverted = '';
                $titlesAttrs = array();
-               
+
                // Concatenate titles to a single string, thus we only need auto convert the
                // single string to all variants. This would improve parser's performance
                // significantly.
@@ -323,14 +322,14 @@ class LinkHolderArray {
                                                'ns' => $ns,
                                                'key' => "$ns:$index",
                                                'titleText' => $titleText,
-                                       );                                      
+                                       );
                                        // separate titles with \0 because it would never appears
                                        // in a valid title
                                        $titlesToBeConverted .= $titleText . "\0";
                                }
                        }
                }
-               
+
                // Now do the conversion and explode string to text of titles
                $titlesAllVariants = $wgContLang->autoConvertToAllVariants( $titlesToBeConverted );
                $allVariantsName = array_keys( $titlesAllVariants );
@@ -373,11 +372,12 @@ class LinkHolderArray {
                if(!$linkBatch->isEmpty()){
                        // construct query
                        $dbr = wfGetDB( DB_SLAVE );
-                       $page = $dbr->tableName( 'page' );
-                       $titleClause = $linkBatch->constructSet('page', $dbr);
-                       $variantQuery =  "SELECT page_id, page_namespace, page_title, page_is_redirect, page_len";
-                       $variantQuery .= " FROM $page WHERE $titleClause";
-                       $varRes = $dbr->query( $variantQuery, __METHOD__ );
+                       $varRes = $dbr->select( 'page',
+                               array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_len' ),
+                               $linkBatch->constructSet( 'page', $dbr ),
+                               __METHOD__
+                       );
+
                        $linkcolour_ids = array();
 
                        // for each found variants, figure out link holders and replace
@@ -388,14 +388,14 @@ class LinkHolderArray {
                                $vardbk = $variantTitle->getDBkey();
 
                                $holderKeys = array();
-                               if(isset($variantMap[$varPdbk])){
+                               if( isset( $variantMap[$varPdbk] ) ) {
                                        $holderKeys = $variantMap[$varPdbk];
                                        $linkCache->addGoodLinkObj( $s->page_id, $variantTitle, $s->page_len, $s->page_is_redirect );
                                        $output->addLink( $variantTitle, $s->page_id );
                                }
 
                                // loop over link holders
-                               foreach($holderKeys as $key){
+                               foreach( $holderKeys as $key ) {
                                        list( $ns, $index ) = explode( ':', $key, 2 );
                                        $entry =& $this->internals[$ns][$index];
                                        $pdbk = $entry['pdbk'];