/**
* Get the groups for the given user based on $wgAutopromote.
*
- * @param $user The user to get the groups for
+ * @param $user User The user to get the groups for
* @return array Array of groups to promote to.
*/
public static function getAutopromoteGroups( User $user ) {
/**
* Take a modulo of a signed integer as if it were an unsigned integer.
* $b must be less than 0x40000000 and greater than 0
+ * @return int
*/
public static function unsignedMod( $a, $b ) {
if ( $a & 0x80000000 ) {
return $a % $b;
}
}
-
+
/**
* Shift a signed integer right as if it were unsigned
+ * @param $a
+ * @param $b
+ * @return int
*/
public static function unsignedShiftRight( $a, $b ) {
if ( $b == 0 ) {
/**
* The CDB hash function.
+ *
+ * @param $s
+ * @return
*/
public static function hash( $s ) {
$h = 5381;
}
function close() {
- if( isset($this->handle) )
+ if( isset( $this->handle ) ) {
fclose( $this->handle );
+ }
unset( $this->handle );
}
}
}
+ /**
+ * @param $key
+ * @param $pos
+ * @return bool
+ */
protected function match( $key, $pos ) {
$buf = $this->read( strlen( $key ), $pos );
return $buf === $key;
$this->loop = 0;
}
+ /**
+ * @throws MWException
+ * @param $length
+ * @param $pos
+ * @return string
+ */
protected function read( $length, $pos ) {
if ( fseek( $this->handle, $pos ) == -1 ) {
// This can easily happen if the internal pointers are incorrect
/**
* Unpack an unsigned integer and throw an exception if it needs more than 31 bits
+ * @param $s
+ * @return
*/
protected function unpack31( $s ) {
$data = unpack( 'V', $s );
/**
* Unpack a 32-bit signed integer
+ * @param $s
+ * @return int
*/
protected function unpackSigned( $s ) {
$data = unpack( 'va/vb', $s );
return $data['a'] | ( $data['b'] << 16 );
}
+ /**
+ * @param $key
+ * @return bool
+ */
protected function findNext( $key ) {
if ( !$this->loop ) {
$u = CdbFunctions::hash( $key );
return false;
}
+ /**
+ * @param $key
+ * @return bool
+ */
protected function find( $key ) {
$this->findStart();
return $this->findNext( $key );
}
}
+ /**
+ * @param $key
+ * @param $value
+ * @return
+ */
public function set( $key, $value ) {
if ( strval( $key ) === '' ) {
// DBA cross-check hack
$this->addend( strlen( $key ), strlen( $value ), CdbFunctions::hash( $key ) );
}
+ /**
+ * @throws MWException
+ */
public function close() {
$this->finish();
- if( isset($this->handle) )
+ if( isset($this->handle) ) {
fclose( $this->handle );
+ }
if ( wfIsWindows() && file_exists($this->realFileName) ) {
unlink( $this->realFileName );
}
unset( $this->handle );
}
+ /**
+ * @throws MWException
+ * @param $buf
+ */
protected function write( $buf ) {
$len = fwrite( $this->handle, $buf );
if ( $len !== strlen( $buf ) ) {
}
}
+ /**
+ * @throws MWException
+ * @param $len
+ */
protected function posplus( $len ) {
$newpos = $this->pos + $len;
if ( $newpos > 0x7fffffff ) {
$this->posplus( $datalen );
}
+ /**
+ * @throws MWException
+ * @param $keylen
+ * @param $datalen
+ */
protected function addbegin( $keylen, $datalen ) {
if ( $keylen > 0x7fffffff ) {
throw new MWException( __METHOD__.': key length too long' );
* You must call setLocation() on the stub object before storing it to the
* database
*
+ * @param $text string
+ *
* @return String: the key for getItem()
*/
function addItem( $text );
/**
* Get item by key, or false if the key is not present
*
+ * @param $key string
+ *
* @return String or false
*/
function getItem( $key );
* be other revisions in the same object.
*
* Default text is not required for two-part external storage URLs.
+ *
+ * @param $text string
*/
function setText( $text );
}
}
+ /**
+ * @param $text string
+ * @return string
+ */
public function addItem( $text ) {
$this->uncompress();
$hash = md5( $text );
return $hash;
}
+ /**
+ * @param $hash string
+ * @return array|bool
+ */
public function getItem( $hash ) {
$this->uncompress();
if ( array_key_exists( $hash, $this->mItems ) ) {
}
}
+ /**
+ * @param $text string
+ * @return void
+ */
public function setText( $text ) {
$this->uncompress();
$this->mDefaultHash = $this->addItem( $text );
}
+ /**
+ * @return array|bool
+ */
public function getText() {
$this->uncompress();
return $this->getItem( $this->mDefaultHash );
/**
* Remove an item
+ *
+ * @param $hash string
*/
public function removeItem( $hash ) {
$this->mSize -= strlen( $this->mItems[$hash] );
}
}
-
+ /**
+ * @return array
+ */
function __sleep() {
$this->compress();
return array( 'mVersion', 'mCompressed', 'mItems', 'mDefaultHash' );
/**
* Helper function for compression jobs
* Returns true until the object is "full" and ready to be committed
+ *
+ * @return bool
*/
public function isHappy() {
return $this->mSize < $this->mMaxSize
}
-
-
/**
* Pointer object for an item within a CGZ blob stored in the text table.
*/
return $this->mRef;
}
+ /**
+ * @return string
+ */
function getText() {
$fname = 'HistoryBlobStub::getText';
if( in_array( 'external', $flags ) ) {
$url=$row->old_text;
@list( /* $proto */ ,$path)=explode('://',$url,2);
- if ($path=="") {
+ if ( $path == "" ) {
wfProfileOut( $fname );
return false;
}
- $row->old_text=ExternalStore::fetchFromUrl($url);
+ $row->old_text = ExternalStore::fetchFromUrl($url);
}
if( !in_array( 'object', $flags ) ) {
/**
* Get the content hash
+ *
+ * @return string
*/
function getHash() {
return $this->mHash;
$this->mCurId = $id;
}
+ /**
+ * @return string|false
+ */
function getText() {
$dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow( 'cur', array( 'cur_text' ), array( 'cur_id' => $this->mCurId ) );
}
}
+ /**
+ * @throws MWException
+ * @param $text string
+ * @return int
+ */
function addItem( $text ) {
if ( $this->mFrozen ) {
throw new MWException( __METHOD__.": Cannot add more items after sleep/wakeup" );
return count( $this->mItems ) - 1;
}
+ /**
+ * @param $key string
+ * @return string
+ */
function getItem( $key ) {
return $this->mItems[$key];
}
+ /**
+ * @param $text string
+ */
function setText( $text ) {
$this->mDefaultKey = $this->addItem( $text );
}
+ /**
+ * @return string
+ */
function getText() {
return $this->getItem( $this->mDefaultKey );
}
+ /**
+ * @throws MWException
+ */
function compress() {
if ( !function_exists( 'xdiff_string_rabdiff' ) ){
throw new MWException( "Need xdiff 1.5+ support to write DiffHistoryBlob\n" );
* i.e. articles where the image may occur inline.
*
* @param $name string the image name to check
- * @param $contextTitle Title: the page on which the image occurs, if known
+ * @param $contextTitle Title the page on which the image occurs, if known
* @return bool
*/
function wfIsBadImage( $name, $contextTitle = false ) {
/**
* Standard output handler for use with ob_start
- *
+ *
+ * @param $s string
+ *
* @return string
*/
function wfOutputHandler( $s ) {
* @file
*/
-/** */
+/**
+ * @param $fname string
+ * @param $headers array
+ */
function wfStreamFile( $fname, $headers = array() ) {
$stat = @stat( $fname );
if ( !$stat ) {
/**
* Check if connection to zhdaemon is successful
+ *
+ * @return bool
*/
function isconnected() {
return $this->mConnected;
* Establish conncetion
*
* @access private
+ *
+ * @return bool
*/
function connect() {
wfSuppressWarnings();
class FileRepoStatus extends Status {
/**
* Factory function for fatal errors
+ *
+ * @param $repo FileRepo
+ *
+ * @return FileRepoStatus
*/
static function newFatal( $repo /*, parameters...*/ ) {
$params = array_slice( func_get_args(), 1 );
return $result;
}
+ /**
+ * @param $repo FileRepo
+ * @param $value
+ * @return FileRepoStatus
+ */
static function newGood( $repo = false, $value = null ) {
$result = new self( $repo );
$result->value = $value;
*
* @see http://www.iptc.org/std/IIM/4.1/specification/IIMV4.1.pdf
*
- * @param String $data app13 block from jpeg containing iptc/iim data
+ * @param $rawData String app13 block from jpeg containing iptc/iim data
* @return Array iptc metadata array
*/
static function parse( $rawData ) {
/**
* Conversion to PNG for inline display can be disabled here...
* Note scaling should work with ImageMagick, but may not with GD scaling.
+ *
+ * @return bool
*/
function canRender( $file ) {
global $wgTiffThumbnailType;
/**
* Browsers don't support TIFF inline generally...
* For inline display, we need to convert to PNG.
+ *
+ * @return bool
*/
function mustRender( $file ) {
return true;
}
+ /**
+ * @param $ext
+ * @param $mime
+ * @param null $params
+ * @return bool
+ */
function getThumbType( $ext, $mime, $params = null ) {
global $wgTiffThumbnailType;
return $wgTiffThumbnailType;
}
- function getMetadata( $image, $filename ) {
- global $wgShowEXIF;
- if ( $wgShowEXIF && file_exists( $filename ) ) {
- $exif = new Exif( $filename );
- $data = $exif->getFilteredData();
- if ( $data ) {
- $data['MEDIAWIKI_EXIF_VERSION'] = Exif::version();
- return serialize( $data );
- } else {
- return JpegOrTiffHandler::BROKEN_FILE;
- }
- } else {
- return '';
- }
- }
+ /**
+ * @param $image
+ * @param $filename
+ * @return string
+ */
+ function getMetadata( $image, $filename ) {
+ global $wgShowEXIF;
+ if ( $wgShowEXIF && file_exists( $filename ) ) {
+ $exif = new Exif( $filename );
+ $data = $exif->getFilteredData();
+ if ( $data ) {
+ $data['MEDIAWIKI_EXIF_VERSION'] = Exif::version();
+ return serialize( $data );
+ } else {
+ return JpegOrTiffHandler::BROKEN_FILE;
+ }
+ } else {
+ return '';
+ }
+ }
}
* - caches: This should have a numbered array of cache parameter
* structures, in the style required by $wgObjectCaches. See
* the documentation of $wgObjectCaches for more detail.
+ *
+ * @param $params array
*/
public function __construct( $params ) {
if ( !isset( $params['caches'] ) ) {
/**
* Get a cached instance of the specified type of cache object.
+ *
+ * @param $id
+ *
+ * @return object
*/
static function getInstance( $id ) {
if ( isset( self::$instances[$id] ) ) {
/**
* Create a new cache object from parameters
+ *
+ * @param $params array
*/
static function newFromParams( $params ) {
if ( isset( $params['factory'] ) ) {
* Factory function that creates a memcached client object.
* The idea of this is that it might eventually detect and automatically
* support the PECL extension, assuming someone can get it to compile.
+ *
+ * @param $params array
+ *
+ * @return MemcachedPhpBagOStuff
*/
static function newMemcached( $params ) {
return new MemcachedPhpBagOStuff( $params );
var $mFirstCall = true;
# Initialised by initialiseVariables()
+
+ /**
+ * @var MagicWordArray
+ */
var $mVariables;
/**
var $mRevisionUser; # Userto display in {{REVISIONUSER}} tag
var $mRevIdForTs; # The revision ID which was used to fetch the timestamp
+ /**
+ * @var string
+ */
+ var $mUniqPrefix;
+
/**
* Constructor
*/
/**
* Get a random string
+ *
+ * @return string
*/
static public function getRandomString() {
return dechex( mt_rand( 0, 0x7fffffff ) ) . dechex( mt_rand( 0, 0x7fffffff ) );
/**
* Set the context title
+ *
+ * @param $t Title
*/
function setTitle( $t ) {
if ( !$t || $t instanceof FakeTitle ) {
return wfSetVar( $this->mOptions, $x );
}
+ /**
+ * @return int
+ */
function nextLinkID() {
return $this->mLinkID++;
}
+ /**
+ * @param $id int
+ */
function setLinkID( $id ) {
$this->mLinkID = $id;
}
* array( 'param' => 'x' ),
* '<element param="x">tag content</element>' ) )
*
- * @param $elements list of element names. Comments are always extracted.
- * @param $text Source text string.
- * @param $matches Out parameter, Array: extracted tags
- * @param $uniq_prefix
+ * @param $elements array list of element names. Comments are always extracted.
+ * @param $text string Source text string.
+ * @param $matches array Out parameter, Array: extracted tags
+ * @param $uniq_prefix string
* @return String: stripped text
*/
public static function extractTagsAndParams( $elements, $text, &$matches, $uniq_prefix = '' ) {
/**
* Get a list of strippable XML-like elements
+ *
+ * @return array
*/
function getStripList() {
return $this->mStripList;
* is repeated twice.
*
* @private
+ * @param $cell
+ * @param $tagName
+ * @return array
*/
function getCellAttr ( $cell, $tagName ) {
$attributes = null;
return $text;
}
+ /**
+ * @throws MWException
+ * @param $m array
+ * @return HTML|string
+ */
function magicLinkCallback( $m ) {
if ( isset( $m[1] ) && $m[1] !== '' ) {
# Skip anchor
/**
* Create a new custom frame for programmatic use of parameter replacement as used in some extensions
*
+ * @param $args array
+ *
* @return PPFrame
*/
function newCustomFrame( $args );
/**
* Create a child frame
+ *
+ * @return PPFrame
*/
function newChild( $args = false, $title = false );
* Cache page existence for performance
*
* @param $db DatabaseBase
+ * @param $res ResultWrapper
*/
function preprocessResults( $db, $res ) {
$batch = new LinkBatch;