class LinksUpdate extends SqlDataUpdate {
// @todo make members protected, but make sure extensions don't break
- public $mId, //!< Page ID of the article linked from
- $mTitle, //!< Title object of the article linked from
- $mParserOutput, //!< Parser output
- $mLinks, //!< Map of title strings to IDs for the links in the document
- $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
- $mInterlangs, //!< Map of language codes to titles
- $mProperties, //!< Map of arbitrary name to value
- $mDb, //!< Database connection reference
- $mOptions, //!< SELECT options to be used (array)
- $mRecursive; //!< Whether to queue jobs for recursive updates
+ /** @var int Page ID of the article linked from */
+ public $mId;
+
+ /** @var Title object of the article linked from */
+ public $mTitle;
+
+ /** @var ParserOutput */
+ public $mParserOutput;
+
+ /** @var array Map of title strings to IDs for the links in the document */
+ public $mLinks;
+
+ /** @var array DB keys of the images used, in the array key only */
+ public $mImages;
+
+ /** @var array Map of title strings to IDs for the template references, including broken ones */
+ public $mTemplates;
+
+ /** @var array URLs of external links, array key only */
+ public $mExternals;
+
+ /** @var array Map of category names to sort keys */
+ public $mCategories;
+
+ /** @var array ap of language codes to titles */
+ public $mInterlangs;
+
+ /** @var array Map of arbitrary name to value */
+ public $mProperties;
+
+ /** @var DatabaseBase Database connection reference */
+ public $mDb;
+
+ /** @var array SELECT options to be used */
+ public $mOptions;
+
+ /** @var bool Whether to queue jobs for recursive updates */
+ public $mRecursive;
/**
* @var null|array Added links if calculated.
/**
* Constructor
*
- * @param $title Title of the page we're updating
- * @param $parserOutput ParserOutput: output from a full parse of this page
- * @param $recursive Boolean: queue jobs for recursive updates?
+ * @param Title $title Title of the page we're updating
+ * @param ParserOutput $parserOutput Output from a full parse of this page
+ * @param bool $recursive Queue jobs for recursive updates?
* @throws MWException
*/
function __construct( $title, $parserOutput, $recursive = true ) {
$this->mId = $title->getArticleID();
if ( !$this->mId ) {
- throw new MWException( "The Title object did not provide an article ID. Perhaps the page doesn't exist?" );
+ throw new MWException( "The Title object did not provide an article " .
+ "ID. Perhaps the page doesn't exist?" );
}
$this->mParserOutput = $parserOutput;
* Queue a RefreshLinks job for any table.
*
* @param Title $title Title to do job for
- * @param String $table Table to use (e.g. 'templatelinks')
+ * @param string $table Table to use (e.g. 'templatelinks')
*/
public static function queueRecursiveJobsForTable( Title $title, $table ) {
wfProfileIn( __METHOD__ );
/**
* Update all the appropriate counts in the category table.
- * @param array $added associative array of category name => sort key
- * @param array $deleted associative array of category name => sort key
+ * @param array $added Associative array of category name => sort key
+ * @param array $deleted Associative array of category name => sort key
*/
function updateCategoryCounts( $added, $deleted ) {
$a = WikiPage::factory( $this->mTitle );
/**
* Update a table by doing a delete query then an insert query
- * @param $table
- * @param $prefix
- * @param $deletions
- * @param $insertions
+ * @param string $table Table name
+ * @param string $prefix Field name prefix
+ * @param array $deletions
+ * @param array $insertions Rows to insert
*/
function incrTableUpdate( $table, $prefix, $deletions, $insertions ) {
if ( $table == 'page_props' ) {
/**
* Get an array of pagelinks insertions for passing to the DB
* Skips the titles specified by the 2-D array $existing
- * @param $existing array
+ * @param array $existing
* @return array
*/
private function getLinkInsertions( $existing = array() ) {
/**
* Get an array of template insertions. Like getLinkInsertions()
- * @param $existing array
+ * @param array $existing
* @return array
*/
private function getTemplateInsertions( $existing = array() ) {
/**
* Get an array of image insertions
* Skips the names specified in $existing
- * @param $existing array
+ * @param array $existing
* @return array
*/
private function getImageInsertions( $existing = array() ) {
/**
* Get an array of externallinks insertions. Skips the names specified in $existing
- * @param $existing array
+ * @param array $existing
* @return array
*/
private function getExternalInsertions( $existing = array() ) {
/**
* Get an array of page property insertions
- * @param $existing array
+ * @param array $existing
* @return array
*/
function getPropertyInsertions( $existing = array() ) {
/**
* Get an array of interwiki insertions for passing to the DB
* Skips the titles specified by the 2-D array $existing
- * @param $existing array
+ * @param array $existing
* @return array
*/
private function getInterwikiInsertions( $existing = array() ) {
$arr = array();
foreach ( $this->mInterwikis as $prefix => $dbkeys ) {
- $diffs = isset( $existing[$prefix] ) ? array_diff_key( $dbkeys, $existing[$prefix] ) : $dbkeys;
+ $diffs = isset( $existing[$prefix] )
+ ? array_diff_key( $dbkeys, $existing[$prefix] )
+ : $dbkeys;
+
foreach ( $diffs as $dbk => $id ) {
$arr[] = array(
'iwl_from' => $this->mId,
/**
* Given an array of existing links, returns those links which are not in $this
* and thus should be deleted.
- * @param $existing array
+ * @param array $existing
* @return array
*/
private function getLinkDeletions( $existing ) {
/**
* Given an array of existing templates, returns those templates which are not in $this
* and thus should be deleted.
- * @param $existing array
+ * @param array $existing
* @return array
*/
private function getTemplateDeletions( $existing ) {
/**
* Given an array of existing images, returns those images which are not in $this
* and thus should be deleted.
- * @param $existing array
+ * @param array $existing
* @return array
*/
private function getImageDeletions( $existing ) {
/**
* Given an array of existing external links, returns those links which are not
* in $this and thus should be deleted.
- * @param $existing array
+ * @param array $existing
* @return array
*/
private function getExternalDeletions( $existing ) {
/**
* Given an array of existing categories, returns those categories which are not in $this
* and thus should be deleted.
- * @param $existing array
+ * @param array $existing
* @return array
*/
private function getCategoryDeletions( $existing ) {
/**
* Given an array of existing interlanguage links, returns those links which are not
* in $this and thus should be deleted.
- * @param $existing array
+ * @param array $existing
* @return array
*/
private function getInterlangDeletions( $existing ) {
/**
* Get array of properties which should be deleted.
- * @param $existing array
+ * @param array $existing
* @return array
*/
function getPropertyDeletions( $existing ) {
/**
* Given an array of existing interwiki links, returns those links which are not in $this
* and thus should be deleted.
- * @param $existing array
+ * @param array $existing
* @return array
*/
private function getInterwikiDeletions( $existing ) {
/**
* Get an array of existing categories, with the name in the key and sort key in the value.
*
- * @return array
+ * @return array of property names and values
*/
private function getExistingProperties() {
$res = $this->mDb->select( 'page_props', array( 'pp_propname', 'pp_value' ),
/**
* Invalidate any necessary link lists related to page property changes
- * @param $changed
+ * @param array $changed
*/
private function invalidateProperties( $changed ) {
global $wgPagePropLinkInvalidations;
* Update object handling the cleanup of links tables after a page was deleted.
**/
class LinksDeletionUpdate extends SqlDataUpdate {
- protected $mPage; //!< WikiPage the wikipage that was deleted
+ /** @var WikiPage The WikiPage that was deleted */
+ protected $mPage;
/**
* Constructor
*
- * @param $page WikiPage Page we are updating
+ * @param WikiPage $page Page we are updating
* @throws MWException
*/
function __construct( WikiPage $page ) {
/**
* Update all the appropriate counts in the category table.
- * @param array $added associative array of category name => sort key
- * @param array $deleted associative array of category name => sort key
+ * @param array $added Associative array of category name => sort key
+ * @param array $deleted Associative array of category name => sort key
*/
function updateCategoryCounts( $added, $deleted ) {
$a = WikiPage::factory( $this->mTitle );
* Class for handling updates to the site_stats table
*/
class SiteStatsUpdate implements DeferrableUpdate {
+ /** @var int */
protected $views = 0;
+
+ /** @var int */
protected $edits = 0;
+
+ /** @var int */
protected $pages = 0;
+
+ /** @var int */
protected $articles = 0;
+
+ /** @var int */
protected $users = 0;
+
+ /** @var int */
protected $images = 0;
// @todo deprecate this constructor
}
/**
- * @param $deltas Array
+ * @param array $deltas
* @return SiteStatsUpdate
*/
public static function factory( array $deltas ) {
/**
* Do not call this outside of SiteStatsUpdate
- *
- * @return void
*/
public function tryDBUpdateInternal() {
global $wgSiteStatsAsyncFactor;
$dbw = wfGetDB( DB_MASTER );
$lockKey = wfMemcKey( 'site_stats' ); // prepend wiki ID
+ $pd = array();
if ( $wgSiteStatsAsyncFactor ) {
// Lock the table so we don't have double DB/memcached updates
if ( !$dbw->lockIsFree( $lockKey, __METHOD__ )
}
/**
- * @param $dbw DatabaseBase
+ * @param DatabaseBase $dbw
* @return bool|mixed
*/
public static function cacheUpdate( $dbw ) {
'rc_user != 0',
'rc_bot' => 0,
'rc_log_type != ' . $dbr->addQuotes( 'newusers' ) . ' OR rc_log_type IS NULL',
- 'rc_timestamp >= ' . $dbr->addQuotes( $dbr->timestamp( wfTimestamp( TS_UNIX ) - $wgActiveUserDays * 24 * 3600 ) ),
+ 'rc_timestamp >= ' . $dbr->addQuotes( $dbr->timestamp( wfTimestamp( TS_UNIX )
+ - $wgActiveUserDays * 24 * 3600 ) ),
),
__METHOD__
);
}
/**
- * @param $sql string
- * @param $field string
- * @param $delta integer
+ * @param string $sql
+ * @param string $field
+ * @param int $delta
*/
protected function appendUpdate( &$sql, $field, $delta ) {
if ( $delta ) {
}
/**
- * @param $type string
+ * @param string $type
* @param string $sign ('+' or '-')
* @return string
*/
/**
* Adjust the pending deltas for a stat type.
* Each stat type has two pending counters, one for increments and decrements
- * @param $type string
- * @param $delta integer Delta (positive or negative)
- * @return void
+ * @param string $type
+ * @param int $delta Delta (positive or negative)
*/
protected function adjustPending( $type, $delta ) {
global $wgMemc;
/**
* Get pending delta counters for each stat type
- * @return Array Positive and negative deltas for each type
- * @return void
+ * @return array Positive and negative deltas for each type
*/
protected function getPendingDeltas() {
global $wgMemc;
/**
* Reduce pending delta counters after updates have been applied
* @param array $pd Result of getPendingDeltas(), used for DB update
- * @return void
*/
protected function removePendingDeltas( array $pd ) {
global $wgMemc;
* the beginTransaction() and commitTransaction() methods.
*/
abstract class SqlDataUpdate extends DataUpdate {
- protected $mDb; //!< Database connection reference
- protected $mOptions; //!< SELECT options to be used (array)
+ /** @var DatabaseBase Database connection reference */
+ protected $mDb;
- private $mHasTransaction; //!< bool whether a transaction is open on this object (internal use only!)
- protected $mUseTransaction; //!< bool whether this update should be wrapped in a transaction
+ /** @var array SELECT options to be used (array) */
+ protected $mOptions;
+
+ /** @var bool Whether a transaction is open on this object (internal use only!) */
+ private $mHasTransaction;
+
+ /** @var bool Whether this update should be wrapped in a transaction */
+ protected $mUseTransaction;
/**
* Constructor
*
- * @param bool $withTransaction whether this update should be wrapped in a transaction (default: true).
- * A transaction is only started if no transaction is already in progress,
- * see beginTransaction() for details.
- **/
+ * @param bool $withTransaction whether this update should be wrapped in a
+ * transaction (default: true). A transaction is only started if no
+ * transaction is already in progress, see beginTransaction() for details.
+ */
public function __construct( $withTransaction = true ) {
global $wgAntiLockFlags;
$this->mOptions = array( 'FOR UPDATE' );
}
- // @todo get connection only when it's needed? make sure that doesn't break anything, especially transactions!
+ // @todo Get connection only when it's needed? Make sure that doesn't
+ // break anything, especially transactions!
$this->mDb = wfGetDB( DB_MASTER );
$this->mWithTransaction = $withTransaction;
}
/**
- * Begin a database transaction, if $withTransaction was given as true in the constructor for this SqlDataUpdate.
+ * Begin a database transaction, if $withTransaction was given as true in
+ * the constructor for this SqlDataUpdate.
*
- * Because nested transactions are not supported by the Database class, this implementation
- * checks Database::trxLevel() and only opens a transaction if none is already active.
+ * Because nested transactions are not supported by the Database class,
+ * this implementation checks Database::trxLevel() and only opens a
+ * transaction if none is already active.
*/
public function beginTransaction() {
if ( !$this->mWithTransaction ) {
* Invalidate the cache of a list of pages from a single namespace.
* This is intended for use by subclasses.
*
- * @param $namespace Integer
- * @param $dbkeys Array
+ * @param int $namespace Namespace number
+ * @param array $dbkeys
*/
protected function invalidatePages( $namespace, array $dbkeys ) {
if ( $dbkeys === array() ) {