* Serialization handler, diasallows to serialize the database to prevent
* failures after this class is deserialized from cache with dead DB
* connection.
+ *
+ * @return array
*/
function __sleep() {
return array( 'partitionCache', 'fullResultCache', 'title' );
var $targets = array(); # Array of DBKEY category names
var $name2id = array();
var $mode; # "AND" or "OR"
+
+ /**
+ * @var DatabaseBase
+ */
var $dbr; # Read-DB slave
/**
return $ret;
}
+ /**
+ * @param $domain
+ * @return bool
+ */
protected function canServeDomain( $domain ) {
if ( $domain == $this->domain
|| ( strlen( $domain ) > strlen( $this->domain )
return false;
}
+ /**
+ * @param $path
+ * @return bool
+ */
protected function canServePath( $path ) {
- if ( $this->path && substr_compare( $this->path, $path, 0, strlen( $this->path ) ) == 0 ) {
- return true;
- }
-
- return false;
+ return ( $this->path && substr_compare( $this->path, $path, 0, strlen( $this->path ) ) == 0 );
}
+ /**
+ * @return bool
+ */
protected function isUnExpired() {
- if ( $this->isSessionKey || $this->expires > time() ) {
- return true;
- }
-
- return false;
+ return $this->isSessionKey || $this->expires > time();
}
}
function internalAttemptSave( &$result, $bot = false ) {
global $wgFilterCallback, $wgUser, $wgRequest, $wgParser;
global $wgMaxArticleSize;
-
+
$status = Status::newGood();
wfProfileIn( __METHOD__ );
$status->setResult( false, $code );
wfProfileOut( __METHOD__ . '-checks' );
-
wfProfileOut( __METHOD__ );
return $status;
wfProfileOut( __METHOD__ );
return $status;
}
+
if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) {
# Check block state against master, thus 'false'.
$status->setResult( false, self::AS_BLOCKED_PAGE_FOR_USER );
wfProfileOut( __METHOD__ );
return $status;
}
+
$this->kblength = (int)( strlen( $this->textbox1 ) / 1024 );
if ( $this->kblength > $wgMaxArticleSize ) {
// Error will be displayed by showEditForm()
* Fallback functions for PHP installed without mbstring support
*/
class Fallback {
-
+
+ /**
+ * @param $from
+ * @param $to
+ * @param $string
+ * @return string
+ */
public static function iconv( $from, $to, $string ) {
if ( substr( $to, -8 ) == '//IGNORE' ) {
$to = substr( $to, 0, strlen( $to ) - 8 );
* Larger offsets are still fairly efficient for Latin text, but
* can be up to 100x slower than native if the text is heavily
* multibyte and we have to slog through a few hundred kb.
- *
+ *
* @param $str
* @param $start
* @param $count string
$split = self::mb_substr_split_unicode( $str, intval( $start ) );
$str = substr( $str, $split );
}
-
+
if( $count !== 'end' ) {
$split = self::mb_substr_split_unicode( $str, intval( $count ) );
$str = substr( $str, 0, $split );
}
-
+
return $str;
}
-
+
+ /**
+ * @param $str
+ * @param $splitPos
+ * @return int
+ */
public static function mb_substr_split_unicode( $str, $splitPos ) {
if( $splitPos == 0 ) {
return 0;
}
-
+
$byteLen = strlen( $str );
-
+
if( $splitPos > 0 ) {
if( $splitPos > 256 ) {
// Optimize large string offsets by skipping ahead N bytes.
$charPos = 0;
$bytePos = 0;
}
-
+
while( $charPos++ < $splitPos ) {
++$bytePos;
// Move past any tail bytes
}
}
}
-
+
return $bytePos;
}
-
+
/**
* Fallback implementation of mb_strlen, hardcoded to UTF-8.
* @param string $str
public static function mb_strlen( $str, $enc = '' ) {
$counts = count_chars( $str );
$total = 0;
-
+
// Count ASCII bytes
for( $i = 0; $i < 0x80; $i++ ) {
$total += $counts[$i];
}
-
+
// Count multibyte sequence heads
for( $i = 0xc0; $i < 0xff; $i++ ) {
$total += $counts[$i];
}
return $total;
}
-
-
+
+
/**
* Fallback implementation of mb_strpos, hardcoded to UTF-8.
* @param $haystack String
*/
public static function mb_strpos( $haystack, $needle, $offset = 0, $encoding = '' ) {
$needle = preg_quote( $needle, '/' );
-
+
$ar = array();
preg_match( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset );
-
+
if( isset( $ar[0][1] ) ) {
return $ar[0][1];
} else {
return false;
}
- }
-
+ }
+
/**
* Fallback implementation of mb_strrpos, hardcoded to UTF-8.
* @param $haystack String
*/
public static function mb_strrpos( $haystack, $needle, $offset = 0, $encoding = '' ) {
$needle = preg_quote( $needle, '/' );
-
+
$ar = array();
preg_match_all( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset );
-
+
if( isset( $ar[0] ) && count( $ar[0] ) > 0 &&
isset( $ar[0][count( $ar[0] ) - 1][1] ) ) {
return $ar[0][count( $ar[0] ) - 1][1];
}
return false;
}
-
+
}
*
* @param $text String: diff's HTML output
* @return String: modified HTML
- * @private
*/
public static function applyDiffStyle( $text ) {
$styles = array(
/**
* Fork a number of worker processes.
*
- * return string
+ * @return string
*/
protected function forkWorkers( $numProcs ) {
$this->prepareEnvironment();
}
/**
- * Given a host/port string, like one might find in the host part of a URL
- * per RFC 2732, split the hostname part and the port part and return an
- * array with an element for each. If there is no port part, the array will
- * have false in place of the port. If the string was invalid in some way,
+ * Given a host/port string, like one might find in the host part of a URL
+ * per RFC 2732, split the hostname part and the port part and return an
+ * array with an element for each. If there is no port part, the array will
+ * have false in place of the port. If the string was invalid in some way,
* false is returned.
*
- * This was easy with IPv4 and was generally done in an ad-hoc way, but
- * with IPv6 it's somewhat more complicated due to the need to parse the
+ * This was easy with IPv4 and was generally done in an ad-hoc way, but
+ * with IPv6 it's somewhat more complicated due to the need to parse the
* square brackets and colons.
*
* A bare IPv6 address is accepted despite the lack of square brackets.
/**
* Given a host name and a port, combine them into host/port string like
* you might find in a URL. If the host contains a colon, wrap it in square
- * brackets like in RFC 2732. If the port matches the default port, omit
+ * brackets like in RFC 2732. If the port matches the default port, omit
* the port specification
+ *
+ * @param $host string
+ * @param $port int
+ * @param $defaultPort bool|int
+ * @return string
*/
public static function combineHostAndPort( $host, $port, $defaultPort = false ) {
if ( strpos( $host, ':' ) !== false ) {
return $n;
}
+ /**
+ * @param $ip
+ * @return String
+ */
private static function toUnsigned6( $ip ) {
return wfBaseConvert( self::IPv6ToRawHex( $ip ), 16, 10 );
}
* Convert a network specification in IPv6 CIDR notation to an
* integer network and a number of bits
*
+ * @param $range
+ *
* @return array(string, int)
*/
private static function parseCIDR6( $range ) {
* 2001:0db8:85a3::7344/96 CIDR
* 2001:0db8:85a3::7344 - 2001:0db8:85a3::7344 Explicit range
* 2001:0db8:85a3::7344/96 Single IP
+ *
+ * @param $range
+ *
* @return array(string, string)
*/
private static function parseRange6( $range ) {
}
/**
- * Returns true if we are running under HipHop, whether in compiled or
+ * Returns true if we are running under HipHop, whether in compiled or
* interpreted mode.
*
* @return bool
}
/**
- * If we are running code compiled by HipHop, this will pass through the
- * input path, assumed to be relative to $IP. If the code is interpreted,
- * it will converted to a fully qualified path. It is necessary to use a
- * path which is relative to $IP in order to make HipHop use its compiled
+ * If we are running code compiled by HipHop, this will pass through the
+ * input path, assumed to be relative to $IP. If the code is interpreted,
+ * it will converted to a fully qualified path. It is necessary to use a
+ * path which is relative to $IP in order to make HipHop use its compiled
* code.
*
* @param $file string
}
/**
- * Register an extension setup file and return its path for compiled
+ * Register an extension setup file and return its path for compiled
* inclusion. Use this function in LocalSettings.php to add extensions
* to the build. For example:
*
/**
* Determine whether a class exists, using a method which works under HipHop.
*
- * Note that it's not possible to implement this with any variant of
- * class_exists(), because class_exists() returns false for classes which
- * are compiled in.
+ * Note that it's not possible to implement this with any variant of
+ * class_exists(), because class_exists() returns false for classes which
+ * are compiled in.
*
- * Calling class_exists() on a literal string causes the class to be made
- * "volatile", which means (as of March 2011) that the class is broken and
- * can't be used at all. So don't do that. See
+ * Calling class_exists() on a literal string causes the class to be made
+ * "volatile", which means (as of March 2011) that the class is broken and
+ * can't be used at all. So don't do that. See
* https://github.com/facebook/hiphop-php/issues/314
*
* @param $class string
}
/**
- * Determine whether a function exists, using a method which works under
+ * Determine whether a function exists, using a method which works under
* HipHop.
*
* @param $function string
- *
+ *
* @return bool
*/
static function functionExists( $function ) {
return str_repeat( "\t", $depth ) . Xml::element( 'option', $attribs, $val ) . "\n";
}
+ /**
+ * @param $str string
+ * @return String
+ */
protected function msg( $str ) {
$msg = wfMessage( $str );
return $msg->exists() ? $msg->text() : $str;
}
/**
- * @return boolean Checkbox
+ * @param $pattern
+ * @return string Checkbox
*/
private function getTitlePattern( $pattern ) {
return '<span style="white-space: nowrap">' .
'</span>';
}
+ /**
+ * @param $types
+ * @return string
+ */
private function getExtraInputs( $types ) {
global $wgRequest;
$offender = $wgRequest->getVal('offender');
return '';
}
+ /**
+ * @return string
+ */
public function beginLogEventsList() {
return "<ul>\n";
}
+ /**
+ * @return string
+ */
public function endLogEventsList() {
return "</ul>\n";
}
return htmlspecialchars( $time );
}
+ /**
+ * @param $row
+ * @return String
+ */
private function logUserLinks( $row ) {
if( self::isDeleted( $row, LogPage::DELETED_USER ) ) {
$userLinks = '<span class="history-deleted">' .
return $userLinks;
}
+ /**
+ * @param $row
+ * @param $title
+ * @param $paramArray
+ * @return string
+ */
private function logAction( $row, $title, $paramArray ) {
if( self::isDeleted( $row, LogPage::DELETED_ACTION ) ) {
$action = '<span class="history-deleted">' .
return $action;
}
+ /**
+ * @param $row
+ * @return string
+ */
private function logComment( $row ) {
if( self::isDeleted( $row, LogPage::DELETED_COMMENT ) ) {
$comment = '<span class="history-deleted">' .
return $query;
}
+ /**
+ * @return Title
+ */
function getTitle() {
return $this->mLogEventsList->getDisplayTitle();
}
return $this->types;
}
+ /**
+ * @return string
+ */
public function getUser() {
return $this->user;
}
+ /**
+ * @return string
+ */
public function getPage() {
return $this->title;
}
/**
* Get the RC comment from the last addEntry() call
+ *
+ * @return string
*/
public function getRcComment() {
$rcComment = $this->actionText;
* @param $comment String: description associated
* @param $params Array: parameters passed later to wfMsg.* functions
* @param $doer User object: the user doing the action
+ *
+ * @return bool|int|null
*/
public function addEntry( $action, $target, $comment, $params = array(), $doer = null ) {
global $wgContLang;
* Get an array of parser substitution modifier IDs
*/
static function getSubstIDs() {
- return self::$mSubstIDs;
+ return self::$mSubstIDs;
}
/**
}
/**
- * A comparison function that returns -1, 0 or 1 depending on whether the
- * first string is longer, the same length or shorter than the second
+ * A comparison function that returns -1, 0 or 1 depending on whether the
+ * first string is longer, the same length or shorter than the second
* string.
*
* @param $s1 string
/**
* Add a number of magic words by name
*
- * $param $names array
+ * @param $names array
*/
public function addArray( $names ) {
$this->names = array_merge( $this->names, array_values( $names ) );
$newRegex[0] = "/^(?:{$base[0]})/iuS";
}
if ( $base[1] !== '' ) {
- $newRegex[1] = "/^(?:{$base[1]})/S";
+ $newRegex[1] = "/^(?:{$base[1]})/S";
}
return $newRegex;
}