X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Fparser%2FLinkHolderArray.php;h=5418b6e517fc67babaa87969806ab95deffc6e6e;hb=d761eab34985f57a3e304198db60a1d9b1fc51bc;hp=54bb41fa216f45b994202b5a670c2c09c490ba00;hpb=f89b1e3238d903ad34f3e0abc2ed2d3802e3c2ab;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/LinkHolderArray.php b/includes/parser/LinkHolderArray.php index 54bb41fa21..5418b6e517 100644 --- a/includes/parser/LinkHolderArray.php +++ b/includes/parser/LinkHolderArray.php @@ -35,15 +35,15 @@ class LinkHolderArray { * Compact the titles, only serialize the text form. */ function __sleep() { - foreach ( $this->internals as $ns => &$nsLinks ) { - foreach ( $nsLinks as $key => &$entry ) { + foreach ( $this->internals as &$nsLinks ) { + foreach ( $nsLinks as &$entry ) { unset( $entry['title'] ); } } unset( $nsLinks ); unset( $entry ); - foreach ( $this->interwikis as $key => &$entry ) { + foreach ( $this->interwikis as &$entry ) { unset( $entry['title'] ); } unset( $entry ); @@ -55,15 +55,15 @@ class LinkHolderArray { * Recreate the Title objects */ function __wakeup() { - foreach ( $this->internals as $ns => &$nsLinks ) { - foreach ( $nsLinks as $key => &$entry ) { + foreach ( $this->internals as &$nsLinks ) { + foreach ( $nsLinks as &$entry ) { $entry['title'] = Title::newFromText( $entry['pdbk'] ); } } unset( $nsLinks ); unset( $entry ); - foreach ( $this->interwikis as $key => &$entry ) { + foreach ( $this->interwikis as &$entry ) { $entry['title'] = Title::newFromText( $entry['pdbk'] ); } unset( $entry ); @@ -94,7 +94,7 @@ class LinkHolderArray { * strings will be returned. * * @param $other LinkHolderArray - * @param $text Array of strings + * @param $texts Array of strings * @return Array */ function mergeForeign( $other, $texts ) { @@ -227,7 +227,7 @@ class LinkHolderArray { } /** - * FIXME: update documentation. makeLinkObj() is deprecated. + * @todo FIXME: Update documentation. makeLinkObj() is deprecated. * Replace link placeholders with actual links, in the buffer * Placeholders created in Skin::makeLinkObj() * Returns an array of link CSS classes, indexed by PDBK. @@ -254,13 +254,11 @@ class LinkHolderArray { global $wgContLang; $colours = array(); - $sk = $this->parent->getOptions()->getSkin( $this->parent->mTitle ); $linkCache = LinkCache::singleton(); $output = $this->parent->getOutput(); wfProfileIn( __METHOD__.'-check' ); $dbr = wfGetDB( DB_SLAVE ); - $page = $dbr->tableName( 'page' ); $threshold = $this->parent->getOptions()->getStubThreshold(); # Sort by namespace @@ -269,8 +267,7 @@ class LinkHolderArray { $linkcolour_ids = array(); # Generate query - $query = false; - $current = null; + $queries = array(); foreach ( $this->internals as $ns => $entries ) { foreach ( $entries as $entry ) { $title = $entry['title']; @@ -288,32 +285,35 @@ class LinkHolderArray { } elseif ( $ns == NS_SPECIAL ) { $colours[$pdbk] = 'new'; } elseif ( ( $id = $linkCache->getGoodLinkID( $pdbk ) ) != 0 ) { - $colours[$pdbk] = $sk->getLinkColour( $title, $threshold ); + $colours[$pdbk] = Linker::getLinkColour( $title, $threshold ); $output->addLink( $title, $id ); $linkcolour_ids[$id] = $pdbk; } elseif ( $linkCache->isBadLink( $pdbk ) ) { $colours[$pdbk] = 'new'; } else { # Not in the link cache, add it to the query - if ( !isset( $current ) ) { - $current = $ns; - $query = "SELECT page_id, page_namespace, page_title, page_is_redirect, page_len, page_latest"; - $query .= " FROM $page WHERE (page_namespace=$ns AND page_title IN("; - } elseif ( $current != $ns ) { - $current = $ns; - $query .= ")) OR (page_namespace=$ns AND page_title IN("; - } else { - $query .= ', '; - } - - $query .= $dbr->addQuotes( $title->getDBkey() ); + $queries[$ns][] = $title->getDBkey(); } } } - if ( $query ) { - $query .= '))'; + if ( $queries ) { + $where = array(); + foreach( $queries as $ns => $pages ){ + $where[] = $dbr->makeList( + array( + 'page_namespace' => $ns, + 'page_title' => $pages, + ), + LIST_AND + ); + } - $res = $dbr->query( $query, __METHOD__ ); + $res = $dbr->select( + 'page', + array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_len', 'page_latest' ), + $dbr->makeList( $where, LIST_OR ), + __METHOD__ + ); # Fetch data and form into an associative array # non-existent = broken @@ -322,10 +322,10 @@ class LinkHolderArray { $pdbk = $title->getPrefixedDBkey(); $linkCache->addGoodLinkObj( $s->page_id, $title, $s->page_len, $s->page_is_redirect, $s->page_latest ); $output->addLink( $title, $s->page_id ); - # FIXME: convoluted data flow + # @todo FIXME: Convoluted data flow # The redirect status and length is passed to getLinkColour via the LinkCache # Use formal parameters instead - $colours[$pdbk] = $sk->getLinkColour( $title, $threshold ); + $colours[$pdbk] = Linker::getLinkColour( $title, $threshold ); //add id to the extension todolist $linkcolour_ids[$s->page_id] = $pdbk; } @@ -370,7 +370,7 @@ class LinkHolderArray { } $type = array( 'known', 'noclasses' ); } - $replacePairs[$searchkey] = $sk->link( $title, $displayText, + $replacePairs[$searchkey] = Linker::link( $title, $displayText, $attribs, $query, $type ); } } @@ -398,11 +398,10 @@ class LinkHolderArray { wfProfileIn( __METHOD__ ); # Make interwiki link HTML - $sk = $this->parent->getOptions()->getSkin( $this->parent->mTitle ); $output = $this->parent->getOutput(); $replacePairs = array(); foreach( $this->interwikis as $key => $link ) { - $replacePairs[$key] = $sk->link( $link['title'], $link['text'] ); + $replacePairs[$key] = Linker::link( $link['title'], $link['text'] ); $output->addInterwikiLink( $link['title'] ); } $replacer = new HashtableReplacer( $replacePairs, 1 ); @@ -423,7 +422,6 @@ class LinkHolderArray { $variantMap = array(); // maps $pdbkey_Variant => $keys (of link holders) $output = $this->parent->getOutput(); $linkCache = LinkCache::singleton(); - $sk = $this->parent->getOptions()->getSkin( $this->parent->mTitle ); $threshold = $this->parent->getOptions()->getStubThreshold(); $titlesToBeConverted = ''; $titlesAttrs = array(); @@ -525,10 +523,10 @@ class LinkHolderArray { $entry['pdbk'] = $varPdbk; // set pdbk and colour - # FIXME: convoluted data flow + # @todo FIXME: Convoluted data flow # The redirect status and length is passed to getLinkColour via the LinkCache # Use formal parameters instead - $colours[$varPdbk] = $sk->getLinkColour( $variantTitle, $threshold ); + $colours[$varPdbk] = Linker::getLinkColour( $variantTitle, $threshold ); $linkcolour_ids[$s->page_id] = $pdbk; } }