*
* 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
*
// 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] );
}
* @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 );
// 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 );
}
}