/**
* Merge another LinkHolderArray into this one
+ * @param $other LinkHolderArray
*/
function merge( $other ) {
foreach ( $other->internals as $ns => $entries ) {
* 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;
}
$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'];
$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.
'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 );
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
$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'];