X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FGlobalFunctions.php;h=ddea620b815dcb637bcd2686bd2e0a8f037437a3;hb=1bb93ae45ab6fefd269b1be1c1dab13077aec320;hp=b40b00703c65219cf2a9ef4128c4873aceb276e6;hpb=b74456fca841445a1c9f356fc8e53551eea14dd4;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index b40b00703c..ddea620b81 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -38,6 +38,7 @@ if ( !defined( 'MEDIAWIKI' ) ) { if ( !function_exists( 'mb_substr' ) ) { /** * @codeCoverageIgnore + * @see Fallback::mb_substr * @return string */ function mb_substr( $str, $start, $count = 'end' ) { @@ -46,6 +47,7 @@ if ( !function_exists( 'mb_substr' ) ) { /** * @codeCoverageIgnore + * @see Fallback::mb_substr_split_unicode * @return int */ function mb_substr_split_unicode( $str, $splitPos ) { @@ -56,6 +58,7 @@ if ( !function_exists( 'mb_substr' ) ) { if ( !function_exists( 'mb_strlen' ) ) { /** * @codeCoverageIgnore + * @see Fallback::mb_strlen * @return int */ function mb_strlen( $str, $enc = '' ) { @@ -66,6 +69,7 @@ if ( !function_exists( 'mb_strlen' ) ) { if ( !function_exists( 'mb_strpos' ) ) { /** * @codeCoverageIgnore + * @see Fallback::mb_strpos * @return int */ function mb_strpos( $haystack, $needle, $offset = 0, $encoding = '' ) { @@ -76,6 +80,7 @@ if ( !function_exists( 'mb_strpos' ) ) { if ( !function_exists( 'mb_strrpos' ) ) { /** * @codeCoverageIgnore + * @see Fallback::mb_strrpos * @return int */ function mb_strrpos( $haystack, $needle, $offset = 0, $encoding = '' ) { @@ -88,6 +93,7 @@ if ( !function_exists( 'mb_strrpos' ) ) { if ( !function_exists( 'gzdecode' ) ) { /** * @codeCoverageIgnore + * @param string $data * @return string */ function gzdecode( $data ) { @@ -176,21 +182,6 @@ function wfArrayDiff2_cmp( $a, $b ) { } } -/** - * 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 * @@ -209,27 +200,6 @@ function wfAppendToArrayIfNotDefault( $key, $value, $default, &$changed ) { } } -/** - * 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. @@ -1807,19 +1777,6 @@ function wfEmptyMsg( $key ) { 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 @@ -2116,16 +2073,6 @@ function wfEscapeWikiText( $text ) { 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 @@ -3811,6 +3758,7 @@ function wfGetNull() { * @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 @@ -3826,19 +3774,21 @@ function wfWaitForSlaves( $ifWritesSince = false, $wiki = false, $cluster = fals // 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; } /**