parent::__construct( false ); // no implicit transaction
$this->mTitle = $title;
- $this->mId = $title->getArticleID();
+ $this->mId = $title->getArticleID( Title::GAID_FOR_UPDATE );
if ( !$this->mId ) {
throw new InvalidArgumentException(
# 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();
+ $this->mInterlangs = [];
foreach ( $ill as $link ) {
list( $key, $title ) = explode( ':', $link, 2 );
$this->mInterlangs[$key] = $title;
$this->mRecursive = $recursive;
- Hooks::run( 'LinksUpdateConstructed', array( &$this ) );
+ Hooks::run( 'LinksUpdateConstructed', [ &$this ] );
}
/**
* Update link tables with outgoing links from an updated article
*/
public function doUpdate() {
- Hooks::run( 'LinksUpdate', array( &$this ) );
+ Hooks::run( 'LinksUpdate', [ &$this ] );
$this->doIncrementalUpdate();
- $that = $this;
- $this->mDb->onTransactionIdle( function() use ( $that ) {
- Hooks::run( 'LinksUpdateComplete', array( &$that ) );
+ $this->mDb->onTransactionIdle( function() {
+ Hooks::run( 'LinksUpdateComplete', [ &$this ] );
} );
}
// should be implicitly protected as soon as possible, if applicable.
// These jobs duplicate a subset of the above ones, but can run sooner.
// Which ever runs first generally no-ops the other one.
- $jobs = array();
+ $jobs = [];
foreach ( $bc->getCascadeProtectedLinks() as $title ) {
- $jobs[] = RefreshLinksJob::newPrioritized( $title, array() );
+ $jobs[] = RefreshLinksJob::newPrioritized( $title, [] );
}
JobQueueGroup::singleton()->push( $jobs );
}
if ( $title->getBacklinkCache()->hasLinks( $table ) ) {
$job = new RefreshLinksJob(
$title,
- array(
+ [
'table' => $table,
'recursive' => true,
- ) + Job::newRootJobParams( // "overall" refresh links job info
+ ] + Job::newRootJobParams( // "overall" refresh links job info
"refreshlinks:{$table}:{$title->getPrefixedText()}"
)
);
} else {
$fromField = "{$prefix}_from";
}
- $where = array( $fromField => $this->mId );
+ $where = [ $fromField => $this->mId ];
if ( $table == 'pagelinks' || $table == 'templatelinks' || $table == 'iwlinks' ) {
if ( $table == 'iwlinks' ) {
$baseKey = 'iwl_prefix';
}
if ( count( $insertions ) ) {
$this->mDb->insert( $table, $insertions, __METHOD__, 'IGNORE' );
- Hooks::run( 'LinksUpdateAfterInsert', array( $this, $table, $insertions ) );
+ Hooks::run( 'LinksUpdateAfterInsert', [ $this, $table, $insertions ] );
}
}
* @param array $existing
* @return array
*/
- private function getLinkInsertions( $existing = array() ) {
- $arr = array();
+ private function getLinkInsertions( $existing = [] ) {
+ $arr = [];
foreach ( $this->mLinks as $ns => $dbkeys ) {
$diffs = isset( $existing[$ns] )
? array_diff_key( $dbkeys, $existing[$ns] )
: $dbkeys;
foreach ( $diffs as $dbk => $id ) {
- $arr[] = array(
+ $arr[] = [
'pl_from' => $this->mId,
'pl_from_namespace' => $this->mTitle->getNamespace(),
'pl_namespace' => $ns,
'pl_title' => $dbk
- );
+ ];
}
}
* @param array $existing
* @return array
*/
- private function getTemplateInsertions( $existing = array() ) {
- $arr = array();
+ private function getTemplateInsertions( $existing = [] ) {
+ $arr = [];
foreach ( $this->mTemplates as $ns => $dbkeys ) {
$diffs = isset( $existing[$ns] ) ? array_diff_key( $dbkeys, $existing[$ns] ) : $dbkeys;
foreach ( $diffs as $dbk => $id ) {
- $arr[] = array(
+ $arr[] = [
'tl_from' => $this->mId,
'tl_from_namespace' => $this->mTitle->getNamespace(),
'tl_namespace' => $ns,
'tl_title' => $dbk
- );
+ ];
}
}
* @param array $existing
* @return array
*/
- private function getImageInsertions( $existing = array() ) {
- $arr = array();
+ private function getImageInsertions( $existing = [] ) {
+ $arr = [];
$diffs = array_diff_key( $this->mImages, $existing );
foreach ( $diffs as $iname => $dummy ) {
- $arr[] = array(
+ $arr[] = [
'il_from' => $this->mId,
'il_from_namespace' => $this->mTitle->getNamespace(),
'il_to' => $iname
- );
+ ];
}
return $arr;
* @param array $existing
* @return array
*/
- private function getExternalInsertions( $existing = array() ) {
- $arr = array();
+ private function getExternalInsertions( $existing = [] ) {
+ $arr = [];
$diffs = array_diff_key( $this->mExternals, $existing );
foreach ( $diffs as $url => $dummy ) {
foreach ( wfMakeUrlIndexes( $url ) as $index ) {
- $arr[] = array(
+ $arr[] = [
'el_id' => $this->mDb->nextSequenceValue( 'externallinks_el_id_seq' ),
'el_from' => $this->mId,
'el_to' => $url,
'el_index' => $index,
- );
+ ];
}
}
*
* @return array
*/
- private function getCategoryInsertions( $existing = array() ) {
+ private function getCategoryInsertions( $existing = [] ) {
global $wgContLang, $wgCategoryCollation;
$diffs = array_diff_assoc( $this->mCategories, $existing );
- $arr = array();
+ $arr = [];
foreach ( $diffs as $name => $prefix ) {
$nt = Title::makeTitleSafe( NS_CATEGORY, $name );
$wgContLang->findVariantLink( $name, $nt, true );
$sortkey = Collation::singleton()->getSortKey(
$this->mTitle->getCategorySortkey( $prefix ) );
- $arr[] = array(
+ $arr[] = [
'cl_from' => $this->mId,
'cl_to' => $name,
'cl_sortkey' => $sortkey,
'cl_sortkey_prefix' => $prefix,
'cl_collation' => $wgCategoryCollation,
'cl_type' => $type,
- );
+ ];
}
return $arr;
*
* @return array
*/
- private function getInterlangInsertions( $existing = array() ) {
+ private function getInterlangInsertions( $existing = [] ) {
$diffs = array_diff_assoc( $this->mInterlangs, $existing );
- $arr = array();
+ $arr = [];
foreach ( $diffs as $lang => $title ) {
- $arr[] = array(
+ $arr[] = [
'll_from' => $this->mId,
'll_lang' => $lang,
'll_title' => $title
- );
+ ];
}
return $arr;
* @param array $existing
* @return array
*/
- function getPropertyInsertions( $existing = array() ) {
+ function getPropertyInsertions( $existing = [] ) {
$diffs = array_diff_assoc( $this->mProperties, $existing );
- $arr = array();
+ $arr = [];
foreach ( array_keys( $diffs ) as $name ) {
$arr[] = $this->getPagePropRowData( $name );
}
$value = $this->mProperties[$prop];
- $row = array(
+ $row = [
'pp_page' => $this->mId,
'pp_propname' => $prop,
'pp_value' => $value,
- );
+ ];
if ( $wgPagePropsHaveSortkey ) {
$row['pp_sortkey'] = $this->getPropertySortKeyValue( $value );
* @param array $existing
* @return array
*/
- private function getInterwikiInsertions( $existing = array() ) {
- $arr = array();
+ private function getInterwikiInsertions( $existing = [] ) {
+ $arr = [];
foreach ( $this->mInterwikis as $prefix => $dbkeys ) {
$diffs = isset( $existing[$prefix] )
? array_diff_key( $dbkeys, $existing[$prefix] )
: $dbkeys;
foreach ( $diffs as $dbk => $id ) {
- $arr[] = array(
+ $arr[] = [
'iwl_from' => $this->mId,
'iwl_prefix' => $prefix,
'iwl_title' => $dbk
- );
+ ];
}
}
* @return array
*/
private function getLinkDeletions( $existing ) {
- $del = array();
+ $del = [];
foreach ( $existing as $ns => $dbkeys ) {
if ( isset( $this->mLinks[$ns] ) ) {
$del[$ns] = array_diff_key( $existing[$ns], $this->mLinks[$ns] );
* @return array
*/
private function getTemplateDeletions( $existing ) {
- $del = array();
+ $del = [];
foreach ( $existing as $ns => $dbkeys ) {
if ( isset( $this->mTemplates[$ns] ) ) {
$del[$ns] = array_diff_key( $existing[$ns], $this->mTemplates[$ns] );
* @return array
*/
private function getInterwikiDeletions( $existing ) {
- $del = array();
+ $del = [];
foreach ( $existing as $prefix => $dbkeys ) {
if ( isset( $this->mInterwikis[$prefix] ) ) {
$del[$prefix] = array_diff_key( $existing[$prefix], $this->mInterwikis[$prefix] );
* @return array
*/
private function getExistingLinks() {
- $res = $this->mDb->select( 'pagelinks', array( 'pl_namespace', 'pl_title' ),
- array( 'pl_from' => $this->mId ), __METHOD__, $this->mOptions );
- $arr = array();
+ $res = $this->mDb->select( 'pagelinks', [ 'pl_namespace', 'pl_title' ],
+ [ 'pl_from' => $this->mId ], __METHOD__, $this->mOptions );
+ $arr = [];
foreach ( $res as $row ) {
if ( !isset( $arr[$row->pl_namespace] ) ) {
- $arr[$row->pl_namespace] = array();
+ $arr[$row->pl_namespace] = [];
}
$arr[$row->pl_namespace][$row->pl_title] = 1;
}
* @return array
*/
private function getExistingTemplates() {
- $res = $this->mDb->select( 'templatelinks', array( 'tl_namespace', 'tl_title' ),
- array( 'tl_from' => $this->mId ), __METHOD__, $this->mOptions );
- $arr = array();
+ $res = $this->mDb->select( 'templatelinks', [ 'tl_namespace', 'tl_title' ],
+ [ 'tl_from' => $this->mId ], __METHOD__, $this->mOptions );
+ $arr = [];
foreach ( $res as $row ) {
if ( !isset( $arr[$row->tl_namespace] ) ) {
- $arr[$row->tl_namespace] = array();
+ $arr[$row->tl_namespace] = [];
}
$arr[$row->tl_namespace][$row->tl_title] = 1;
}
* @return array
*/
private function getExistingImages() {
- $res = $this->mDb->select( 'imagelinks', array( 'il_to' ),
- array( 'il_from' => $this->mId ), __METHOD__, $this->mOptions );
- $arr = array();
+ $res = $this->mDb->select( 'imagelinks', [ 'il_to' ],
+ [ 'il_from' => $this->mId ], __METHOD__, $this->mOptions );
+ $arr = [];
foreach ( $res as $row ) {
$arr[$row->il_to] = 1;
}
* @return array
*/
private function getExistingExternals() {
- $res = $this->mDb->select( 'externallinks', array( 'el_to' ),
- array( 'el_from' => $this->mId ), __METHOD__, $this->mOptions );
- $arr = array();
+ $res = $this->mDb->select( 'externallinks', [ 'el_to' ],
+ [ 'el_from' => $this->mId ], __METHOD__, $this->mOptions );
+ $arr = [];
foreach ( $res as $row ) {
$arr[$row->el_to] = 1;
}
* @return array
*/
private function getExistingCategories() {
- $res = $this->mDb->select( 'categorylinks', array( 'cl_to', 'cl_sortkey_prefix' ),
- array( 'cl_from' => $this->mId ), __METHOD__, $this->mOptions );
- $arr = array();
+ $res = $this->mDb->select( 'categorylinks', [ 'cl_to', 'cl_sortkey_prefix' ],
+ [ 'cl_from' => $this->mId ], __METHOD__, $this->mOptions );
+ $arr = [];
foreach ( $res as $row ) {
$arr[$row->cl_to] = $row->cl_sortkey_prefix;
}
* @return array
*/
private function getExistingInterlangs() {
- $res = $this->mDb->select( 'langlinks', array( 'll_lang', 'll_title' ),
- array( 'll_from' => $this->mId ), __METHOD__, $this->mOptions );
- $arr = array();
+ $res = $this->mDb->select( 'langlinks', [ 'll_lang', 'll_title' ],
+ [ 'll_from' => $this->mId ], __METHOD__, $this->mOptions );
+ $arr = [];
foreach ( $res as $row ) {
$arr[$row->ll_lang] = $row->ll_title;
}
* @return array (prefix => array(dbkey => 1))
*/
protected function getExistingInterwikis() {
- $res = $this->mDb->select( 'iwlinks', array( 'iwl_prefix', 'iwl_title' ),
- array( 'iwl_from' => $this->mId ), __METHOD__, $this->mOptions );
- $arr = array();
+ $res = $this->mDb->select( 'iwlinks', [ 'iwl_prefix', 'iwl_title' ],
+ [ 'iwl_from' => $this->mId ], __METHOD__, $this->mOptions );
+ $arr = [];
foreach ( $res as $row ) {
if ( !isset( $arr[$row->iwl_prefix] ) ) {
- $arr[$row->iwl_prefix] = array();
+ $arr[$row->iwl_prefix] = [];
}
$arr[$row->iwl_prefix][$row->iwl_title] = 1;
}
* @return array Array of property names and values
*/
private function getExistingProperties() {
- $res = $this->mDb->select( 'page_props', array( 'pp_propname', 'pp_value' ),
- array( 'pp_page' => $this->mId ), __METHOD__, $this->mOptions );
- $arr = array();
+ $res = $this->mDb->select( 'page_props', [ 'pp_propname', 'pp_value' ],
+ [ 'pp_page' => $this->mId ], __METHOD__, $this->mOptions );
+ $arr = [];
foreach ( $res as $row ) {
$arr[$row->pp_propname] = $row->pp_value;
}
if ( isset( $wgPagePropLinkInvalidations[$name] ) ) {
$inv = $wgPagePropLinkInvalidations[$name];
if ( !is_array( $inv ) ) {
- $inv = array( $inv );
+ $inv = [ $inv ];
}
foreach ( $inv as $table ) {
DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->mTitle, $table ) );
if ( $this->linkInsertions === null ) {
return null;
}
- $result = array();
+ $result = [];
foreach ( $this->linkInsertions as $insertion ) {
$result[] = Title::makeTitle( $insertion['pl_namespace'], $insertion['pl_title'] );
}
if ( $this->linkDeletions === null ) {
return null;
}
- $result = array();
+ $result = [];
foreach ( $this->linkDeletions as $ns => $titles ) {
foreach ( $titles as $title => $unused ) {
$result[] = Title::makeTitle( $ns, $title );
// The link updates made here only reflect the freshness of the parser output
$timestamp = $this->mParserOutput->getCacheTime();
$this->mDb->update( 'page',
- array( 'page_links_updated' => $this->mDb->timestamp( $timestamp ) ),
- array( 'page_id' => $this->mId ),
+ [ 'page_links_updated' => $this->mDb->timestamp( $timestamp ) ],
+ [ 'page_id' => $this->mId ],
__METHOD__
);
}
public function getAsJobSpecification() {
if ( $this->user ) {
- $userInfo = array(
+ $userInfo = [
'userId' => $this->user->getId(),
'userName' => $this->user->getName(),
- );
+ ];
} else {
$userInfo = false;
}
$triggeringRevisionId = false;
}
- return array(
+ return [
'wiki' => $this->mDb->getWikiID(),
'job' => new JobSpecification(
'refreshLinksPrioritized',
- array(
+ [
// Reuse the parser cache if it was saved
'rootJobTimestamp' => $this->mParserOutput->getCacheTime(),
'useRecursiveLinksUpdate' => $this->mRecursive,
'triggeringUser' => $userInfo,
'triggeringRevisionId' => $triggeringRevisionId,
- ),
- array( 'removeDuplicates' => true ),
+ ],
+ [ 'removeDuplicates' => true ],
$this->getTitle()
)
- );
+ ];
}
}