Change-Id: I7db616db8c969567d420c0161fa207b366e292b6
25 files changed:
If your PHP is configured as a CGI plug-in rather than an Apache module you may
experience problems, as this configuration is not well tested. safe_mode is also
If your PHP is configured as a CGI plug-in rather than an Apache module you may
experience problems, as this configuration is not well tested. safe_mode is also
-not tested and unlikely to work.
+not tested and unlikely to work.
If you want math support see the instructions in math/README
If you want math support see the instructions in math/README
******************* WARNING *******************
******************* WARNING *******************
-REMEMBER: ALWAYS BACK UP YOUR DATABASE BEFORE
+REMEMBER: ALWAYS BACK UP YOUR DATABASE BEFORE
ATTEMPTING TO INSTALL OR UPGRADE!!!
******************* WARNING *******************
ATTEMPTING TO INSTALL OR UPGRADE!!!
******************* WARNING *******************
-For system requirements, installation and upgrade details, see the files
+For system requirements, installation and upgrade details, see the files
RELEASE-NOTES, INSTALL, and UPGRADE.
== MediaWiki ==
RELEASE-NOTES, INSTALL, and UPGRADE.
== MediaWiki ==
released into the public domain, which does not impair the obligations of users
under the GPL for use of the whole code or other sections thereof.
released into the public domain, which does not impair the obligations of users
under the GPL for use of the whole code or other sections thereof.
-MediaWiki makes use of the Sajax Toolkit by modernmethod,
+MediaWiki makes use of the Sajax Toolkit by modernmethod,
http://www.modernmethod.com/sajax/ which has the following license:
'This work is licensed under the Creative Commons Attribution
http://www.modernmethod.com/sajax/ which has the following license:
'This work is licensed under the Creative Commons Attribution
* } else {
* $wgProfiler['class'] = 'ProfilerStub';
* }
* } else {
* $wgProfiler['class'] = 'ProfilerStub';
* }
* Configuration of the profiler output can be done in LocalSettings.php
*/
* Configuration of the profiler output can be done in LocalSettings.php
*/
-If you browse to the web-based installation script (usually at
-/mw-config/index.php) from your wiki installation you can follow the script and
+If you browse to the web-based installation script (usually at
+/mw-config/index.php) from your wiki installation you can follow the script and
upgrade your database in place.
==== From the command line ====
upgrade your database in place.
==== From the command line ====
If you absolutely cannot make the UTF-8 upgrade work, you can try
doing it by hand: dump your old database, convert the dump file
If you absolutely cannot make the UTF-8 upgrade work, you can try
doing it by hand: dump your old database, convert the dump file
-using iconv as described here:
+using iconv as described here:
http://portal.suse.com/sdb/en/2004/05/jbartsh_utf-8.html
and then reimport it. You can also convert filenames using convmv,
but note that the old directory hashes will no longer be valid,
http://portal.suse.com/sdb/en/2004/05/jbartsh_utf-8.html
and then reimport it. You can also convert filenames using convmv,
but note that the old directory hashes will no longer be valid,
* $wgSharedPrefix is the table prefix for the shared database. It defaults to
* $wgDBprefix.
*
* $wgSharedPrefix is the table prefix for the shared database. It defaults to
* $wgDBprefix.
*
- * @deprecated In new code, use the $wiki parameter to wfGetLB() to access
- * remote databases. Using wfGetLB() allows the shared database to reside on
- * separate servers to the wiki's own database, with suitable configuration
+ * @deprecated In new code, use the $wiki parameter to wfGetLB() to access
+ * remote databases. Using wfGetLB() allows the shared database to reside on
+ * separate servers to the wiki's own database, with suitable configuration
* of $wgLBFactoryConf.
*/
$wgSharedDB = null;
* of $wgLBFactoryConf.
*/
$wgSharedDB = null;
/**
* Whether to use a Host header in purge requests sent to the proxy servers
/**
* Whether to use a Host header in purge requests sent to the proxy servers
- * configured in $wgSquidServers. Set this to false to support Squid
+ * configured in $wgSquidServers. Set this to false to support Squid
* configured in forward-proxy mode.
*
* If this is set to true, a Host header will be sent, and only the path
* component of the URL will appear on the request line, as if the request
* configured in forward-proxy mode.
*
* If this is set to true, a Host header will be sent, and only the path
* component of the URL will appear on the request line, as if the request
- * were a non-proxy HTTP 1.1 request. Varnish only supports this style of
+ * were a non-proxy HTTP 1.1 request. Varnish only supports this style of
* request. Squid supports this style of request only if reverse-proxy mode
* (http_port ... accel) is enabled.
*
* request. Squid supports this style of request only if reverse-proxy mode
* (http_port ... accel) is enabled.
*
* will be sent in the request line, as is the standard for an HTTP proxy
* request in both HTTP 1.0 and 1.1. This style of request is not supported
* by Varnish, but is supported by Squid in either configuration (forward or
* will be sent in the request line, as is the standard for an HTTP proxy
* request in both HTTP 1.0 and 1.1. This style of request is not supported
* by Varnish, but is supported by Squid in either configuration (forward or
- * Base class for general text storage via the "object" flag in old_flags, or
- * two-part external storage URLs. Used for represent efficient concatenated
+ * Base class for general text storage via the "object" flag in old_flags, or
+ * two-part external storage URLs. Used for represent efficient concatenated
* storage, and migration-related pointer objects.
*/
interface HistoryBlob
* storage, and migration-related pointer objects.
*/
interface HistoryBlob
* @return bool
*/
public function isHappy() {
* @return bool
*/
public function isHappy() {
- return $this->mSize < $this->mMaxSize
+ return $this->mSize < $this->mMaxSize
&& count( $this->mItems ) < $this->mMaxCount;
}
}
&& count( $this->mItems ) < $this->mMaxCount;
}
}
/** Total uncompressed size */
var $mSize = 0;
/** Total uncompressed size */
var $mSize = 0;
- /**
- * Array of diffs. If a diff D from A to B is notated D = B - A, and Z is
+ /**
+ * Array of diffs. If a diff D from A to B is notated D = B - A, and Z is
* an empty string:
*
* { item[map[i]] - item[map[i-1]] where i > 0
* an empty string:
*
* { item[map[i]] - item[map[i-1]] where i > 0
* { item[map[i]] - Z where i = 0
*/
var $mDiffs;
* { item[map[i]] - Z where i = 0
*/
var $mDiffs;
* The maximum number of text items before the object becomes sad
*/
var $mMaxCount = 100;
* The maximum number of text items before the object becomes sad
*/
var $mMaxCount = 100;
/** Constants from xdiff.h */
const XDL_BDOP_INS = 1;
const XDL_BDOP_CPY = 2;
/** Constants from xdiff.h */
const XDL_BDOP_INS = 1;
const XDL_BDOP_CPY = 2;
* @throws MWException
*/
function compress() {
* @throws MWException
*/
function compress() {
- if ( !function_exists( 'xdiff_string_rabdiff' ) ){
+ if ( !function_exists( 'xdiff_string_rabdiff' ) ){
throw new MWException( "Need xdiff 1.5+ support to write DiffHistoryBlob\n" );
}
if ( isset( $this->mDiffs ) ) {
throw new MWException( "Need xdiff 1.5+ support to write DiffHistoryBlob\n" );
}
if ( isset( $this->mDiffs ) ) {
# Pure PHP implementation
$header = unpack( 'Vofp/Vcsize', substr( $diff, 0, 8 ) );
# Pure PHP implementation
$header = unpack( 'Vofp/Vcsize', substr( $diff, 0, 8 ) );
# Check the checksum if hash/mhash is available
$ofp = $this->xdiffAdler32( $base );
if ( $ofp !== false && $ofp !== substr( $diff, 0, 4 ) ) {
# Check the checksum if hash/mhash is available
$ofp = $this->xdiffAdler32( $base );
if ( $ofp !== false && $ofp !== substr( $diff, 0, 4 ) ) {
wfDebug( __METHOD__. ": incorrect base length\n" );
return false;
}
wfDebug( __METHOD__. ": incorrect base length\n" );
return false;
}
$p = 8;
$out = '';
while ( $p < strlen( $diff ) ) {
$p = 8;
$out = '';
while ( $p < strlen( $diff ) ) {
- * Compute a binary "Adler-32" checksum as defined by LibXDiff, i.e. with
+ * Compute a binary "Adler-32" checksum as defined by LibXDiff, i.e. with
* the bytes backwards and initialised with 0 instead of 1. See bug 34428.
*
* Returns false if no hashing library is available
* the bytes backwards and initialised with 0 instead of 1. See bug 34428.
*
* Returns false if no hashing library is available
if ( $init === null ) {
$init = str_repeat( "\xf0", 205 ) . "\xee" . str_repeat( "\xf0", 67 ) . "\x02";
}
if ( $init === null ) {
$init = str_repeat( "\xf0", 205 ) . "\xee" . str_repeat( "\xf0", 67 ) . "\x02";
}
- // The real Adler-32 checksum of $init is zero, so it initialises the
- // state to zero, as it is at the start of LibXDiff's checksum
+ // The real Adler-32 checksum of $init is zero, so it initialises the
+ // state to zero, as it is at the start of LibXDiff's checksum
// algorithm. Appending the subject string then simulates LibXDiff.
if ( function_exists( 'hash' ) ) {
$hash = hash( 'adler32', $init . $s, true );
// algorithm. Appending the subject string then simulates LibXDiff.
if ( function_exists( 'hash' ) ) {
$hash = hash( 'adler32', $init . $s, true );
if ( isset( $info['base'] ) ) {
// Old format
$this->mDiffMap = range( 0, count( $this->mDiffs ) - 1 );
if ( isset( $info['base'] ) ) {
// Old format
$this->mDiffMap = range( 0, count( $this->mDiffs ) - 1 );
- array_unshift( $this->mDiffs,
+ array_unshift( $this->mDiffs,
pack( 'VVCV', 0, 0, self::XDL_BDOP_INSB, strlen( $info['base'] ) ) .
$info['base'] );
} else {
pack( 'VVCV', 0, 0, self::XDL_BDOP_INSB, strlen( $info['base'] ) ) .
$info['base'] );
} else {
* @return bool
*/
function isHappy() {
* @return bool
*/
function isHappy() {
- return $this->mSize < $this->mMaxSize
+ return $this->mSize < $this->mMaxSize
&& count( $this->mItems ) < $this->mMaxCount;
}
&& count( $this->mItems ) < $this->mMaxCount;
}
'class', // html4, html5
'accesskey', // as of html5, multiple space-separated values allowed
// html4-spec doesn't document rel= as space-separated
'class', // html4, html5
'accesskey', // as of html5, multiple space-separated values allowed
// html4-spec doesn't document rel= as space-separated
- // but has been used like that and is now documented as such
+ // but has been used like that and is now documented as such
// in the html5-spec.
'rel',
);
// in the html5-spec.
'rel',
);
// values. Implode/explode to get those into the main array as well.
if ( is_array( $value ) ) {
// If input wasn't an array, we can skip this step
// values. Implode/explode to get those into the main array as well.
if ( is_array( $value ) ) {
// If input wasn't an array, we can skip this step
$newValue = array();
foreach ( $value as $k => $v ) {
if ( is_string( $v ) ) {
$newValue = array();
foreach ( $value as $k => $v ) {
if ( is_string( $v ) ) {
# @todo FIXME: Is this really true?
$map['<'] = '<';
}
# @todo FIXME: Is this really true?
$map['<'] = '<';
}
$ret .= " $key=$quote" . strtr( $value, $map ) . $quote;
}
}
$ret .= " $key=$quote" . strtr( $value, $map ) . $quote;
}
}
/**
* Some functions to help implement an external link filter for spam control.
/**
* Some functions to help implement an external link filter for spam control.
* @todo implement the filter. Currently these are just some functions to help
* maintenance/cleanupSpam.php remove links to a single specified domain. The
* next thing is to implement functions for checking a given page against a big
* @todo implement the filter. Currently these are just some functions to help
* maintenance/cleanupSpam.php remove links to a single specified domain. The
* next thing is to implement functions for checking a given page against a big
// Reverse the labels in the hostname, convert to lower case
// For emails reverse domainpart only
if ( $prot == 'mailto:' && strpos($host, '@') ) {
// Reverse the labels in the hostname, convert to lower case
// For emails reverse domainpart only
if ( $prot == 'mailto:' && strpos($host, '@') ) {
- // complete email adress
+ // complete email adress
$mailparts = explode( '@', $host );
$domainpart = strtolower( implode( '.', array_reverse( explode( '.', $mailparts[1] ) ) ) );
$host = $domainpart . '@' . $mailparts[0];
$like = array( "$prot$host", $db->anyString() );
} elseif ( $prot == 'mailto:' ) {
// domainpart of email adress only. do not add '.'
$mailparts = explode( '@', $host );
$domainpart = strtolower( implode( '.', array_reverse( explode( '.', $mailparts[1] ) ) ) );
$host = $domainpart . '@' . $mailparts[0];
$like = array( "$prot$host", $db->anyString() );
} elseif ( $prot == 'mailto:' ) {
// domainpart of email adress only. do not add '.'
- $host = strtolower( implode( '.', array_reverse( explode( '.', $host ) ) ) );
- $like = array( "$prot$host", $db->anyString() );
+ $host = strtolower( implode( '.', array_reverse( explode( '.', $host ) ) ) );
+ $like = array( "$prot$host", $db->anyString() );
- $host = strtolower( implode( '.', array_reverse( explode( '.', $host ) ) ) );
+ $host = strtolower( implode( '.', array_reverse( explode( '.', $host ) ) ) );
if ( substr( $host, -1, 1 ) !== '.' ) {
$host .= '.';
}
if ( substr( $host, -1, 1 ) !== '.' ) {
$host .= '.';
}
*/
public static function buildRollbackLink( $rev, IContextSource $context = null ) {
global $wgShowRollbackEditCount, $wgMiserMode;
*/
public static function buildRollbackLink( $rev, IContextSource $context = null ) {
global $wgShowRollbackEditCount, $wgMiserMode;
// To config which pages are effected by miser mode
$disableRollbackEditCountSpecialPage = array( 'Recentchanges', 'Watchlist' );
// To config which pages are effected by miser mode
$disableRollbackEditCountSpecialPage = array( 'Recentchanges', 'Watchlist' );
*/
static function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
wfDeprecated( __METHOD__, '1.16' );
*/
static function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
wfDeprecated( __METHOD__, '1.16' );
$nt = Title::newFromText( $title );
if ( $nt instanceof Title ) {
return self::makeBrokenLinkObj( $nt, $text, $query, $trail );
$nt = Title::newFromText( $title );
if ( $nt instanceof Title ) {
return self::makeBrokenLinkObj( $nt, $text, $query, $trail );
*/
static function makeLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
# wfDeprecated( __METHOD__, '1.16' ); // See r105985 and it's revert. Somewhere still used.
*/
static function makeLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
# wfDeprecated( __METHOD__, '1.16' ); // See r105985 and it's revert. Somewhere still used.
wfProfileIn( __METHOD__ );
$query = wfCgiToArray( $query );
list( $inside, $trail ) = self::splitTrail( $trail );
wfProfileIn( __METHOD__ );
$query = wfCgiToArray( $query );
list( $inside, $trail ) = self::splitTrail( $trail );
$title, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = ''
) {
# wfDeprecated( __METHOD__, '1.16' ); // See r105985 and it's revert. Somewhere still used.
$title, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = ''
) {
# wfDeprecated( __METHOD__, '1.16' ); // See r105985 and it's revert. Somewhere still used.
wfProfileIn( __METHOD__ );
if ( $text == '' ) {
wfProfileIn( __METHOD__ );
if ( $text == '' ) {
*/
static function makeBrokenLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' ) {
wfDeprecated( __METHOD__, '1.16' );
*/
static function makeBrokenLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' ) {
wfDeprecated( __METHOD__, '1.16' );
wfProfileIn( __METHOD__ );
list( $inside, $trail ) = self::splitTrail( $trail );
wfProfileIn( __METHOD__ );
list( $inside, $trail ) = self::splitTrail( $trail );
*/
static function makeColouredLinkObj( $nt, $colour, $text = '', $query = '', $trail = '', $prefix = '' ) {
wfDeprecated( __METHOD__, '1.16' );
*/
static function makeColouredLinkObj( $nt, $colour, $text = '', $query = '', $trail = '', $prefix = '' ) {
wfDeprecated( __METHOD__, '1.16' );
if ( $colour != '' ) {
$style = self::getInternalLinkAttributesObj( $nt, $text, $colour );
} else {
if ( $colour != '' ) {
$style = self::getInternalLinkAttributesObj( $nt, $text, $colour );
} else {
* This is used as a fallback to mime.types files.
* An extensive list of well known mime types is provided by
* the file mime.types in the includes directory.
* This is used as a fallback to mime.types files.
* An extensive list of well known mime types is provided by
* the file mime.types in the includes directory.
* This list concatenated with mime.types is used to create a mime <-> ext
* map. Each line contains a mime type followed by a space separated list of
* This list concatenated with mime.types is used to create a mime <-> ext
* map. Each line contains a mime type followed by a space separated list of
- * extensions. If multiple extensions for a single mime type exist or if
+ * extensions. If multiple extensions for a single mime type exist or if
* multiple mime types exist for a single extension then in most cases
* MediaWiki assumes that the first extension following the mime type is the
* canonical extension, and the first time a mime type appears for a certain
* extension is considered the canonical mime type.
* multiple mime types exist for a single extension then in most cases
* MediaWiki assumes that the first extension following the mime type is the
* canonical extension, and the first time a mime type appears for a certain
* extension is considered the canonical mime type.
* (Note that appending $wgMimeTypeFile to the end of MM_WELL_KNOWN_MIME_TYPES
* (Note that appending $wgMimeTypeFile to the end of MM_WELL_KNOWN_MIME_TYPES
- * sucks because you can't redefine canonical types. This could be fixed by
+ * sucks because you can't redefine canonical types. This could be fixed by
* appending MM_WELL_KNOWN_MIME_TYPES behind $wgMimeTypeFile, but who knows
* what will break? In practice this probably isn't a problem anyway -- Bryan)
*/
* appending MM_WELL_KNOWN_MIME_TYPES behind $wgMimeTypeFile, but who knows
* what will break? In practice this probably isn't a problem anyway -- Bryan)
*/
image/gif gif
image/jpeg jpeg jpg jpe
image/png png
image/gif gif
image/jpeg jpeg jpg jpe
image/png png
image/svg svg
image/tiff tiff tif
image/vnd.djvu djvu
image/svg svg
image/tiff tiff tif
image/vnd.djvu djvu
return self::$instance;
}
return self::$instance;
}
- /**
- * Returns a list of file extensions for a given mime type as a space
+ /**
+ * Returns a list of file extensions for a given mime type as a space
* separated string or null if the mime type was unrecognized. Resolves
* mime type aliases.
* separated string or null if the mime type was unrecognized. Resolves
* mime type aliases.
* @param $mime string
* @return string|null
*/
* @param $mime string
* @return string|null
*/
- /**
- * Returns a list of mime types for a given file extension as a space
+ /**
+ * Returns a list of mime types for a given file extension as a space
* separated string or null if the extension was unrecognized.
* separated string or null if the extension was unrecognized.
* @param $ext string
* @return string|null
*/
* @param $ext string
* @return string|null
*/
* Returns a single mime type for a given file extension or null if unknown.
* This is always the first type from the list returned by getTypesForExtension($ext).
* Returns a single mime type for a given file extension or null if unknown.
* This is always the first type from the list returned by getTypesForExtension($ext).
* @param $ext string
* @return string|null
*/
* @param $ext string
* @return string|null
*/
- /**
- * Tests if the extension matches the given mime type. Returns true if a
- * match was found, null if the mime type is unknown, and false if the
+ /**
+ * Tests if the extension matches the given mime type. Returns true if a
+ * match was found, null if the mime type is unknown, and false if the
* mime type is known but no matches where found.
* mime type is known but no matches where found.
* @param $extension string
* @param $mime string
* @return bool|null
* @param $extension string
* @param $mime string
* @return bool|null
return in_array( $extension, $ext );
}
return in_array( $extension, $ext );
}
- /**
- * Returns true if the mime type is known to represent an image format
+ /**
+ * Returns true if the mime type is known to represent an image format
* supported by the PHP GD library.
*
* @param $mime string
* supported by the PHP GD library.
*
* @param $mime string
* @return bool
*/
public function isPHPImageType( $mime ) {
* @return bool
*/
public function isPHPImageType( $mime ) {
return in_array( strtolower( $extension ), $types );
}
return in_array( strtolower( $extension ), $types );
}
* Improves a mime type using the file extension. Some file formats are very generic,
* Improves a mime type using the file extension. Some file formats are very generic,
- * so their mime type is not very meaningful. A more useful mime type can be derived
- * by looking at the file extension. Typically, this method would be called on the
+ * so their mime type is not very meaningful. A more useful mime type can be derived
+ * by looking at the file extension. Typically, this method would be called on the
* result of guessMimeType().
* result of guessMimeType().
* Currently, this method does the following:
*
* If $mime is "unknown/unknown" and isRecognizableExtension( $ext ) returns false,
* Currently, this method does the following:
*
* If $mime is "unknown/unknown" and isRecognizableExtension( $ext ) returns false,
- * return the result of guessTypesForExtension($ext).
+ * return the result of guessTypesForExtension($ext).
*
* If $mime is "application/x-opc+zip" and isMatchingExtension( $ext, $mime )
*
* If $mime is "application/x-opc+zip" and isMatchingExtension( $ext, $mime )
- * gives true, return the result of guessTypesForExtension($ext).
+ * gives true, return the result of guessTypesForExtension($ext).
*
* @param $mime String: the mime type, typically guessed from a file's content.
* @param $ext String: the file extension, as taken from the file name
*
* @param $mime String: the mime type, typically guessed from a file's content.
* @param $ext String: the file extension, as taken from the file name
public function improveTypeFromExtension( $mime, $ext ) {
if ( $mime === 'unknown/unknown' ) {
if ( $this->isRecognizableExtension( $ext ) ) {
public function improveTypeFromExtension( $mime, $ext ) {
if ( $mime === 'unknown/unknown' ) {
if ( $this->isRecognizableExtension( $ext ) ) {
- wfDebug( __METHOD__. ': refusing to guess mime type for .' .
+ wfDebug( __METHOD__. ': refusing to guess mime type for .' .
"$ext file, we should have recognized it\n" );
} else {
"$ext file, we should have recognized it\n" );
} else {
- // Not something we can detect, so simply
+ // Not something we can detect, so simply
// trust the file extension
$mime = $this->guessTypesForExtension( $ext );
}
// trust the file extension
$mime = $this->guessTypesForExtension( $ext );
}
// find the proper mime type for that file extension
$mime = $this->guessTypesForExtension( $ext );
} else {
// find the proper mime type for that file extension
$mime = $this->guessTypesForExtension( $ext );
} else {
- wfDebug( __METHOD__. ": refusing to guess better type for $mime file, " .
+ wfDebug( __METHOD__. ": refusing to guess better type for $mime file, " .
".$ext is not a known OPC extension.\n" );
$mime = 'application/zip';
}
".$ext is not a known OPC extension.\n" );
$mime = 'application/zip';
}
- /**
- * Mime type detection. This uses detectMimeType to detect the mime type
- * of the file, but applies additional checks to determine some well known
- * file formats that may be missed or misinterpreter by the default mime
- * detection (namely XML based formats like XHTML or SVG, as well as ZIP
+ /**
+ * Mime type detection. This uses detectMimeType to detect the mime type
+ * of the file, but applies additional checks to determine some well known
+ * file formats that may be missed or misinterpreter by the default mime
+ * detection (namely XML based formats like XHTML or SVG, as well as ZIP
* based formats like OPC/ODF files).
*
* @param $file String: the file to check
* @param $ext Mixed: the file extension, or true (default) to extract it from the filename.
* based formats like OPC/ODF files).
*
* @param $file String: the file to check
* @param $ext Mixed: the file extension, or true (default) to extract it from the filename.
- * Set it to false to ignore the extension. DEPRECATED! Set to false, use
+ * Set it to false to ignore the extension. DEPRECATED! Set to false, use
* improveTypeFromExtension($mime, $ext) later to improve mime type.
*
* @return string the mime type of $file
* improveTypeFromExtension($mime, $ext) later to improve mime type.
*
* @return string the mime type of $file
// @todo FIXME: Shouldn't this be rb?
$f = fopen( $file, 'rt' );
wfRestoreWarnings();
// @todo FIXME: Shouldn't this be rb?
$f = fopen( $file, 'rt' );
wfRestoreWarnings();
if( !$f ) {
return 'unknown/unknown';
}
if( !$f ) {
return 'unknown/unknown';
}
/**
* Detect application-specific file type of a given ZIP file from its
* header data. Currently works for OpenDocument and OpenXML types...
/**
* Detect application-specific file type of a given ZIP file from its
* header data. Currently works for OpenDocument and OpenXML types...
* @param $header String: some reasonably-sized chunk of file header
* @param $tail String: the tail of the file
* @param $ext Mixed: the file extension, or true to extract it from the filename.
* @param $header String: some reasonably-sized chunk of file header
* @param $tail String: the tail of the file
* @param $ext Mixed: the file extension, or true to extract it from the filename.
- * Set it to false (default) to ignore the extension. DEPRECATED! Set to false,
+ * Set it to false (default) to ignore the extension. DEPRECATED! Set to false,
* use improveTypeFromExtension($mime, $ext) later to improve mime type.
*
* @return string
* use improveTypeFromExtension($mime, $ext) later to improve mime type.
*
* @return string
wfDebug( __METHOD__.": detected $mime from ZIP archive\n" );
} elseif ( preg_match( $openxmlRegex, substr( $header, 30 ) ) ) {
$mime = "application/x-opc+zip";
wfDebug( __METHOD__.": detected $mime from ZIP archive\n" );
} elseif ( preg_match( $openxmlRegex, substr( $header, 30 ) ) ) {
$mime = "application/x-opc+zip";
- # TODO: remove the block below, as soon as improveTypeFromExtension is used everywhere
- if ( $ext !== true && $ext !== false ) {
+ # TODO: remove the block below, as soon as improveTypeFromExtension is used everywhere
+ if ( $ext !== true && $ext !== false ) {
/** This is the mode used by getPropsFromPath
* These mime's are stored in the database, where we don't really want
* x-opc+zip, because we use it only for internal purposes
/** This is the mode used by getPropsFromPath
* These mime's are stored in the database, where we don't really want
* x-opc+zip, because we use it only for internal purposes
}
}
wfDebug( __METHOD__.": detected an Open Packaging Conventions archive: $mime\n" );
}
}
wfDebug( __METHOD__.": detected an Open Packaging Conventions archive: $mime\n" );
- } elseif ( substr( $header, 0, 8 ) == "\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1" &&
+ } elseif ( substr( $header, 0, 8 ) == "\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1" &&
($headerpos = strpos( $tail, "PK\x03\x04" ) ) !== false &&
preg_match( $openxmlRegex, substr( $tail, $headerpos + 30 ) ) ) {
if ( substr( $header, 512, 4) == "\xEC\xA5\xC1\x00" ) {
$mime = "application/msword";
($headerpos = strpos( $tail, "PK\x03\x04" ) ) !== false &&
preg_match( $openxmlRegex, substr( $tail, $headerpos + 30 ) ) ) {
if ( substr( $header, 512, 4) == "\xEC\xA5\xC1\x00" ) {
$mime = "application/msword";
switch( substr( $header, 512, 6) ) {
case "\xEC\xA5\xC1\x00\x0E\x00":
case "\xEC\xA5\xC1\x00\x1C\x00":
switch( substr( $header, 512, 6) ) {
case "\xEC\xA5\xC1\x00\x0E\x00":
case "\xEC\xA5\xC1\x00\x1C\x00":
- /**
- * Internal mime type detection. Detection is done using an external
- * program, if $wgMimeDetectorCommand is set. Otherwise, the fileinfo
- * extension and mime_content_type are tried (in this order), if they
- * are available. If the dections fails and $ext is not false, the mime
+ /**
+ * Internal mime type detection. Detection is done using an external
+ * program, if $wgMimeDetectorCommand is set. Otherwise, the fileinfo
+ * extension and mime_content_type are tried (in this order), if they
+ * are available. If the dections fails and $ext is not false, the mime
* type is guessed from the file extension, using guessTypesForExtension.
* type is guessed from the file extension, using guessTypesForExtension.
- *
- * If the mime type is still unknown, getimagesize is used to detect the
- * mime type if the file is an image. If no mime type can be determined,
+ *
+ * If the mime type is still unknown, getimagesize is used to detect the
+ * mime type if the file is an image. If no mime type can be determined,
* this function returns 'unknown/unknown'.
*
* @param $file String: the file to check
* @param $ext Mixed: the file extension, or true (default) to extract it from the filename.
* this function returns 'unknown/unknown'.
*
* @param $file String: the file to check
* @param $ext Mixed: the file extension, or true (default) to extract it from the filename.
- * Set it to false to ignore the extension. DEPRECATED! Set to false, use
+ * Set it to false to ignore the extension. DEPRECATED! Set to false, use
* improveTypeFromExtension($mime, $ext) later to improve mime type.
*
* @return string the mime type of $file
* improveTypeFromExtension($mime, $ext) later to improve mime type.
*
* @return string the mime type of $file
* Returns a media code matching the given mime type or file extension.
* File extensions are represented by a string starting with a dot (.) to
* distinguish them from mime types.
* Returns a media code matching the given mime type or file extension.
* File extensions are represented by a string starting with a dot (.) to
* distinguish them from mime types.
* @return int|string
*/
function findMediaType( $extMime ) {
* @return int|string
*/
function findMediaType( $extMime ) {
- if ( strpos( $extMime, '.' ) === 0 ) {
+ if ( strpos( $extMime, '.' ) === 0 ) {
// If it's an extension, look up the mime types
$m = $this->getTypesForExtension( substr( $extMime, 1 ) );
if ( !$m ) {
// If it's an extension, look up the mime types
$m = $this->getTypesForExtension( substr( $extMime, 1 ) );
if ( !$m ) {
- * Get the MIME types that various versions of Internet Explorer would
+ * Get the MIME types that various versions of Internet Explorer would
* detect from a chunk of the content.
*
* @param $fileName String: the file name (unused at present)
* detect from a chunk of the content.
*
* @param $fileName String: the file name (unused at present)
// this is a fallback SQL file
$testSqlFile = false;
$testImageZip = false;
// this is a fallback SQL file
$testSqlFile = false;
$testImageZip = false;
// if we find a request parameter containing the test name, set a cookie with the test name
if ( isset( $_GET['setupTestSuite'] ) ) {
$setupTestSuiteName = $_GET['setupTestSuite'];
// if we find a request parameter containing the test name, set a cookie with the test name
if ( isset( $_GET['setupTestSuite'] ) ) {
$setupTestSuiteName = $_GET['setupTestSuite'];
$testIncludes = array(); // array containing all the includes needed for this test
$testGlobalConfigs = array(); // an array containg all the global configs needed for this test
$testResourceFiles = array(); // an array containing all the resource files needed for this test
$testIncludes = array(); // array containing all the includes needed for this test
$testGlobalConfigs = array(); // an array containg all the global configs needed for this test
$testResourceFiles = array(); // an array containing all the resource files needed for this test
if ( isset( $testResourceFiles['images'] ) ) {
$testImageZip = $testResourceFiles['images'];
}
if ( isset( $testResourceFiles['images'] ) ) {
$testImageZip = $testResourceFiles['images'];
}
if ( isset( $testResourceFiles['db'] ) ) {
$testSqlFile = $testResourceFiles['db'];
$testResourceName = getTestResourceNameFromTestSuiteName( $setupTestSuiteName );
if ( isset( $testResourceFiles['db'] ) ) {
$testSqlFile = $testResourceFiles['db'];
$testResourceName = getTestResourceNameFromTestSuiteName( $setupTestSuiteName );
switchToTestResources( $testResourceName, false ); // false means do not switch database yet
setupTestResources( $testResourceName, $testSqlFile, $testImageZip );
}
switchToTestResources( $testResourceName, false ); // false means do not switch database yet
setupTestResources( $testResourceName, $testSqlFile, $testImageZip );
}
if ( isset( $_GET['clearTestSuite'] ) ) {
$testSuiteName = getTestSuiteNameFromCookie( $cookieName );
if ( isset( $_GET['clearTestSuite'] ) ) {
$testSuiteName = getTestSuiteNameFromCookie( $cookieName );
- $expire = time() - 600;
+ $expire = time() - 600;
setcookie(
$cookieName,
'',
setcookie(
$cookieName,
'',
$testResourceName = getTestResourceNameFromTestSuiteName( $testSuiteName );
teardownTestResources( $testResourceName );
}
// if a cookie is found, run the appropriate callback to get the config params.
$testResourceName = getTestResourceNameFromTestSuiteName( $testSuiteName );
teardownTestResources( $testResourceName );
}
// if a cookie is found, run the appropriate callback to get the config params.
-if ( isset( $_COOKIE[$cookieName] ) ) {
+if ( isset( $_COOKIE[$cookieName] ) ) {
$testSuiteName = getTestSuiteNameFromCookie( $cookieName );
if ( !isset( $wgSeleniumTestConfigs[$testSuiteName] ) ) {
return;
}
$testSuiteName = getTestSuiteNameFromCookie( $cookieName );
if ( !isset( $wgSeleniumTestConfigs[$testSuiteName] ) ) {
return;
}
$testIncludes = array(); // array containing all the includes needed for this test
$testGlobalConfigs = array(); // an array containg all the global configs needed for this test
$testResourceFiles = array(); // an array containing all the resource files needed for this test
$testIncludes = array(); // array containing all the includes needed for this test
$testGlobalConfigs = array(); // an array containg all the global configs needed for this test
$testResourceFiles = array(); // an array containing all the resource files needed for this test
- $callback = $wgSeleniumTestConfigs[$testSuiteName];
+ $callback = $wgSeleniumTestConfigs[$testSuiteName];
call_user_func_array( $callback, array( &$testIncludes, &$testGlobalConfigs, &$testResourceFiles));
if ( isset( $testResourceFiles['db'] ) ) {
call_user_func_array( $callback, array( &$testIncludes, &$testGlobalConfigs, &$testResourceFiles));
if ( isset( $testResourceFiles['db'] ) ) {
require_once( $file );
}
foreach ( $testGlobalConfigs as $key => $value ) {
require_once( $file );
}
foreach ( $testGlobalConfigs as $key => $value ) {
- if ( is_array( $value ) ) {
+ if ( is_array( $value ) ) {
$GLOBALS[$key] = array_merge( $GLOBALS[$key], $value );
$GLOBALS[$key] = array_merge( $GLOBALS[$key], $value );
} else {
$GLOBALS[$key] = $value;
}
} else {
$GLOBALS[$key] = $value;
}
if ( $testResourceName == '' ) {
die( 'Cannot identify a test the resources should be installed for.' );
}
if ( $testResourceName == '' ) {
die( 'Cannot identify a test the resources should be installed for.' );
}
// create tables
$dbw = wfGetDB( DB_MASTER );
$dbw->query( 'DROP DATABASE IF EXISTS ' . $testResourceName );
// create tables
$dbw = wfGetDB( DB_MASTER );
$dbw->query( 'DROP DATABASE IF EXISTS ' . $testResourceName );
- * Get the error message as HTML. This is done by parsing the wikitext error
+ * Get the error message as HTML. This is done by parsing the wikitext error
* message.
*/
public function getHTML( $shortContext = false, $longContext = false ) {
* message.
*/
public function getHTML( $shortContext = false, $longContext = false ) {
$linkCache = LinkCache::singleton();
$cached = $linkCache->getGoodLinkFieldObj( $this, 'redirect' );
$linkCache = LinkCache::singleton();
$cached = $linkCache->getGoodLinkFieldObj( $this, 'redirect' );
- if ( $cached === null ) {
+ if ( $cached === null ) {
// TODO: check the assumption that the cache actually knows about this title
// and handle this, such as get the title from the database.
// See https://bugzilla.wikimedia.org/show_bug.cgi?id=37209
// TODO: check the assumption that the cache actually knows about this title
// and handle this, such as get the title from the database.
// See https://bugzilla.wikimedia.org/show_bug.cgi?id=37209
- * Add this existing user object to the database. If the user already
- * exists, a fatal status object is returned, and the user object is
+ * Add this existing user object to the database. If the user already
+ * exists, a fatal status object is returned, and the user object is
* initialised with the data from the database.
*
* Previously, this function generated a DB error due to a key conflict
* initialised with the data from the database.
*
* Previously, this function generated a DB error due to a key conflict
* }
* // do something with $user...
*
* }
* // do something with $user...
*
- * However, this was vulnerable to a race condition (bug 16020). By
+ * However, this was vulnerable to a race condition (bug 16020). By
* initialising the user object if the user exists, we aim to support this
* calling sequence as far as possible.
*
* Note that if the user exists, this function will acquire a write lock,
* initialising the user object if the user exists, we aim to support this
* calling sequence as far as possible.
*
* Note that if the user exists, this function will acquire a write lock,
- * so it is still advisable to make the call conditional on isLoggedIn(),
+ * so it is still advisable to make the call conditional on isLoggedIn(),
* and to commit the transaction after calling.
*
* @return Status
* and to commit the transaction after calling.
*
* @return Status
array( 'IGNORE' )
);
if ( !$dbw->affectedRows() ) {
array( 'IGNORE' )
);
if ( !$dbw->affectedRows() ) {
- $this->mId = $dbw->selectField( 'user', 'user_id',
+ $this->mId = $dbw->selectField( 'user', 'user_id',
array( 'user_name' => $this->mName ), __METHOD__ );
$loaded = false;
if ( $this->mId ) {
array( 'user_name' => $this->mName ), __METHOD__ );
$loaded = false;
if ( $this->mId ) {
* 'DBprefix' => '',
* );
*
* 'DBprefix' => '',
* );
*
- * All fields must be present. These mean the same things as $wgDBtype,
- * $wgDBserver, etc. This implementation is quite crude; it could easily
- * support multiple database servers, for instance, and memcached, and it
- * probably has bugs. Kind of hard to reuse code when things might rely on who
+ * All fields must be present. These mean the same things as $wgDBtype,
+ * $wgDBserver, etc. This implementation is quite crude; it could easily
+ * support multiple database servers, for instance, and memcached, and it
+ * probably has bugs. Kind of hard to reuse code when things might rely on who
* knows what configuration globals.
*
* knows what configuration globals.
*
- * If either wiki uses the UserComparePasswords hook, password authentication
- * might fail unexpectedly unless they both do the exact same validation.
- * There may be other corner cases like this where this will fail, but it
+ * If either wiki uses the UserComparePasswords hook, password authentication
+ * might fail unexpectedly unless they both do the exact same validation.
+ * There may be other corner cases like this where this will fail, but it
* should be unlikely.
*
* @ingroup ExternalUser
* should be unlikely.
*
* @ingroup ExternalUser
* @return bool
*/
protected function initFromName( $name ) {
* @return bool
*/
protected function initFromName( $name ) {
- # We might not need the 'usable' bit, but let's be safe. Theoretically
- # this might return wrong results for old versions, but it's probably
+ # We might not need the 'usable' bit, but let's be safe. Theoretically
+ # this might return wrong results for old versions, but it's probably
# good enough.
$name = User::getCanonicalName( $name, 'usable' );
# good enough.
$name = User::getCanonicalName( $name, 'usable' );
}
public function authenticate( $password ) {
}
public function authenticate( $password ) {
- # This might be wrong if anyone actually uses the UserComparePasswords hook
+ # This might be wrong if anyone actually uses the UserComparePasswords hook
# (on either end), so don't use this if you those are incompatible.
return User::comparePasswords( $this->mRow->user_password, $password,
# (on either end), so don't use this if you those are incompatible.
return User::comparePasswords( $this->mRow->user_password, $password,
- $this->mRow->user_id );
+ $this->mRow->user_id );
}
public function getPref( $pref ) {
}
public function getPref( $pref ) {
- # @todo FIXME: Return other prefs too. Lots of global-riddled code that does
+ # @todo FIXME: Return other prefs too. Lots of global-riddled code that does
# this normally.
if ( $pref === 'emailaddress'
&& $this->row->user_email_authenticated !== null ) {
# this normally.
if ( $pref === 'emailaddress'
&& $this->row->user_email_authenticated !== null ) {
/**
* Guess the MIME type from the file contents alone
/**
* Guess the MIME type from the file contents alone
*/
public function getMimeType() {
return MimeMagic::singleton()->guessMimeType( $this->path, false );
*/
public function getMimeType() {
return MimeMagic::singleton()->guessMimeType( $this->path, false );
/**
* Get the final file extension from a file system path
/**
* Get the final file extension from a file system path
* @param $path string
* @return string
*/
* @param $path string
* @return string
*/
/**
* A repository for files accessible via the local filesystem.
* Does not support database access or registration.
/**
* A repository for files accessible via the local filesystem.
* Does not support database access or registration.
* This is a mostly a legacy class. New uses should not be added.
* This is a mostly a legacy class. New uses should not be added.
* @ingroup FileRepo
* @deprecated since 1.19
*/
* @ingroup FileRepo
* @deprecated since 1.19
*/
/**
* Get a key on the primary cache for this repository.
/**
* Get a key on the primary cache for this repository.
- * Returns false if the repository's cache is not accessible at this site.
+ * Returns false if the repository's cache is not accessible at this site.
* The parameters are the parts of the key, as for wfMemcKey().
* @return bool|mixed
*/
* The parameters are the parts of the key, as for wfMemcKey().
* @return bool|mixed
*/
/**
* Get a key on the primary cache for this repository.
/**
* Get a key on the primary cache for this repository.
- * Returns false if the repository's cache is not accessible at this site.
+ * Returns false if the repository's cache is not accessible at this site.
* The parameters are the parts of the key, as for wfMemcKey().
* @return bool|string
*/
* The parameters are the parts of the key, as for wfMemcKey().
* @return bool|string
*/
__METHOD__,
array( 'ORDER BY' => 'img_name' )
);
__METHOD__,
array( 'ORDER BY' => 'img_name' )
);
$result = array();
foreach ( $res as $row ) {
$result[] = $this->newFileFromRow( $row );
$result = array();
foreach ( $res as $row ) {
$result[] = $this->newFileFromRow( $row );
/**
* Get a key on the primary cache for this repository.
/**
* Get a key on the primary cache for this repository.
- * Returns false if the repository's cache is not accessible at this site.
+ * Returns false if the repository's cache is not accessible at this site.
* The parameters are the parts of the key, as for wfMemcKey().
*
* @return string
* The parameters are the parts of the key, as for wfMemcKey().
*
* @return string
/** Associative array mapping module name to info associative array */
protected $moduleInfos = array();
/** Associative array mapping module name to info associative array */
protected $moduleInfos = array();
/** Associative array mapping framework ids to a list of names of test suite modules */
/** like array( 'qunit' => array( 'mediawiki.tests.qunit.suites', 'ext.foo.tests', .. ), .. ) */
protected $testModuleNames = array();
/** Associative array mapping framework ids to a list of names of test suite modules */
/** like array( 'qunit' => array( 'mediawiki.tests.qunit.suites', 'ext.foo.tests', .. ), .. ) */
protected $testModuleNames = array();
public function getModuleNames() {
return array_keys( $this->moduleInfos );
}
public function getModuleNames() {
return array_keys( $this->moduleInfos );
}
/**
* Get a list of test module names for one (or all) frameworks.
* If the given framework id is unknkown, or if the in-object variable is not an array,
/**
* Get a list of test module names for one (or all) frameworks.
* If the given framework id is unknkown, or if the in-object variable is not an array,
* NOTE: The mtime of the module's messages is NOT automatically included.
* If you want this to happen, you'll need to call getMsgBlobMtime()
* yourself and take its result into consideration.
* NOTE: The mtime of the module's messages is NOT automatically included.
* If you want this to happen, you'll need to call getMsgBlobMtime()
* yourself and take its result into consideration.
* @param $context ResourceLoaderContext: Context object
* @return Integer: UNIX timestamp
*/
* @param $context ResourceLoaderContext: Context object
* @return Integer: UNIX timestamp
*/
* @return String: Name of group
*/
public function getGroup() {
* @return String: Name of group
*/
public function getGroup() {
'MediaWiki:Print.css' => array( 'type' => 'style', 'media' => 'print' ),
);
if ( $wgHandheldStyle ) {
'MediaWiki:Print.css' => array( 'type' => 'style', 'media' => 'print' ),
);
if ( $wgHandheldStyle ) {
- $pages['MediaWiki:Handheld.css'] = array(
- 'type' => 'style',
+ $pages['MediaWiki:Handheld.css'] = array(
+ 'type' => 'style',
'media' => 'handheld' );
}
return $pages;
'media' => 'handheld' );
}
return $pages;
* @return String: Name of group
*/
public function getGroup() {
* @return String: Name of group
*/
public function getGroup() {
global $wgUser;
return $this->modifiedTime[$hash] = wfTimestamp( TS_UNIX, $wgUser->getTouched() );
}
global $wgUser;
return $this->modifiedTime[$hash] = wfTimestamp( TS_UNIX, $wgUser->getTouched() );
}
/**
* @param $context ResourceLoaderContext
* @return array
/**
* @param $context ResourceLoaderContext
* @return array