global $wgOut, $wgDebugLogFile, $wgDebugComments, $wgProfileOnly, $wgDebugRawPage;
static $recursion = 0;
+ static $cache = array(); // Cache of unoutputted messages
+
# Check for raw action using $_GET not $wgRequest, since the latter might not be initialised yet
if ( isset( $_GET['action'] ) && $_GET['action'] == 'raw' && !$wgDebugRawPage ) {
return;
}
if ( $wgDebugComments && !$logonly ) {
+ $cache[] = $text;
+
if ( !isset( $wgOut ) ) {
return;
}
$wgOut->_unstub();
$recursion--;
}
- $wgOut->debug( $text );
+
+ // add the message and possible cached ones to the output
+ array_map( array( $wgOut, 'debug' ), $cache );
+ $cache = array();
}
if ( '' != $wgDebugLogFile && !$wgProfileOnly ) {
# Strip unprintables; they can switch terminal modes when binary data
* @param string $key
* @param bool $useDB
* @param string $langcode Code of the language to get the message for, or
- * behaves as a content language switch if it is a
+ * behaves as a content language switch if it is a
* boolean.
* @return string
* @private
function wfMsgGetKey( $key, $useDB, $langCode = false, $transform = true ) {
global $wgParser, $wgContLang, $wgMessageCache, $wgLang;
+ wfRunHooks('NormalizeMessageKey', array(&$key, &$useDB, &$langCode, &$transform));
+
# If $wgMessageCache isn't initialised yet, try to return something sensible.
if( is_object( $wgMessageCache ) ) {
$message = $wgMessageCache->get( $key, $useDB, $langCode );
$langCode = $options['language'];
$validCodes = array_keys( Language::getLanguageNames() );
if( !in_array($options['language'], $validCodes) ) {
- $langCode = false;
+ # Fallback to en, instead of whatever interface language we might have
+ $langCode = 'en';
}
} else {
$forContent = false;
$currentDir = substr( $currentDir, 0, $p );
}
}
-
+
if ( count( $createList ) == 0 ) {
# Directory specified already exists
return true;
} elseif ( $currentDir === false ) {
# Went all the way back to root and it apparently doesn't exist
+ wfDebugLog( 'mkdir', "Root doesn't exist?\n" );
return false;
}
-
# Now go forward creating directories
$createList = array_reverse( $createList );
+
+ # Is the parent directory writable?
+ if ( $currentDir === '' ) {
+ $currentDir = '/';
+ }
+ if ( !is_writable( $currentDir ) ) {
+ wfDebugLog( 'mkdir', "Not writable: $currentDir\n" );
+ return false;
+ }
+
foreach ( $createList as $dir ) {
- # Check first to avoid spamming with warnings
- if ( !is_writable( $dir ) ) {
- return false;
- }
# use chmod to override the umask, as suggested by the PHP manual
if ( !mkdir( $dir, $mode ) || !chmod( $dir, $mode ) ) {
wfDebugLog( 'mkdir', "Unable to create directory $dir\n" );
* @param string $userid ID of the user
* @param string $password Password of the user
* @return string Hashed password
+ * @deprecated Use User::crypt() or User::oldCrypt() instead
*/
function wfEncryptPassword( $userid, $password ) {
- global $wgPasswordSalt;
- $p = md5( $password);
-
- if($wgPasswordSalt)
- return md5( "{$userid}-{$p}" );
- else
- return $p;
+ wfDeprecated(__FUNCTION__);
+ # Just wrap around User::oldCrypt()
+ return User::oldCrypt($password, $userid);
}
/**
}
/**
- * Aliases for modularized functions
+ * Alias for modularized function
+ * @deprecated Use Http::get() instead
*/
function wfGetHTTP( $url, $timeout = 'default' ) {
+ wfDeprecated(__FUNCTION__);
return Http::get( $url, $timeout );
}
+
+/**
+ * Alias for modularized function
+ * @deprecated Use Http::isLocalURL() instead
+ */
function wfIsLocalURL( $url ) {
+ wfDeprecated(__FUNCTION__);
return Http::isLocalURL( $url );
}
global $wgHttpOnlyBlacklist;
if( !version_compare("5.2", PHP_VERSION, "<") )
return false;
-
+
if( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
foreach( $wgHttpOnlyBlacklist as $regex ) {
if( preg_match( $regex, $_SERVER['HTTP_USER_AGENT'] ) ) {
}
}
}
-
+
return true;
}
*
* @param string $wiki The wiki ID, or false for the current wiki
*
- * Note: multiple calls to wfGetDB(DB_SLAVE) during the course of one request
- * will always return the same object, unless the underlying connection or load
- * balancer is manually destroyed.
+ * Note: multiple calls to wfGetDB(DB_SLAVE) during the course of one request
+ * will always return the same object, unless the underlying connection or load
+ * balancer is manually destroyed.
*/
function &wfGetDB( $db = DB_LAST, $groups = array(), $wiki = false ) {
return wfGetLB( $wiki )->getConnection( $db, $groups, $wiki );
$loaded[$extensionName] = array();
}
+ if ( !isset($wgExtensionMessagesFiles[$extensionName]) ) {
+ throw new MWException( "Messages file for extensions $extensionName is not defined" );
+ }
+
if( !$langcode && !array_key_exists( '*', $loaded[$extensionName] ) ) {
# Just do en, content language and user language.
$wgMessageCache->loadMessagesFile( $wgExtensionMessagesFiles[$extensionName], false );
return md5( mt_rand( 0, 0x7fffffff ) . $salt );
}
+
+/**
+ * Replace all invalid characters with -
+ * @param mixed $title Filename to process
+ */
+function wfStripIllegalFilenameChars( $name ) {
+ $name = wfBaseName( $name );
+ $name = preg_replace ( "/[^".Title::legalChars()."]|:/", '-', $name );
+ return $name;
+}