Undefined variable: attrs in HistoryAction.php on line 202
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index cfe9a87..3306acd 100644 (file)
@@ -1407,7 +1407,7 @@ function wfGetLangObj( $langcode = false ) {
  *
  * This function replaces all old wfMsg* functions.
  *
- * @param string $key Message key
+ * @param string|string[] $key Message key, or array of keys
  * @param mixed $params,... Normal message parameters
  * @return Message
  *
@@ -3179,10 +3179,10 @@ function wfDiff( $before, $after, $params = '-u' ) {
 
        // Kill the --- and +++ lines. They're not useful.
        $diff_lines = explode( "\n", $diff );
-       if ( strpos( $diff_lines[0], '---' ) === 0 ) {
+       if ( isset( $diff_lines[0] ) && strpos( $diff_lines[0], '---' ) === 0 ) {
                unset( $diff_lines[0] );
        }
-       if ( strpos( $diff_lines[1], '+++' ) === 0 ) {
+       if ( isset( $diff_lines[1] ) && strpos( $diff_lines[1], '+++' ) === 0 ) {
                unset( $diff_lines[1] );
        }
 
@@ -3761,11 +3761,18 @@ 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.
+ * @param int|null $timeout Max wait time. Default: 1 day (cli), ~10 seconds (web)
  * @return bool Success (able to connect and no timeouts reached)
  */
-function wfWaitForSlaves( $ifWritesSince = false, $wiki = false, $cluster = false ) {
+function wfWaitForSlaves(
+       $ifWritesSince = null, $wiki = false, $cluster = false, $timeout = null
+) {
        // B/C: first argument used to be "max seconds of lag"; ignore such values
-       $ifWritesSince = ( $ifWritesSince > 1e9 ) ? $ifWritesSince : false;
+       $ifWritesSince = ( $ifWritesSince > 1e9 ) ? $ifWritesSince : null;
+
+       if ( $timeout === null ) {
+               $timeout = ( PHP_SAPI === 'cli' ) ? 86400 : 10;
+       }
 
        if ( $cluster !== false ) {
                $lb = wfGetLBFactory()->getExternalLB( $cluster );
@@ -3787,7 +3794,7 @@ function wfWaitForSlaves( $ifWritesSince = false, $wiki = false, $cluster = fals
                // The DBMS may not support getMasterPos() or the whole
                // load balancer might be fake (e.g. $wgAllDBsAreLocalhost).
                if ( $pos !== false ) {
-                       return $lb->waitForAll( $pos, PHP_SAPI === 'cli' ? 86400 : null );
+                       return $lb->waitForAll( $pos, $timeout );
                }
        }