if ( !function_exists( 'mb_substr' ) ) {
/**
* @codeCoverageIgnore
+ * @see Fallback::mb_substr
* @return string
*/
function mb_substr( $str, $start, $count = 'end' ) {
/**
* @codeCoverageIgnore
+ * @see Fallback::mb_substr_split_unicode
* @return int
*/
function mb_substr_split_unicode( $str, $splitPos ) {
if ( !function_exists( 'mb_strlen' ) ) {
/**
* @codeCoverageIgnore
+ * @see Fallback::mb_strlen
* @return int
*/
function mb_strlen( $str, $enc = '' ) {
if ( !function_exists( 'mb_strpos' ) ) {
/**
* @codeCoverageIgnore
+ * @see Fallback::mb_strpos
* @return int
*/
function mb_strpos( $haystack, $needle, $offset = 0, $encoding = '' ) {
if ( !function_exists( 'mb_strrpos' ) ) {
/**
* @codeCoverageIgnore
+ * @see Fallback::mb_strrpos
* @return int
*/
function mb_strrpos( $haystack, $needle, $offset = 0, $encoding = '' ) {
if ( !function_exists( 'gzdecode' ) ) {
/**
* @codeCoverageIgnore
+ * @param string $data
* @return string
*/
function gzdecode( $data ) {
}
}
-/**
- * Array lookup
- * Returns an array where the values in array $b are replaced by the
- * values in array $a with the corresponding keys
- *
- * @deprecated since 1.22; use array_intersect_key()
- * @param array $a
- * @param array $b
- * @return array
- */
-function wfArrayLookup( $a, $b ) {
- wfDeprecated( __FUNCTION__, '1.22' );
- return array_flip( array_intersect( array_flip( $a ), array_keys( $b ) ) );
-}
-
/**
* Appends to second array if $value differs from that in $default
*
}
}
-/**
- * Backwards array plus for people who haven't bothered to read the PHP manual
- * XXX: will not darn your socks for you.
- *
- * @deprecated since 1.22; use array_replace()
- *
- * @param array $array1 Initial array to merge.
- * @param array $array2,... Variable list of arrays to merge.
- * @return array
- */
-function wfArrayMerge( $array1 /*...*/ ) {
- wfDeprecated( __FUNCTION__, '1.22' );
- $args = func_get_args();
- $args = array_reverse( $args, true );
- $out = array();
- foreach ( $args as $arg ) {
- $out += $arg;
- }
- return $out;
-}
-
/**
* Merge arrays in the style of getUserPermissionsErrors, with duplicate removal
* e.g.
return MessageCache::singleton()->get( $key, /*useDB*/true, /*content*/false ) === false;
}
-/**
- * Throw a debugging exception. This function previously once exited the process,
- * but now throws an exception instead, with similar results.
- *
- * @deprecated since 1.22; just throw an MWException yourself
- * @param string $msg Message shown when dying.
- * @throws MWException
- */
-function wfDebugDieBacktrace( $msg = '' ) {
- wfDeprecated( __FUNCTION__, '1.22' );
- throw new MWException( $msg );
-}
-
/**
* Fetch server name for use in error reporting etc.
* Use real server name if available, so we know which machine
return $text;
}
-/**
- * Get the current unix timestamp with microseconds. Useful for profiling
- * @deprecated since 1.22; call microtime() directly
- * @return float
- */
-function wfTime() {
- wfDeprecated( __FUNCTION__, '1.22' );
- return microtime( true );
-}
-
/**
* Sets dest to source and returns the original value of dest
* If source is NULL, it just returns the value, it doesn't set the variable
);
if ( extension_loaded( 'gmp' ) && ( $engine == 'auto' || $engine == 'gmp' ) ) {
- $result = gmp_strval( gmp_init( $input, $sourceBase ), $destBase );
+ // Removing leading zeros works around broken base detection code in
+ // some PHP versions (see <https://bugs.php.net/bug.php?id=50175> and
+ // <https://bugs.php.net/bug.php?id=55398>).
+ $result = gmp_strval( gmp_init( ltrim( $input, '0' ), $sourceBase ), $destBase );
} elseif ( extension_loaded( 'bcmath' ) && ( $engine == 'auto' || $engine == 'bcmath' ) ) {
$decimal = '0';
foreach ( str_split( strtolower( $input ) ) as $char ) {
* @param float|null $ifWritesSince Only wait if writes were done since this UNIX timestamp
* @param string|bool $wiki Wiki identifier accepted by wfGetLB
* @param string|bool $cluster Cluster name accepted by LBFactory. Default: false.
+ * @return bool Success (able to connect and no timeouts reached)
*/
function wfWaitForSlaves( $ifWritesSince = false, $wiki = false, $cluster = false ) {
// B/C: first argument used to be "max seconds of lag"; ignore such values
// Prevents permission error when getting master position
if ( $lb->getServerCount() > 1 ) {
if ( $ifWritesSince && !$lb->hasMasterConnection() ) {
- return; // assume no writes done
+ return true; // assume no writes done
}
$dbw = $lb->getConnection( DB_MASTER, array(), $wiki );
if ( $ifWritesSince && $dbw->lastDoneWrites() < $ifWritesSince ) {
- return; // no writes since the last wait
+ return true; // no writes since the last wait
}
$pos = $dbw->getMasterPos();
// The DBMS may not support getMasterPos() or the whole
// load balancer might be fake (e.g. $wgAllDBsAreLocalhost).
if ( $pos !== false ) {
- $lb->waitForAll( $pos );
+ return $lb->waitForAll( $pos, PHP_SAPI === 'cli' ? 86400 : null );
}
}
+
+ return true;
}
/**