* @param $dest Int
* @param $bit Int
* @param $state Bool
+ *
+ * @return bool
*/
function wfSetBit( &$dest, $bit, $state = true ) {
$temp = (bool)( $dest & $bit );
) {
$displayReturnto = null;
- # Due to bug 32276, if a user does not have read permissions,
- # $this->getTitle() will just give Special:Badtitle, which is
- # not especially useful as a returnto parameter. Use the title
+ # Due to bug 32276, if a user does not have read permissions,
+ # $this->getTitle() will just give Special:Badtitle, which is
+ # not especially useful as a returnto parameter. Use the title
# from the request instead, if there was one.
$request = $this->getRequest();
$returnto = Title::newFromURL( $request->getVal( 'title', '' ) );
* - in other words, page-independent/site-wide variables (without state).
* You will only be adding bloat to the html page and causing page caches to
* have to be purged on configuration changes.
+ * @return array
*/
protected function getJSVars() {
global $wgUseAjax, $wgEnableMWSuggest;
return $this->skinname;
}
+ /**
+ * @param $out OutputPage
+ */
function initPage( OutputPage $out ) {
wfProfileIn( __METHOD__ );
*/
abstract function outputPage( OutputPage $out = null );
+ /**
+ * @param $data
+ * @return string
+ */
static function makeVariablesScript( $data ) {
if ( $data ) {
return Html::inlineScript(
return $wgLogo;
}
+ /**
+ * @return string
+ */
function getCategoryLinks() {
global $wgUseCategoryBrowser;
return $return;
}
+ /**
+ * @return string
+ */
function getCategories() {
$out = $this->getOutput();
return '';
}
+ /**
+ * @param $debugText
+ * @return string
+ */
private function formatDebugHTML( $debugText ) {
global $wgDebugTimestamps;
return $this->msg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' )->text();
}
+ /**
+ * @return String
+ */
function getUndeleteLink() {
$action = $this->getRequest()->getVal( 'action', 'view' );
return '';
}
+ /**
+ * @return string
+ */
function subPageSubtitle() {
$out = $this->getOutput();
$subpages = '';
return $wgShowIPinHeader && session_id() != '';
}
+ /**
+ * @return String
+ */
function getSearchLink() {
$searchPage = SpecialPage::getTitleFor( 'Search' );
return $searchPage->getLocalURL();
}
+ /**
+ * @return string
+ */
function escapeSearchLink() {
return htmlspecialchars( $this->getSearchLink() );
}
+ /**
+ * @param string $type
+ * @return string
+ */
function getCopyright( $type = 'detect' ) {
global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgContLang;
}
}
+ /**
+ * @return null|string
+ */
function getCopyrightIcon() {
global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
return $s;
}
+ /**
+ * @param $align string
+ * @return string
+ */
function logoText( $align = '' ) {
if ( $align != '' ) {
$a = " align='{$align}'";
return $s;
}
+ /**
+ * @param $desc
+ * @param $page
+ * @return string
+ */
public function footerLink( $desc, $page ) {
// if the link description has been set to "-" in the default language,
if ( $this->msg( $desc )->inContentLanguage()->isDisabled() ) {
return $options;
}
+ /**
+ * @param $id
+ * @return bool
+ */
function showEmailUser( $id ) {
if ( $id instanceof User ) {
$targetUser = $id;
}
/* these are used extensively in SkinTemplate, but also some other places */
+
+ /**
+ * @param $urlaction string
+ * @return String
+ */
static function makeMainPageUrl( $urlaction = '' ) {
$title = Title::newMainPage();
self::checkTitle( $title, '' );
return $title->getLocalURL( $urlaction );
}
+ /**
+ * @param $name
+ * @param $urlaction string
+ * @return String
+ */
static function makeSpecialUrl( $name, $urlaction = '' ) {
$title = SpecialPage::getSafeTitleFor( $name );
return $title->getLocalURL( $urlaction );
}
+ /**
+ * @param $name
+ * @param $subpage
+ * @param $urlaction string
+ * @return String
+ */
static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
$title = SpecialPage::getSafeTitleFor( $name, $subpage );
return $title->getLocalURL( $urlaction );
}
+ /**
+ * @param $name
+ * @param $urlaction string
+ * @return String
+ */
static function makeI18nUrl( $name, $urlaction = '' ) {
$title = Title::newFromText( wfMsgForContent( $name ) );
self::checkTitle( $title, $name );
return $title->getLocalURL( $urlaction );
}
+ /**
+ * @param $name
+ * @param $urlaction string
+ * @return String
+ */
static function makeUrl( $name, $urlaction = '' ) {
$title = Title::newFromText( $name );
self::checkTitle( $title, $name );
}
}
- # this can be passed the NS number as defined in Language.php
+ /**
+ * this can be passed the NS number as defined in Language.php
+ * @param $name
+ * @param $urlaction string
+ * @param $namespace int
+ * @return String
+ */
static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN ) {
$title = Title::makeTitleSafe( $namespace, $name );
self::checkTitle( $title, $name );
return $title->getLocalURL( $urlaction );
}
- /* these return an array with the 'href' and boolean 'exists' */
+ /**
+ * these return an array with the 'href' and boolean 'exists'
+ * @param $name
+ * @param $urlaction string
+ * @return array
+ */
static function makeUrlDetails( $name, $urlaction = '' ) {
$title = Title::newFromText( $name );
self::checkTitle( $title, $name );
);
}
- # make sure we have some title to operate on
+ /**
+ * make sure we have some title to operate on
+ *
+ * @param $title Title
+ * @param $name
+ */
static function checkTitle( &$title, $name ) {
if ( !is_object( $title ) ) {
$title = Title::newFromText( $name );
*
* This is just a wrapper around addToSidebarPlain() for backwards compatibility
*
- * @param &$bar array
+ * @param $bar array
* @param $message String
*/
function addToSidebar( &$bar, $message ) {
/**
* Add content from plain text
* @since 1.17
- * @param &$bar array
+ * @param $bar array
* @param $text string
* @return Array
*/
if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
$href = $link;
-
+
// Parser::getExternalLinkAttribs won't work here because of the Namespace things
global $wgNoFollowLinks, $wgNoFollowDomainExceptions;
if ( $wgNoFollowLinks && !wfMatchesDomainList( $href, $wgNoFollowDomainExceptions ) ) {
$extraAttribs['rel'] = 'nofollow';
}
-
+
global $wgExternalLinkTarget;
if ( $wgExternalLinkTarget) {
$extraAttribs['target'] = $wgExternalLinkTarget;
*
* @param $ignoreErrors bool|null
*
- * @return The previous value of the flag.
+ * @return bool The previous value of the flag.
*/
function ignoreErrors( $ignoreErrors = null ) {
return wfSetBit( $this->mFlags, DBO_IGNORE, $ignoreErrors );
/**
* Free a prepared query, generated by prepare().
+ * @param $prepared
*/
function freePrepared( $prepared ) {
/* No-op by default */
* Any implementation of this function should *not* involve reusing
* sequence numbers created for rolled-back transactions.
* See http://bugs.mysql.com/bug.php?id=30767 for details.
+ * @param $seqName
+ * @return null
*/
function nextSequenceValue( $seqName ) {
return null;
*
* @param $result bool|ResultWrapper
*
- * @param bool|ResultWrapper
+ * @return bool|ResultWrapper
*/
function resultObject( $result ) {
if ( empty( $result ) ) {
* don't allow simple quoted strings to be inserted. To insert into such
* a field, pass the data through this function before passing it to
* DatabaseBase::insert().
+ * @param $b
+ * @return
*/
function encodeBlob( $b ) {
return $b;
* Some DBMSs return a special placeholder object representing blob fields
* in result objects. Pass the object through this function to return the
* original string.
+ * @param $b
+ * @return
*/
function decodeBlob( $b ) {
return $b;
* @param $resultCallback Callback: Optional function called for each MySQL result
* @param $fname String: Calling function name or false if name should be
* generated dynamically using $filename
+ * @return bool|string
*/
function sourceFile( $filename, $lineCallback = false, $resultCallback = false, $fname = false ) {
wfSuppressWarnings();
* @param $lineCallback Callback: Optional function called before reading each line
* @param $resultCallback Callback: Optional function called for each MySQL result
* @param $fname String: Calling function name
+ * @return bool|string
*/
function sourceStream( $fp, $lineCallback = false, $resultCallback = false,
$fname = 'DatabaseBase::sourceStream' )
parent::__construct( $db, $msg );
}
+ /**
+ * @return bool
+ */
function useOutputPage() {
// Not likely to work
return false;
return wfMsgReplaceArgs( $message, $args );
}
+ /**
+ * @return bool
+ */
function getLogMessage() {
# Don't send to the exception log
return false;
class DBQueryError extends DBError {
public $error, $errno, $sql, $fname;
+ /**
+ * @param $db DatabaseBase
+ * @param $error
+ * @param $errno
+ * @param $sql
+ * @param $fname
+ */
function __construct( DatabaseBase &$db, $error, $errno, $sql, $fname ) {
$message = "A database error has occurred. Did you forget to run maintenance/update.php after upgrading? See: https://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script\n" .
"Query: $sql\n" .
}
}
+ /**
+ * @return bool
+ */
function getLogMessage() {
# Don't send to the exception log
return false;
return 'mysql';
}
+ /**
+ * @param $sql
+ * @return resource
+ */
protected function doQuery( $sql ) {
if( $this->bufferResults() ) {
$ret = mysql_query( $sql, $this->mConn );
return $ret;
}
+ /**
+ * @param $server
+ * @param $user
+ * @param $password
+ * @param $dbName
+ * @return bool
+ * @throws DBConnectionError
+ */
function open( $server, $user, $password, $dbName ) {
global $wgAllDBsAreLocalhost;
wfProfileIn( __METHOD__ );
}
}
+ /**
+ * @param $res
+ * @throws DBUnexpectedError
+ */
function freeResult( $res ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
}
}
+ /**
+ * @param $res
+ * @return object|stdClass
+ * @throws DBUnexpectedError
+ */
function fetchObject( $res ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
return $row;
}
+ /**
+ * @param $res
+ * @return array
+ * @throws DBUnexpectedError
+ */
function fetchRow( $res ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
return mysql_insert_id( $this->mConn );
}
+ /**
+ * @param $res
+ * @param $row
+ * @return bool
+ */
function dataSeek( $res, $row ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
return mysql_data_seek( $res, $row );
}
+ /**
+ * @return int
+ */
function lastErrno() {
if ( $this->mConn ) {
return mysql_errno( $this->mConn );
}
}
+ /**
+ * @return string
+ */
function lastError() {
if ( $this->mConn ) {
# Even if it's non-zero, it can still be invalid
return mysql_affected_rows( $this->mConn );
}
+ /**
+ * @param $table
+ * @param $uniqueIndexes
+ * @param $rows
+ * @param $fname string
+ * @return ResultWrapper
+ */
function replace( $table, $uniqueIndexes, $rows, $fname = 'DatabaseMysql::replace' ) {
return $this->nativeReplace( $table, $rows, $fname );
}
* Returns estimated count, based on EXPLAIN output
* Takes same arguments as Database::select()
*
+ * @param $table string|array
+ * @param $vars string|array
+ * @param $conds string|array
+ * @param $fname string
+ * @param $options string|array
* @return int
*/
public function estimateRowCount( $table, $vars='*', $conds='', $fname = 'DatabaseMysql::estimateRowCount', $options = array() ) {
* Get information about an index into an object
* Returns false if the index does not exist
*
+ * @param $table
+ * @param $index
+ * @param $fname string
* @return false|array
*/
function indexInfo( $table, $index, $fname = 'DatabaseMysql::indexInfo' ) {
*
* @param $pos DBMasterPos object
* @param $timeout Integer: the maximum number of seconds to wait for synchronisation
+ * @return bool|string
*/
function masterPosWait( DBMasterPos $pos, $timeout ) {
$fname = 'DatabaseBase::masterPosWait';
return '[http://www.mysql.com/ MySQL]';
}
+ /**
+ * @return bool
+ */
function standardSelectDistinct() {
return false;
}
+ /**
+ * @param $options array
+ */
public function setSessionOptions( array $options ) {
if ( isset( $options['connTimeout'] ) ) {
$timeout = (int)$options['connTimeout'];
}
}
+ /**
+ * @param $lockName
+ * @param $method
+ * @param $timeout int
+ * @return bool
+ */
public function lock( $lockName, $method, $timeout = 5 ) {
$lockName = $this->addQuotes( $lockName );
$result = $this->query( "SELECT GET_LOCK($lockName, $timeout) AS lockstatus", $method );
/**
* FROM MYSQL DOCS: http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_release-lock
+ * @param $lockName
+ * @param $method string
+ * @return
*/
public function unlock( $lockName, $method ) {
$lockName = $this->addQuotes( $lockName );
return $row->lockstatus;
}
+ /**
+ * @param $read
+ * @param $write
+ * @param $method
+ * @param $lowPriority bool
+ */
public function lockTables( $read, $write, $method, $lowPriority = true ) {
$items = array();
$this->query( $sql, $method );
}
+ /**
+ * @param $method string
+ */
public function unlockTables( $method ) {
$this->query( "UNLOCK TABLES", $method );
}
return 'SearchMySQL';
}
+ /**
+ * @param bool $value
+ * @return mixed
+ */
public function setBigSelects( $value = true ) {
if ( $value === 'default' ) {
if ( $this->mDefaultBigSelects === null ) {
/**
* DELETE where the condition is a join. MySql uses multi-table deletes.
+ * @param $delTable
+ * @param $joinTable
+ * @param $delVar
+ * @param $joinVar
+ * @param $conds array|string
+ * @param $fname bool
+ * @return bool|\ResultWrapper
*/
function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname = 'DatabaseBase::deleteJoin' ) {
if ( !$conds ) {
( $this->lastErrno() == 1290 && strpos( $this->lastError(), '--read-only' ) !== false );
}
+ /**
+ * @param $oldName
+ * @param $newName
+ * @param $temporary bool
+ * @param $fname string
+ */
function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = 'DatabaseMysql::duplicateTableStructure' ) {
$tmp = $temporary ? 'TEMPORARY ' : '';
$newName = $this->addIdentifierQuotes( $newName );
*
* @param $prefix Only show tables with this prefix, e.g. mw_
* @param $fname String: calling function name
+ * @return array
*/
function listTables( $prefix = null, $fname = 'DatabaseMysql::listTables' ) {
$result = $this->query( "SHOW TABLES", $fname);
/**
* Get status information from SHOW STATUS in an associative array
*
+ * @param $which string
* @return array
*/
function getMysqlStatus( $which = "%" ) {
return $this->tableName;
}
+ /**
+ * @return string
+ */
function type() {
return $this->type;
}
$this->mData = $data;
}
+ /**
+ * @return bool
+ */
function isLOB() {
return false;
}
/**
* Construct a factory based on a configuration array (typically from $wgLBFactoryConf)
+ * @param $conf
*/
abstract function __construct( $conf );
* Execute a function for each tracked load balancer
* The callback is called with the load balancer as the first parameter,
* and $params passed as the subsequent parameters.
+ * @param $callback
+ * @param array $params
*/
abstract function forEachLB( $callback, $params = array() );
/**
* Call a method of each tracked load balancer
+ * @param $methodName
+ * @param $args array
*/
function forEachLBCallMethod( $methodName, $args = array() ) {
$this->forEachLB( array( $this, 'callMethod' ), array( $methodName, $args ) );
/**
* Private helper for forEachLBCallMethod
+ * @param $loadBalancer
+ * @param $methodName
+ * @param $args
*/
function callMethod( $loadBalancer, $methodName, $args ) {
call_user_func_array( array( $loadBalancer, $methodName ), $args );
* Execute a function for each tracked load balancer
* The callback is called with the load balancer as the first parameter,
* and $params passed as the subsequent parameters.
+ * @param $callback
+ * @param $params array
*/
function forEachLB( $callback, $params = array() ) {
if ( isset( $this->mainLB ) ) {
var $conf, $mainLBs = array(), $extLBs = array();
var $lastWiki, $lastSection;
+ /**
+ * @param $conf
+ */
function __construct( $conf ) {
$this->chronProt = new ChronologyProtector;
$this->conf = $conf;
/**
* Make a new load balancer object based on template and load array
*
+ * @param $template
+ * @param $loads
+ * @param $groupLoads
* @return LoadBalancer
*/
function newLoadBalancer( $template, $loads, $groupLoads ) {
/**
* Get or set arbitrary data used by the parent object, usually an LBFactory
+ * @param $x
+ * @return \Mixed
*/
function parentInfo( $x = null ) {
return wfSetVar( $this->mParentInfo, $x );
/**
* Wait for a specified number of microseconds, and return the period waited
+ * @param $t
+ * @return
*/
function sleep( $t ) {
wfProfileIn( __METHOD__ );
* Set the master wait position
* If a DB_SLAVE connection has been opened already, waits
* Otherwise sets a variable telling it to wait if such a connection is opened
+ * @param $pos
*/
public function waitFor( $pos ) {
wfProfileIn( __METHOD__ );
/**
* Set the master wait position and wait for ALL slaves to catch up to it
+ * @param $pos
*/
public function waitForAll( $pos ) {
wfProfileIn( __METHOD__ );
* Get any open connection to a given server index, local or foreign
* Returns false if there is no connection open
*
- * @return DatabaseBase
+ * @param $i
+ * @return DatabaseBase|false
*/
function getAnyOpenConnection( $i ) {
foreach ( $this->mConns as $conns ) {
* Returns a Database object whether or not the connection was successful.
* @access private
*
+ * @param $server
+ * @param $dbNameOverride bool
* @return DatabaseBase
*/
function reallyOpenConnection( $server, $dbNameOverride = false ) {
return $db;
}
+ /**
+ * @param $conn
+ * @throws DBConnectionError
+ */
function reportConnectionError( &$conn ) {
wfProfileIn( __METHOD__ );
/**
* Returns true if the specified index is a valid server index
*
+ * @param $i
* @return bool
*/
function haveIndex( $i ) {
/**
* Returns true if the specified index is valid and has non-zero load
*
+ * @param $i
* @return bool
*/
function isNonZeroLoad( $i ) {
/**
* Get the host name or IP address of the server with the specified index
* Prefer a readable name if available.
+ * @param $i
+ * @return string
*/
function getServerName( $i ) {
if ( isset( $this->mServers[$i]['hostName'] ) ) {
/**
* Return the server info structure for a given index, or false if the index is invalid.
+ * @param $i
+ * @return bool
*/
function getServerInfo( $i ) {
if ( isset( $this->mServers[$i] ) ) {
/**
* Sets the server info structure for the given index. Entry at index $i is created if it doesn't exist
+ * @param $i
+ * @param $serverInfo
*/
function setServerInfo( $i, $serverInfo ) {
$this->mServers[$i] = $serverInfo;
* Deprecated function, typo in function name
*
* @deprecated in 1.18
+ * @param $conn
*/
function closeConnecton( $conn ) {
$this->closeConnection( $conn );
return $this->mLaggedSlaveMode;
}
- /* Disables/enables lag checks */
+ /**
+ * Disables/enables lag checks
+ * @param $mode null
+ * @return bool
+ */
function allowLagged( $mode = null ) {
if ( $mode === null) {
return $this->mAllowLagged;
/**
* Call a function with each open connection object
+ * @param $callback
+ * @param array $params
*/
function forEachOpenConnection( $callback, $params = array() ) {
foreach ( $this->mConns as $conns2 ) {
function postConnectionBackoff( $conn, $threshold ) {
}
+ /**
+ * @param $serverIndexes
+ * @param $wiki
+ * @return array
+ */
function getLagTimes( $serverIndexes, $wiki ) {
return array_fill_keys( $serverIndexes, 0 );
}
}
-
/**
* Basic MySQL load monitor with no external dependencies
* Uses memcached to cache the replication lag for a short time