protected static $instance;
public function __construct() {
- $this->mGoodLinks = new HashBagOStuff( array( 'maxKeys' => self::MAX_SIZE ) );
- $this->mBadLinks = new HashBagOStuff( array( 'maxKeys' => self::MAX_SIZE ) );
+ $this->mGoodLinks = new HashBagOStuff( [ 'maxKeys' => self::MAX_SIZE ] );
+ $this->mBadLinks = new HashBagOStuff( [ 'maxKeys' => self::MAX_SIZE ] );
}
/**
* @param int $redir Whether the page is a redirect
* @param int $revision Latest revision's ID
* @param string|null $model Latest revision's content model ID
+ * @param string|null $lang Language code of the page, if not the content language
*/
public function addGoodLinkObj( $id, Title $title, $len = -1, $redir = null,
- $revision = 0, $model = null
+ $revision = 0, $model = null, $lang = null
) {
$dbkey = $title->getPrefixedDBkey();
- $this->mGoodLinks->set( $dbkey, array(
+ $this->mGoodLinks->set( $dbkey, [
'id' => (int)$id,
'length' => (int)$len,
'redirect' => (int)$redir,
'revision' => (int)$revision,
'model' => $model ? (string)$model : null,
- ) );
+ 'lang' => $lang ? (string)$lang : null,
+ ] );
}
/**
*/
public function addGoodLinkObjFromRow( Title $title, $row ) {
$dbkey = $title->getPrefixedDBkey();
- $this->mGoodLinks->set( $dbkey, array(
+ $this->mGoodLinks->set( $dbkey, [
'id' => intval( $row->page_id ),
'length' => intval( $row->page_len ),
'redirect' => intval( $row->page_is_redirect ),
'revision' => intval( $row->page_latest ),
'model' => !empty( $row->page_content_model ) ? strval( $row->page_content_model ) : null,
- ) );
+ 'lang' => !empty( $row->page_lang ) ? strval( $row->page_lang ) : null,
+ ] );
}
/**
}
public function clearBadLink( $title ) {
- $this->mBadLinks->clear( array( $title ) );
+ $this->mBadLinks->clear( [ $title ] );
}
/**
* @return int Page ID or zero
*/
public function addLinkObj( Title $nt ) {
- global $wgContentHandlerUseDB;
+ global $wgContentHandlerUseDB, $wgPageLanguageUseDB;
$key = $nt->getPrefixedDBkey();
if ( $this->isBadLink( $key ) || $nt->isExternal() ) {
// Some fields heavily used for linking...
$db = $this->mForUpdate ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
- $fields = array( 'page_id', 'page_len', 'page_is_redirect', 'page_latest' );
+ $fields = [ 'page_id', 'page_len', 'page_is_redirect', 'page_latest' ];
if ( $wgContentHandlerUseDB ) {
$fields[] = 'page_content_model';
}
+ if ( $wgPageLanguageUseDB ) {
+ $fields[] = 'page_lang';
+ }
$row = $db->selectRow( 'page', $fields,
- array( 'page_namespace' => $nt->getNamespace(), 'page_title' => $nt->getDBkey() ),
+ [ 'page_namespace' => $nt->getNamespace(), 'page_title' => $nt->getDBkey() ],
__METHOD__
);