return Fallback::mb_strrpos( $haystack, $needle, $offset, $encoding );
}
}
+
+// gzdecode function only exists in PHP >= 5.4.0
+// http://php.net/gzdecode
+if ( !function_exists( 'gzdecode' ) ) {
+ /**
+ * @codeCoverageIgnore
+ * @return string
+ */
+ function gzdecode( $data ) {
+ return gzinflate( substr( $data, 10, -8 ) );
+ }
+}
/// @endcond
/**
$repl = array(
'"' => '"', '&' => '&', "'" => ''', '<' => '<',
'=' => '=', '>' => '>', '[' => '[', ']' => ']',
- '{' => '{', '|' => '|', '}' => '}',
+ '{' => '{', '|' => '|', '}' => '}', ';' => ';',
"\n#" => "\n#", "\r#" => "\r#",
"\n*" => "\n*", "\r*" => "\r*",
"\n:" => "\n:", "\r:" => "\r:",
- "\n;" => "\n;", "\r;" => "\r;",
"\n " => "\n ", "\r " => "\r ",
+ "\n\n" => "\n ", "\r\n" => " \n",
+ "\n\r" => "\n ", "\r\r" => "\r ",
+ "\n\t" => "\n	", "\r\t" => "\r	", // "\n\t\n" is treated like "\n\n"
+ "\n----" => "\n----", "\r----" => "\r----",
'__' => '__', '://' => '://',
);
wfDebug( "$caller: called wfMkdirParents($dir)\n" );
}
- if ( strval( $dir ) === '' || file_exists( $dir ) ) {
+ if ( strval( $dir ) === '' || ( file_exists( $dir ) && is_dir( $dir ) ) ) {
return true;
}
wfRestoreWarnings();
if ( !$ok ) {
+ //directory may have been created on another request since we last checked
+ if ( is_dir( $dir ) ) {
+ return true;
+ }
+
// PHP doesn't report the path in its warning message, so add our own to aid in diagnosis.
wfLogWarning( sprintf( "failed to mkdir \"%s\" mode 0%o", $dir, $mode ) );
}
$sourceBase > 36 ||
$destBase < 2 ||
$destBase > 36 ||
- $sourceBase != (int) $sourceBase ||
- $destBase != (int) $destBase ||
- $pad != (int) $pad ||
+ $sourceBase != (int)$sourceBase ||
+ $destBase != (int)$destBase ||
+ $pad != (int)$pad ||
!preg_match( "/^[" . substr( '0123456789abcdefghijklmnopqrstuvwxyz', 0, $sourceBase ) . "]+$/i", $input )
) {
return false;
$work += $digit;
if ( $workDigits || $work >= $destBase ) {
- $workDigits[] = (int) ( $work / $destBase );
+ $workDigits[] = (int)( $work / $destBase );
}
$work %= $destBase;
}