$mImages, # DB keys of the images used, in the array key only
$mTemplates, # Map of title strings to IDs for the template references, including broken ones
$mExternals, # URLs of external links, array key only
- $mCategories, # Map of category names to sort keys
+ $mCategories, # Map of category names to sort keys
+ $mInterlangs, # Map of language codes to titles
$mDb, # Database connection reference
$mOptions, # SELECT options to be used (array)
$mRecursive; # Whether to queue jobs for recursive updates
$this->mTemplates = $parserOutput->getTemplates();
$this->mExternals = $parserOutput->getExternalLinks();
$this->mCategories = $parserOutput->getCategories();
- $this->mRecursive = $recursive;
+ # Convert the format of the interlanguage links
+ # I didn't want to change it in the ParserOutput, because that array is passed all
+ # the way back to the skin, so either a skin API break would be required, or an
+ # inefficient back-conversion.
+ $ill = $parserOutput->getLanguageLinks();
+ $this->mInterlangs = array();
+ foreach ( $ill as $link ) {
+ list( $key, $title ) = explode( ':', $link, 2 );
+ $this->mInterlangs[$key] = $title;
+ }
+
+ $this->mRecursive = $recursive;
}
/**
# External links
$existing = $this->getExistingExternals();
$this->incrTableUpdate( 'externallinks', 'el', $this->getExternalDeletions( $existing ),
- $this->getExternalInsertions( $existing ) );
+ $this->getExternalInsertions( $existing ) );
+
+ # Language links
+ $existing = $this->getExistingInterlangs();
+ $this->incrTableUpdate( 'langlinks', 'll', $this->getInterlangDeletions( $existing ),
+ $this->getInterlangInsertions( $existing ) );
# Template links
$existing = $this->getExistingTemplates();
require_once( 'JobQueue.php' );
Job::queueLinksJobs( $tlto );
}
- }
+ }
# Category links
$existing = $this->getExistingCategories();
$this->dumbTableUpdate( 'imagelinks', $this->getImageInsertions(), 'il_from' );
$this->dumbTableUpdate( 'categorylinks', $this->getCategoryInsertions(), 'cl_from' );
$this->dumbTableUpdate( 'templatelinks', $this->getTemplateInsertions(), 'tl_from' );
- $this->dumbTableUpdate( 'externallinks', $this->getExternalInsertions(), 'el_from' );
+ $this->dumbTableUpdate( 'externallinks', $this->getExternalInsertions(), 'el_from' );
+ $this->dumbTableUpdate( 'langlinks', $this->getInterlangInsertions(), 'll_from' );
# Update the cache of all the category pages and image description pages which were changed
$this->invalidateCategories( $categoryUpdates );
$where = false;
}
} else {
+ if ( $table == 'langlinks' ) {
+ $toField = 'll_lang';
+ } else {
+ $toField = $prefix . '_to';
+ }
if ( count( $deletions ) ) {
- $where[] = "{$prefix}_to IN (" . $this->mDb->makeList( array_keys( $deletions ) ) . ')';
+ $where[] = "$toField IN (" . $this->mDb->makeList( array_keys( $deletions ) ) . ')';
} else {
$where = false;
}
return $arr;
}
+ /**
+ * Get an array of interlanguage link insertions
+ * @param array $existing Array mapping existing language codes to titles
+ * @access private
+ */
+ function getInterlangInsertions( $existing = array() ) {
+ $diffs = array_diff_assoc( $this->mInterlangs, $existing );
+ $arr = array();
+ foreach( $diffs as $lang => $title ) {
+ $arr[] = array(
+ 'll_from' => $this->mId,
+ 'll_lang' => $lang,
+ 'll_title' => $title
+ );
+ }
+ return $arr;
+ }
+
/**
* Given an array of existing links, returns those links which are not in $this
* and thus should be deleted.
return array_diff_assoc( $existing, $this->mCategories );
}
+ /**
+ * Given an array of existing interlanguage links, returns those links which are not
+ * in $this and thus should be deleted.
+ * @access private
+ */
+ function getInterlangDeletions( $existing ) {
+ return array_diff_assoc( $existing, $this->mInterlangs );
+ }
+
/**
* Get an array of existing links, as a 2-D array
* @access private
$this->mDb->freeResult( $res );
return $arr;
}
+
+ /**
+ * Get an array of existing interlanguage links, with the language code in the key and the
+ * title in the value.
+ * @access private
+ */
+ function getExistingInterlangs() {
+ $fname = 'LinksUpdate::getExistingInterlangs';
+ $res = $this->mDb->select( 'langlinks', array( 'll_lang', 'll_title' ),
+ array( 'll_from' => $this->mId ), $fname, $this->mOptions );
+ $arr = array();
+ while ( $row = $this->mDb->fetchObject( $res ) ) {
+ $arr[$row->ll_lang] = $row->ll_title;
+ }
+ return $arr;
+ }
}
?>
}
# Extensions
- if ( !$found ) {
+ if ( !$found && substr( $part1, 0, 1 ) == '#' ) {
$colonPos = strpos( $part1, ':' );
if ( $colonPos !== false ) {
- $function = strtolower( substr( $part1, 0, $colonPos ) );
+ $function = strtolower( substr( $part1, 1, $colonPos - 1 ) );
if ( isset( $this->mFunctionHooks[$function] ) ) {
$funcArgs = array_merge( array( &$this, substr( $part1, $colonPos + 1 ) ), $args );
$result = call_user_func_array( $this->mFunctionHooks[$function], $funcArgs );
}
function getText() { return $this->mText; }
- function getLanguageLinks() { return $this->mLanguageLinks; }
+ function &getLanguageLinks() { return $this->mLanguageLinks; }
function getCategoryLinks() { return array_keys( $this->mCategories ); }
function &getCategories() { return $this->mCategories; }
function getCacheTime() { return $this->mCacheTime; }
$this->mTemplates[$ns][$dbk] = $id;
}
- /**
- * @deprecated
- */
- /*
- function merge( $other ) {
- $this->mLanguageLinks = array_merge( $this->mLanguageLinks, $other->mLanguageLinks );
- $this->mCategories = array_merge( $this->mCategories, $this->mLanguageLinks );
- $this->mContainsOldMagic = $this->mContainsOldMagic || $other->mContainsOldMagic;
- }*/
-
/**
* Return true if this cached output object predates the global or
* per-article cache invalidation timestamps, or if it comes from
$this->getCacheTime() <= $wgCacheEpoch ||
!isset( $this->mVersion ) ||
version_compare( $this->mVersion, MW_PARSER_VERSION, "lt" );
- }
+ }
}
/**