*
* @return bool|int|string
*/
- public static function pickRandom( $weights ){
+ public static function pickRandom( $weights ) {
if ( !is_array( $weights ) || count( $weights ) == 0 ) {
return false;
}
// Calculate the number of items that will be in each hashtable
$counts = array_fill( 0, 256, 0 );
foreach ( $this->hplist as $item ) {
- ++ $counts[ 255 & $item['h'] ];
+ ++ $counts[255 & $item['h']];
}
// Fill in $starts with the *end* indexes
$feedLastmodUnix = wfTimestamp( TS_UNIX, $feedLastmod );
$lastmodUnix = wfTimestamp( TS_UNIX, $lastmod );
- if( $feedAge < $wgFeedCacheTimeout || $feedLastmodUnix > $lastmodUnix) {
+ if( $feedAge < $wgFeedCacheTimeout || $feedLastmodUnix > $lastmodUnix ) {
wfDebug( "RC: loading feed from cache ($key; $feedLastmod; $lastmod)...\n" );
if ( $feedLastmodUnix < $lastmodUnix ) {
$wgOut->setLastModified( $feedLastmod ); // bug 21916
krsort( $userlinks );
asort( $userlinks );
$users = array();
- foreach( $userlinks as $userlink => $count) {
+ foreach( $userlinks as $userlink => $count ) {
$text = $userlink;
$text .= $this->getLanguage()->getDirMark();
if( $count > 1 ) {
// Append additional characters
$letters = array_merge( $letters, self::$tailoringFirstLetters[$this->locale] );
// Remove unnecessary ones, if any
- if ( isset( self::$tailoringFirstLetters[ '-' . $this->locale ] ) ) {
- $letters = array_diff( $letters, self::$tailoringFirstLetters[ '-' . $this->locale ] );
+ if ( isset( self::$tailoringFirstLetters['-' . $this->locale] ) ) {
+ $letters = array_diff( $letters, self::$tailoringFirstLetters['-' . $this->locale] );
}
} else {
$letters = wfGetPrecompiledData( "first-letters-{$this->locale}.ser" );
define( 'LIST_COMMA', 0 );
define( 'LIST_AND', 1 );
define( 'LIST_SET', 2 );
-define( 'LIST_NAMES', 3);
-define( 'LIST_OR', 4);
+define( 'LIST_NAMES', 3 );
+define( 'LIST_OR', 4 );
/**@}*/
/**
return null; // Just silently ignore
}
- if ( !array_key_exists( $name, $wgExceptionHooks ) || !is_array( $wgExceptionHooks[ $name ] ) ) {
+ if ( !array_key_exists( $name, $wgExceptionHooks ) || !is_array( $wgExceptionHooks[$name] ) ) {
return null;
}
- $hooks = $wgExceptionHooks[ $name ];
+ $hooks = $wgExceptionHooks[$name];
$callargs = array_merge( array( $this ), $args );
foreach ( $hooks as $hook ) {
'</p><p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ) .
"</p>\n";
} else {
- return
- "<div class=\"errorbox\">" .
+ return "<div class=\"errorbox\">" .
'[' . $this->getLogId() . '] ' .
gmdate( 'Y-m-d H:i:s' ) .
": Fatal exception of type " . get_class( $this ) . "</div>\n" .
foreach ( $wgContLang->getFormattedNamespaces() as $ns => $title ) {
$spaces .= ' ' .
Xml::element( 'namespace',
- array( 'key' => $ns,
- 'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
+ array(
+ 'key' => $ns,
+ 'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
), $title ) . "\n";
}
$spaces .= " </namespaces>";
*/
function wfFixSessionID() {
// If the cookie or session id is already set we already have a session and should abort
- if ( isset( $_COOKIE[ session_name() ] ) || session_id() ) {
+ if ( isset( $_COOKIE[session_name()] ) || session_id() ) {
return;
}
*/
public function setDisplayFormat( $format ) {
if ( !in_array( $format, $this->availableDisplayFormats ) ) {
- throw new MWException ( 'Display format must be one of ' . print_r( $this->availableDisplayFormats, true ) );
+ throw new MWException( 'Display format must be one of ' . print_r( $this->availableDisplayFormats, true ) );
}
$this->displayFormat = $format;
return $this;
}
} elseif ( is_string( $hook[0] ) ) {
$func = $hook[0];
- if ( count( $hook ) > 1) {
+ if ( count( $hook ) > 1 ) {
$data = $hook[1];
$have_data = true;
}
$this->parseHeader();
}
- if ( isset( $this->respHeaders[strtolower ( $header ) ] ) ) {
- $v = $this->respHeaders[strtolower ( $header ) ];
+ if ( isset( $this->respHeaders[strtolower( $header )] ) ) {
+ $v = $this->respHeaders[strtolower( $header )];
return $v[count( $v ) - 1];
}
$headers = $this->getResponseHeaders();
//return full url (fix for incorrect but handled relative location)
- if ( isset( $headers[ 'location' ] ) ) {
- $locations = $headers[ 'location' ];
+ if ( isset( $headers['location'] ) ) {
+ $locations = $headers['location'];
$domain = '';
$foundRelativeURI = false;
$countLocations = count( $locations );
for ( $i = $countLocations - 1; $i >= 0; $i-- ) {
- $url = parse_url( $locations[ $i ] );
+ $url = parse_url( $locations[$i] );
if ( isset( $url['host'] ) ) {
- $domain = $url[ 'scheme' ] . '://' . $url[ 'host' ];
+ $domain = $url['scheme'] . '://' . $url['host'];
break; //found correct URI (with host)
} else {
$foundRelativeURI = true;
if ( $foundRelativeURI ) {
if ( $domain ) {
- return $domain . $locations[ $countLocations - 1 ];
+ return $domain . $locations[$countLocations - 1];
} else {
$url = parse_url( $this->url );
- if ( isset($url[ 'host' ]) ) {
- return $url[ 'scheme' ] . '://' . $url[ 'host' ] . $locations[ $countLocations - 1 ];
+ if ( isset( $url['host'] ) ) {
+ return $url['scheme'] . '://' . $url['host'] . $locations[$countLocations - 1];
}
}
} else {
- return $locations[ $countLocations - 1 ];
+ return $locations[$countLocations - 1];
}
}
// If everything went OK, or we received some error code
// get the response body content.
- if ( $this->status->isOK()
- || (int)$this->respStatus >= 300) {
+ if ( $this->status->isOK() || (int)$this->respStatus >= 300 ) {
while ( !feof( $fh ) ) {
$buf = fread( $fh, 8192 );
$limit = 100;
$out = $this->getContext()->getOutput();
- $res = $this->queryImageLinks( $this->getTitle()->getDbKey(), $limit + 1);
+ $res = $this->queryImageLinks( $this->getTitle()->getDbKey(), $limit + 1 );
$rows = array();
$redirects = array();
foreach ( $res as $row ) {
stream_wrapper_register( 'uploadsource', 'UploadSourceAdapter' );
$id = UploadSourceAdapter::registerSource( $source );
- if (defined( 'LIBXML_PARSEHUGE' ) ) {
+ if ( defined( 'LIBXML_PARSEHUGE' ) ) {
$this->reader->open( "uploadsource://$id", null, LIBXML_PARSEHUGE );
} else {
$this->reader->open( "uploadsource://$id" );
$res = $this->mDb->select( 'categorylinks', 'cl_to', array( 'cl_from' => $id ), __METHOD__ );
foreach ( $res as $row ) {
- $cats [] = $row->cl_to;
+ $cats[] = $row->cl_to;
}
$this->mPage->updateCategoryCounts( array(), $cats );
if ( strpos( $callback, '::' ) !== false ) {
// PHP 5.1 cannot use call_user_func( 'Class::Method' )
// It can only handle only call_user_func( array( 'Class', 'Method' ) )
- $callback = explode( '::', $callback, 2);
+ $callback = explode( '::', $callback, 2 );
}
}
$ext = explode( ' ', $ext );
$extension = strtolower( $extension );
- return in_array( $extension, $ext );
+ return in_array( $extension, $ext );
}
/**
$script_type = null;
# detect by shebang
- if ( substr( $head, 0, 2) == "#!" ) {
+ if ( substr( $head, 0, 2 ) == "#!" ) {
$script_type = "ASCII";
- } elseif ( substr( $head, 0, 5) == "\xef\xbb\xbf#!" ) {
+ } elseif ( substr( $head, 0, 5 ) == "\xef\xbb\xbf#!" ) {
$script_type = "UTF-8";
- } elseif ( substr( $head, 0, 7) == "\xfe\xff\x00#\x00!" ) {
+ } elseif ( substr( $head, 0, 7 ) == "\xfe\xff\x00#\x00!" ) {
$script_type = "UTF-16BE";
} elseif ( substr( $head, 0, 7 ) == "\xff\xfe#\x00!" ) {
$script_type = "UTF-16LE";
* 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
*/
- if ( $this->isMatchingExtension( $ext, $mime) ) {
+ if ( $this->isMatchingExtension( $ext, $mime ) ) {
/* A known file extension for an OPC file,
* find the proper mime type for that file extension
*/
} 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" ) {
+ if ( substr( $header, 512, 4 ) == "\xEC\xA5\xC1\x00" ) {
$mime = "application/msword";
}
- switch( substr( $header, 512, 6) ) {
+ switch( substr( $header, 512, 6 ) ) {
case "\xEC\xA5\xC1\x00\x0E\x00":
case "\xEC\xA5\xC1\x00\x1C\x00":
case "\xEC\xA5\xC1\x00\x43\x00":
if ( in_array( $index, self::$alwaysCapitalizedNamespaces ) ) {
return true;
}
- if ( isset( $wgCapitalLinkOverrides[ $index ] ) ) {
+ if ( isset( $wgCapitalLinkOverrides[$index] ) ) {
// $wgCapitalLinkOverrides is explicitly set
- return $wgCapitalLinkOverrides[ $index ];
+ return $wgCapitalLinkOverrides[$index];
}
// Default to the global setting
return $wgCapitalLinks;
* @param $timestamp Mixed: string, or null
* @return Mixed: previous value
*/
- public function setRevisionTimestamp( $timestamp) {
+ public function setRevisionTimestamp( $timestamp ) {
return wfSetVar( $this->mRevisionTimestamp, $timestamp );
}
$defaultModel = ContentHandler::getDefaultModelFor( $title );
$defaultFormat = ContentHandler::getForModelID( $defaultModel )->getDefaultFormat();
- $row[ 'rev_content_model' ] = ( $model === $defaultModel ) ? null : $model;
- $row[ 'rev_content_format' ] = ( $format === $defaultFormat ) ? null : $format;
+ $row['rev_content_model'] = ( $model === $defaultModel ) ? null : $model;
+ $row['rev_content_format'] = ( $format === $defaultFormat ) ? null : $format;
}
$dbw->insert( 'revision', $row, __METHOD__ );
);
if ( $wgContentHandlerUseDB ) {
- $row[ 'content_model' ] = $current->rev_content_model;
- $row[ 'content_format' ] = $current->rev_content_format;
+ $row['content_model'] = $current->rev_content_model;
+ $row['content_format'] = $current->rev_content_format;
}
$revision = new Revision( $row );
if ( $this->isDeleted() && !$this->canViewContent() ) {
return $this->context->msg( 'diff' )->escaped();
} else {
- return
- Linker::link(
+ return Linker::link(
$this->list->title,
$this->context->msg( 'diff' )->escaped(),
array(),
!in_array( 'table', $tagstack ) ) {
$badtag = true;
} elseif ( in_array( $t, $tagstack ) &&
- !isset( $htmlnest [$t ] ) ) {
+ !isset( $htmlnest[$t] ) ) {
$badtag = true;
#Â Is it a self closed htmlpair ? (bug 5487)
} elseif ( $brace == '/>' &&
continue;
}
}
- $text .= '<' . str_replace( '>', '>', $x);
+ $text .= '<' . str_replace( '>', '>', $x );
}
# Close off any remaining tags
- while ( is_array( $tagstack ) && ($t = array_pop( $tagstack )) ) {
+ while ( is_array( $tagstack ) && ( $t = array_pop( $tagstack ) ) ) {
$text .= "</$t>\n";
- if ( $t == 'table' ) { $tagstack = array_pop( $tablestack ); }
+ if ( $t == 'table' ) {
+ $tagstack = array_pop( $tablestack );
+ }
}
} else {
# this might be possible using tidy itself
continue;
}
}
- $text .= '<' . str_replace( '>', '>', $x);
+ $text .= '<' . str_replace( '>', '>', $x );
}
}
wfProfileOut( __METHOD__ );
}
# Allow any attribute beginning with "data-", if in HTML5 mode
- if ( !($wgHtml5 && preg_match( '/^data-/i', $attribute )) && !isset( $whitelist[$attribute] ) ) {
+ if ( !( $wgHtml5 && preg_match( '/^data-/i', $attribute ) ) && !isset( $whitelist[$attribute] ) ) {
continue;
}
if( $matches[1] != '' ) {
return Sanitizer::decodeEntity( $matches[1] );
} elseif( $matches[2] != '' ) {
- return Sanitizer::decodeChar( intval( $matches[2] ) );
+ return Sanitizer::decodeChar( intval( $matches[2] ) );
} elseif( $matches[3] != '' ) {
- return Sanitizer::decodeChar( hexdec( $matches[3] ) );
+ return Sanitizer::decodeChar( hexdec( $matches[3] ) );
}
# Last case should be an ampersand by itself
return $matches[0];
if ( $wgAllowRdfaAttributes ) {
#RDFa attributes as specified in section 9 of http://www.w3.org/TR/2008/REC-rdfa-syntax-20081014
$common = array_merge( $common, array(
- 'about', 'property', 'resource', 'datatype', 'typeof',
+ 'about', 'property', 'resource', 'datatype', 'typeof',
) );
}
if ( $wgHtml5 && $wgAllowMicrodataAttributes ) {
# add HTML5 microdata tags as specified by http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html#the-microdata-model
$common = array_merge( $common, array(
- 'itemid', 'itemprop', 'itemref', 'itemscope', 'itemtype'
+ 'itemid', 'itemprop', 'itemref', 'itemscope', 'itemtype'
) );
}
$block = array_merge( $common, array( 'align' ) );
$tablealign = array( 'align', 'char', 'charoff', 'valign' );
- $tablecell = array( 'abbr',
- 'axis',
- 'headers',
- 'scope',
- 'rowspan',
- 'colspan',
- 'nowrap', # deprecated
- 'width', # deprecated
- 'height', # deprecated
- 'bgcolor' # deprecated
- );
+ $tablecell = array(
+ 'abbr',
+ 'axis',
+ 'headers',
+ 'scope',
+ 'rowspan',
+ 'colspan',
+ 'nowrap', # deprecated
+ 'width', # deprecated
+ 'height', # deprecated
+ 'bgcolor', # deprecated
+ );
# Numbers refer to sections in HTML 4.01 standard describing the element.
# See: http://www.w3.org/TR/html4/
$testGlobalConfigs = array(); // an array containing all the global configs needed for this test
$testResourceFiles = array(); // an array containing all the resource files needed for this test
$callback = $wgSeleniumTestConfigs[$setupTestSuiteName];
- call_user_func_array( $callback, array( &$testIncludes, &$testGlobalConfigs, &$testResourceFiles));
+ call_user_func_array( $callback, array( &$testIncludes, &$testGlobalConfigs, &$testResourceFiles ) );
if ( isset( $testResourceFiles['images'] ) ) {
$testImageZip = $testResourceFiles['images'];
$testGlobalConfigs = array(); // an array containing all the global configs needed for this test
$testResourceFiles = array(); // an array containing all the resource files needed for this test
$callback = $wgSeleniumTestConfigs[$testSuiteName];
- call_user_func_array( $callback, array( &$testIncludes, &$testGlobalConfigs, &$testResourceFiles));
+ call_user_func_array( $callback, array( &$testIncludes, &$testGlobalConfigs, &$testResourceFiles ) );
if ( isset( $testResourceFiles['db'] ) ) {
$testResourceName = getTestResourceNameFromTestSuiteName( $testSuiteName );
* that happens whenever you use a date function without the timezone being
* explicitly set. Inspired by phpMyAdmin's treatment of the problem.
*/
-if ( is_null( $wgLocaltimezone) ) {
+if ( is_null( $wgLocaltimezone ) ) {
wfSuppressWarnings();
$wgLocaltimezone = date_default_timezone_get();
wfRestoreWarnings();
$retval = $thisSetting[$suffix];
}
break;
- } elseif ( array_key_exists( "+$suffix", $thisSetting ) && is_array($thisSetting["+$suffix"]) ) {
+ } elseif ( array_key_exists( "+$suffix", $thisSetting ) && is_array( $thisSetting["+$suffix"] ) ) {
if ( !isset( $retval ) ) {
$retval = array();
}
}
global $wgExternalLinkTarget;
- if ( $wgExternalLinkTarget) {
+ if ( $wgExternalLinkTarget ) {
$extraAttribs['target'] = $wgExternalLinkTarget;
}
} else {
try {
$final = new DateTime( $strtime, new DateTimeZone( 'GMT' ) );
- } catch(Exception $e) {
+ } catch( Exception $e ) {
throw new TimestampException( __METHOD__ . ' Invalid timestamp format.' );
}
*/
public function getSkinFromCssJsSubpage() {
$subpage = explode( '/', $this->mTextform );
- $subpage = $subpage[ count( $subpage ) - 1 ];
+ $subpage = $subpage[count( $subpage ) - 1];
$lastdot = strrpos( $subpage, '.' );
if ( $lastdot === false )
return $subpage; # Never happens: only called for names ending in '.css' or '.js'
return 'passwordtooshort';
} elseif ( $wgContLang->lc( $password ) == $wgContLang->lc( $this->mName ) ) {
return 'password-name-match';
- } elseif ( isset( $blockedLogins[ $this->getName() ] ) && $password == $blockedLogins[ $this->getName() ] ) {
+ } elseif ( isset( $blockedLogins[$this->getName()] ) && $password == $blockedLogins[$this->getName()] ) {
return 'password-login-forbidden';
} else {
//it seems weird returning true here, but this is because of the
// Set the user limit key
if ( $userLimit !== false ) {
wfDebug( __METHOD__ . ": effective user limit: $userLimit\n" );
- $keys[ wfMemcKey( 'limiter', $action, 'user', $id ) ] = $userLimit;
+ $keys[wfMemcKey( 'limiter', $action, 'user', $id )] = $userLimit;
}
$triggered = false;
}
// Re-map numeric keys of AddToSelf/RemoveFromSelf to the 'user' key for backwards compatibility
- if( empty( $wgGroupsAddToSelf['user']) || $wgGroupsAddToSelf['user'] !== true ) {
+ if( empty( $wgGroupsAddToSelf['user'] ) || $wgGroupsAddToSelf['user'] !== true ) {
foreach( $wgGroupsAddToSelf as $key => $value ) {
if( is_int( $key ) ) {
$wgGroupsAddToSelf['user'][] = $value;
}
}
- if( empty( $wgGroupsRemoveFromSelf['user']) || $wgGroupsRemoveFromSelf['user'] !== true ) {
+ if( empty( $wgGroupsRemoveFromSelf['user'] ) || $wgGroupsRemoveFromSelf['user'] !== true ) {
foreach( $wgGroupsRemoveFromSelf as $key => $value ) {
if( is_int( $key ) ) {
$wgGroupsRemoveFromSelf['user'][] = $value;
$ids = array_map( 'intval', (array)$ids ); // paranoia
if ( !$ids ) {
// Database::select() doesn't like empty arrays
- return new ArrayIterator(array());
+ return new ArrayIterator( array() );
}
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( 'user', '*', array( 'user_id' => $ids ),
}
$matches = self::getPathInfo( 'title' );
- foreach( $matches as $key => $val) {
+ foreach( $matches as $key => $val ) {
$this->data[$key] = $_GET[$key] = $_REQUEST[$key] = $val;
}
}
* @return Boolean
*/
public function checkSessionCookie() {
- return isset( $_COOKIE[ session_name() ] );
+ return isset( $_COOKIE[session_name()] );
}
/**
if ( function_exists( 'apache_request_headers' ) ) {
foreach ( apache_request_headers() as $tempName => $tempValue ) {
- $this->headers[ strtoupper( $tempName ) ] = $tempValue;
+ $this->headers[strtoupper( $tempName )] = $tempValue;
}
} else {
foreach ( $_SERVER as $name => $value ) {
$curIP = IP::canonicalize( $curIP );
if ( wfIsTrustedProxy( $curIP ) ) {
if ( isset( $ipchain[$i + 1] ) ) {
- if ( $wgUsePrivateIPs || IP::isPublic( $ipchain[$i + 1 ] ) ) {
+ if ( $wgUsePrivateIPs || IP::isPublic( $ipchain[$i + 1] ) ) {
$ip = $ipchain[$i + 1];
}
}
* @return String: URL
*/
public function getFullUrl( $page ) {
- return
- $this->mServer .
+ return $this->mServer .
$this->getLocalUrl( $page );
}
}
);
if ( $wgContentHandlerUseDB ) {
- $row[ 'page_content_model' ] = $revision->getContentModel();
+ $row['page_content_model'] = $revision->getContentModel();
}
$dbw->update( 'page',
);
if ( $wgContentHandlerUseDB ) {
- $row[ 'ar_content_model' ] = 'rev_content_model';
- $row[ 'ar_content_format' ] = 'rev_content_format';
+ $row['ar_content_model'] = 'rev_content_model';
+ $row['ar_content_format'] = 'rev_content_format';
}
$dbw->insertSelect( 'archive', array( 'page', 'revision' ),
$options = self::option( $other, 'other', $selected === 'other' );
- foreach ( explode( "\n", $list ) as $option) {
+ foreach ( explode( "\n", $list ) as $option ) {
$value = trim( $option );
if ( $value == '' ) {
continue;
- } elseif ( substr( $value, 0, 1) == '*' && substr( $value, 1, 1) != '*' ) {
+ } elseif ( substr( $value, 0, 1 ) == '*' && substr( $value, 1, 1 ) != '*' ) {
// A new group is starting ...
$value = trim( substr( $value, 1 ) );
if( $optgroup ) $options .= self::closeElement( 'optgroup' );
$options .= self::openElement( 'optgroup', array( 'label' => $value ) );
$optgroup = true;
- } elseif ( substr( $value, 0, 2) == '**' ) {
+ } elseif ( substr( $value, 0, 2 ) == '**' ) {
// groupmember
$value = trim( substr( $value, 2 ) );
$options .= self::option( $value, $value, $selected === $value );
public function getWatchlistUser( $params ) {
if ( !is_null( $params['owner'] ) && !is_null( $params['token'] ) ) {
$user = User::newFromName( $params['owner'], false );
- if ( !($user && $user->getId()) ) {
+ if ( !( $user && $user->getId() ) ) {
$this->dieUsage( 'Specified user does not exist', 'bad_wlowner' );
}
$token = $user->getOption( 'watchlisttoken' );
public function execute() {
$params = $this->extractRequestParams();
- $rotation = $params[ 'rotation' ];
+ $rotation = $params['rotation'];
$user = $this->getUser();
$pageSet = $this->getPageSet();
continue;
}
$ext = strtolower( pathinfo( "$srcPath", PATHINFO_EXTENSION ) );
- $tmpFile = TempFSFile::factory( 'rotate_', $ext);
+ $tmpFile = TempFSFile::factory( 'rotate_', $ext );
$dstPath = $tmpFile->getPath();
$err = $handler->rotate( $file, array(
"srcPath" => $srcPath,
"dstPath" => $dstPath,
- "rotation"=> $rotation
+ "rotation" => $rotation
) );
if ( !$err ) {
$comment = wfMessage( 'rotate-comment' )->numParams( $rotation )->text();
*/
protected function checkPermissions( $user, $title ) {
$permissionErrors = array_merge(
- $title->getUserPermissionsErrors( 'edit' , $user ),
- $title->getUserPermissionsErrors( 'upload' , $user )
+ $title->getUserPermissionsErrors( 'edit', $user ),
+ $title->getUserPermissionsErrors( 'upload', $user )
);
if ( $permissionErrors ) {
'import' => 'ApiImport',
'userrights' => 'ApiUserrights',
'options' => 'ApiOptions',
- 'imagerotate' =>'ApiImageRotate',
+ 'imagerotate' => 'ApiImageRotate',
);
/**
}
// Log the request whether or not there was an error
- $this->logRequest( microtime( true ) - $t);
+ $this->logRequest( microtime( true ) - $t );
// Send cache headers after any code which might generate an error, to
// avoid sending public cache headers for errors.
}
foreach ( $this->mRequestedPageFields as $fieldName => &$fieldValues ) {
- $fieldValues[$pageId] = $row-> $fieldName;
+ $fieldValues[$pageId] = $row->$fieldName;
}
}
if ( $dir == 'newer' ) {
$this->addWhereRange( 'cat_pages', 'newer', $min, $max );
} else {
- $this->addWhereRange( 'cat_pages', 'older', $max, $min);
+ $this->addWhereRange( 'cat_pages', 'older', $max, $min );
}
if ( isset( $params['prefix'] ) ) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
// We need to keep the parent page of this redir in
if ( $this->hasNS ) {
- $parentID = $this->pageMap[$row-> { $this->bl_ns } ][$row-> { $this->bl_title } ];
+ $parentID = $this->pageMap[$row->{$this->bl_ns}][$row->{$this->bl_title}];
} else {
- $parentID = $this->pageMap[NS_FILE][$row-> { $this->bl_title } ];
+ $parentID = $this->pageMap[NS_FILE][$row->{$this->bl_title}];
}
$this->continueStr = $this->getContinueRedirStr( $parentID, $row->page_id );
break;
if ( $row->page_is_redirect ) {
$a['redirect'] = '';
}
- $ns = $this->hasNS ? $row-> { $this->bl_ns } : NS_FILE;
- $parentID = $this->pageMap[$ns][$row-> { $this->bl_title } ];
+ $ns = $this->hasNS ? $row->{$this->bl_ns} : NS_FILE;
+ $parentID = $this->pageMap[$ns][$row->{$this->bl_title}];
// Put all the results in an array first
$this->resultArr[$parentID]['redirlinks'][] = $a;
$this->getResult()->setIndexedTagName( $this->resultArr[$parentID]['redirlinks'], $this->bl_code );
$this->addTables( 'ipblocks' );
$this->addFields( 'ipb_auto' );
- $this->addFieldsIf ( 'ipb_id', $fld_id );
+ $this->addFieldsIf( 'ipb_id', $fld_id );
$this->addFieldsIf( array( 'ipb_address', 'ipb_user' ), $fld_user || $fld_userid );
$this->addFieldsIf( 'ipb_by_text', $fld_by );
$this->addFieldsIf( 'ipb_by', $fld_byid );
' variables - Returns a list of variable IDs',
' protocols - Returns a list of protocols that are allowed in external links.',
),
- 'filteriw' => 'Return only local or only nonlocal entries of the interwiki map',
+ 'filteriw' => 'Return only local or only nonlocal entries of the interwiki map',
'showalldb' => 'List all database servers, not just the one lagging the most',
'numberingroup' => 'Lists the number of users in user groups',
'inlanguagecode' => 'Language code for localised language names (best effort, use CLDR extension)',
// implementation exists, so adapt to Squid
$htcpPacket = pack( 'nxxnCxNxxa*n',
$htcpLen, $htcpDataLen, $htcpOpCLR,
- $htcpTransID, $htcpSpecifier, 2);
+ $htcpTransID, $htcpSpecifier, 2 );
// Send out
wfDebug( "Purging URL $url via HTCP\n" );
$contentObjects[$k] = $v;
$v = $v->serialize();
- $contentTexts[ $k ] = $v;
- $args[ $k ] = $v;
+ $contentTexts[$k] = $v;
+ $args[$k] = $v;
}
}
foreach ( $contentTexts as $k => $orig ) {
/* @var Content $content */
- $modified = $args[ $k ];
+ $modified = $args[$k];
$content = $contentObjects[$k];
if ( $modified !== $orig ) {
$content = $content->getContentHandler()->unserializeContent( $modified );
}
- $args[ $k ] = $content;
+ $args[$k] = $content;
}
return $ok;
static function generalizeSQL( $sql ) {
# This does the same as the regexp below would do, but in such a way
# as to avoid crashing php on some large strings.
- # $sql = preg_replace ( "/'([^\\\\']|\\\\.)*'|\"([^\\\\\"]|\\\\.)*\"/", "'X'", $sql);
+ # $sql = preg_replace( "/'([^\\\\']|\\\\.)*'|\"([^\\\\\"]|\\\\.)*\"/", "'X'", $sql );
- $sql = str_replace ( "\\\\", '', $sql );
- $sql = str_replace ( "\\'", '', $sql );
- $sql = str_replace ( "\\\"", '', $sql );
- $sql = preg_replace ( "/'.*'/s", "'X'", $sql );
- $sql = preg_replace ( '/".*"/s', "'X'", $sql );
+ $sql = str_replace( "\\\\", '', $sql );
+ $sql = str_replace( "\\'", '', $sql );
+ $sql = str_replace( "\\\"", '', $sql );
+ $sql = preg_replace( "/'.*'/s", "'X'", $sql );
+ $sql = preg_replace( '/".*"/s', "'X'", $sql );
# All newlines, tabs, etc replaced by single space
- $sql = preg_replace ( '/\s+/', ' ', $sql );
+ $sql = preg_replace( '/\s+/', ' ', $sql );
# All numbers => N
- $sql = preg_replace ( '/-?[0-9]+/s', 'N', $sql );
+ $sql = preg_replace( '/-?[0-9]+/s', 'N', $sql );
return $sql;
}
}
// MSSQL doesn't have EXTRACT(epoch FROM XXX)
- if ( preg_match('#\bEXTRACT\s*?\(\s*?EPOCH\s+FROM\b#i', $sql, $matches ) ) {
+ if ( preg_match( '#\bEXTRACT\s*?\(\s*?EPOCH\s+FROM\b#i', $sql, $matches ) ) {
// This is same as UNIX_TIMESTAMP, we need to calc # of seconds from 1970
$sql = str_replace( $matches[0], "DATEDIFF(s,CONVERT(datetime,'1/1/1970'),", $sql );
}
$retErrors = sqlsrv_errors( SQLSRV_ERR_ALL );
if ( $retErrors != null ) {
foreach ( $retErrors as $arrError ) {
- $strRet .= "SQLState: " . $arrError[ 'SQLSTATE'] . "\n";
- $strRet .= "Error Code: " . $arrError[ 'code'] . "\n";
- $strRet .= "Message: " . $arrError[ 'message'] . "\n";
+ $strRet .= "SQLState: " . $arrError['SQLSTATE'] . "\n";
+ $strRet .= "Error Code: " . $arrError['code'] . "\n";
+ $strRet .= "Message: " . $arrError['message'] . "\n";
}
} else {
$strRet = "No errors found";
// if we have an identity column
if( $identity ) {
// iterate through
- foreach ($a as $k => $v ) {
+ foreach ( $a as $k => $v ) {
if ( $k == $identity ) {
- if( !is_null($v) ) {
+ if( !is_null( $v ) ) {
// there is a value being passed to us, we need to turn on and off inserted identity
$sqlPre = "SET IDENTITY_INSERT $table ON;";
$sqlPost = ";SET IDENTITY_INSERT $table OFF;";
} elseif ( $ret != null ) {
// remember number of rows affected
$this->mAffectedRows = sqlsrv_rows_affected( $ret );
- if ( !is_null($identity) ) {
+ if ( !is_null( $identity ) ) {
// then we want to get the identity column value we were assigned and save it off
$row = sqlsrv_fetch_object( $ret );
$this->mInsertId = $row->$identity;
}
function __destruct() {
- if ($this->mOpened) {
+ if ( $this->mOpened ) {
wfSuppressWarnings();
$this->close();
wfRestoreWarnings();
$endArray[] = strtoupper( $prefix . 'PAGE' );
$endArray[] = strtoupper( $prefix . 'IMAGE' );
$fixedOrderTabs = $endArray;
- while ( ($row = $result->fetchRow()) !== false ) {
+ while ( ( $row = $result->fetchRow() ) !== false ) {
if ( !in_array( $row['table_name'], $fixedOrderTabs ) )
$endArray[] = $row['table_name'];
}
$conds2 = array();
foreach ( $conds as $col => $val ) {
if ( is_array( $val ) ) {
- $conds2[$col] = $this->wrapConditionsForWhere ( $table, $val, $col );
+ $conds2[$col] = $this->wrapConditionsForWhere( $table, $val, $col );
} else {
if ( is_numeric( $col ) && $parentCol != null ) {
- $this->wrapFieldForWhere ( $table, $parentCol, $val );
+ $this->wrapFieldForWhere( $table, $parentCol, $val );
} else {
- $this->wrapFieldForWhere ( $table, $col, $val );
+ $this->wrapFieldForWhere( $table, $col, $val );
}
$conds2[$col] = $val;
}
$flags |= DBO_COMPRESS;
}
- $servers = array(array(
+ $servers = array( array(
'host' => $wgDBserver,
'user' => $wgDBuser,
'password' => $wgDBpassword,
reset( $seps );
$pt1 = $seps[0];
while ( $pt2 = next( $seps ) ) {
- $this->_compareseq ( $pt1[0], $pt2[0], $pt1[1], $pt2[1] );
+ $this->_compareseq( $pt1[0], $pt2[0], $pt1[1], $pt2[1] );
$pt1 = $pt2;
}
}
* @return bool Path container should have dir changes pushed to all backends
*/
protected function replicateContainerDirChanges( $path ) {
- list( , $shortCont, ) = self::splitStoragePath( $path );
+ list( , $shortCont, ) = self::splitStoragePath( $path );
return !in_array( $shortCont, $this->noPushDirConts );
}
* @param $version integer version number.
* @return Array containing metadata, or what was passed to it on fail (unserializing if not array)
*/
- public function convertMetadataVersion($metadata, $version) {
+ public function convertMetadataVersion( $metadata, $version ) {
$handler = $this->getHandler();
if ( !is_array( $metadata ) ) {
// Just to make the return type consistent
if ( $mime === "unknown/unknown" ) {
return false; #unknown type, not trusted
}
- if ( in_array( $mime, $wgTrustedMediaFormats) ) {
+ if ( in_array( $mime, $wgTrustedMediaFormats ) ) {
return true;
}
? count( $data['query']['redirects'] ) - 1
: -1;
if( $lastRedirect >= 0 ) {
- $newtitle = Title::newFromText( $data['query']['redirects'][$lastRedirect]['to']);
+ $newtitle = Title::newFromText( $data['query']['redirects'][$lastRedirect]['to'] );
$img = new self( $newtitle, $repo, $info, true );
if( $img ) {
$img->redirectedFrom( $title->getDBkey() );
}
$ret = array();
foreach( $metadata as $meta ) {
- $ret[ $meta['name'] ] = self::parseMetadata( $meta['value'] );
+ $ret[$meta['name']] = self::parseMetadata( $meta['value'] );
}
return $ret;
}
* @return String
*/
public function getInstallUserBox() {
- return
- Html::openElement( 'fieldset' ) .
+ return Html::openElement( 'fieldset' ) .
Html::element( 'legend', array(), wfMessage( 'config-db-install-account' )->text() ) .
$this->getTextBox( '_InstallUser', 'config-db-username', array( 'dir' => 'ltr' ), $this->parent->getHelpBox( 'config-db-install-username' ) ) .
$this->getPasswordBox( '_InstallPassword', 'config-db-password', array( 'dir' => 'ltr' ), $this->parent->getHelpBox( 'config-db-install-password' ) ) .
* @param string $fieldName The field to be modified
* @param string $sqlPath The path to the SQL change path
*/
- public function modifyExtensionField( $tableName, $fieldName, $sqlPath) {
+ public function modifyExtensionField( $tableName, $fieldName, $sqlPath ) {
$this->extensionUpdates[] = array( 'modifyField', $tableName, $fieldName, $sqlPath, true );
}
}
# Try the current value of LANG.
- if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
+ if ( isset( $candidatesByLocale[getenv( 'LANG' )] ) ) {
$this->setVar( 'wgShellLocale', getenv( 'LANG' ) );
return true;
}
// then adding any callbacks that wanted to attach after a given step
foreach( $coreInstallSteps as $step ) {
$this->installSteps[] = $step;
- if( isset( $this->extraInstallSteps[ $step['name'] ] ) ) {
+ if( isset( $this->extraInstallSteps[$step['name']] ) ) {
$this->installSteps = array_merge(
$this->installSteps,
- $this->extraInstallSteps[ $step['name'] ]
+ $this->extraInstallSteps[$step['name']]
);
}
}
$status = Status::newGood();
try {
$page = WikiPage::factory( Title::newMainPage() );
- $content = new WikitextContent (
+ $content = new WikitextContent(
wfMessage( 'mainpagetext' )->inContentLanguage()->text() . "\n\n" .
wfMessage( 'mainpagedocfooter' )->inContentLanguage()->text()
);
EDIT_NEW,
false,
User::newFromName( 'MediaWiki default' ) );
- } catch (MWException $e) {
+ } catch ( MWException $e ) {
//using raw, because $wgShowExceptionDetails can not be set yet
$status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
}
case 'db':
case 'memcached':
case 'accel':
- $cacheType = 'CACHE_' . strtoupper( $this->values['wgMainCacheType']);
+ $cacheType = 'CACHE_' . strtoupper( $this->values['wgMainCacheType'] );
break;
case 'none':
default:
* @return string
*/
public function getConnectForm() {
- return
- $this->getTextBox( 'wgDBserver', 'config-db-host', array(), $this->parent->getHelpBox( 'config-db-host-help' ) ) .
+ return $this->getTextBox( 'wgDBserver', 'config-db-host', array(), $this->parent->getHelpBox( 'config-db-host-help' ) ) .
Html::openElement( 'fieldset' ) .
Html::element( 'legend', array(), wfMessage( 'config-db-wiki-settings' )->text() ) .
$this->getTextBox( 'wgDBname', 'config-db-name', array( 'dir' => 'ltr' ), $this->parent->getHelpBox( 'config-db-name-help' ) ) .
if ( $this->getVar( 'wgDBserver' ) == 'localhost' ) {
$this->parent->setVar( 'wgDBserver', '' );
}
- return
- $this->getTextBox( 'wgDBserver', 'config-db-host-oracle', array(), $this->parent->getHelpBox( 'config-db-host-oracle-help' ) ) .
+ return $this->getTextBox( 'wgDBserver', 'config-db-host-oracle', array(), $this->parent->getHelpBox( 'config-db-host-oracle-help' ) ) .
Html::openElement( 'fieldset' ) .
Html::element( 'legend', array(), wfMessage( 'config-db-wiki-settings' )->text() ) .
$this->getTextBox( 'wgDBprefix', 'config-db-prefix' ) .
}
function getConnectForm() {
- return
- $this->getTextBox( 'wgDBserver', 'config-db-host', array(), $this->parent->getHelpBox( 'config-db-host-help' ) ) .
+ return $this->getTextBox( 'wgDBserver', 'config-db-host', array(), $this->parent->getHelpBox( 'config-db-host-help' ) ) .
$this->getTextBox( 'wgDBport', 'config-db-port' ) .
Html::openElement( 'fieldset' ) .
Html::element( 'legend', array(), wfMessage( 'config-db-wiki-settings' )->text() ) .
$this->getVar( 'wgDBserver' ),
$user,
$password,
- $dbName);
+ $dbName
+ );
$status->value = $db;
} catch ( DBConnectionError $e ) {
$status->fatal( 'config-connection-error', $e->getMessage() );
}
}
- protected function changeNullableField( $table, $field, $null) {
+ protected function changeNullableField( $table, $field, $null ) {
$fi = $this->db->fieldInfo( $table, $field );
if ( is_null( $fi ) ) {
$this->output( "...ERROR: expected column $table.$field to exist\n" );
public function getFingerprint() {
// Get the base URL of the installation
$url = $this->request->getFullRequestURL();
- if ( preg_match( '!^(.*\?)!', $url, $m) ) {
+ if ( preg_match( '!^(.*\?)!', $url, $m ) ) {
// Trim query string
$url = $m[1];
}
$attributes['for'] = $forId;
}
- return
- "<div class=\"config-block\">\n" .
+ return "<div class=\"config-block\">\n" .
" <div class=\"config-block-label\">\n" .
Xml::tags( 'label',
$attributes,
if ( !isset( $params['help'] ) ) {
$params['help'] = "";
}
- return
- $this->label(
+ return $this->label(
$params['label'],
$params['controlName'],
Xml::input(
if ( !isset( $params['help'] ) ) {
$params['help'] = "";
}
- return
- $this->label(
+ return $this->label(
$params['label'],
$params['controlName'],
Xml::textarea(
$labelText = $this->parse( wfMessage( $params['label'] )->text() );
}
- return
- "<div class=\"config-input-check\">\n" .
+ return "<div class=\"config-input-check\">\n" .
$params['help'] .
"<label>\n" .
Xml::check(
}
$wrapperStyle = ($this->getVar( '_LicenseCode' ) == 'cc-choose') ? '' : 'display: none';
- return
- "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"$wrapperStyle\">\n" .
+ return "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"$wrapperStyle\">\n" .
Html::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
"</div>\n";
}
// If you change this height, also change it in config.css
$expandJs = str_replace( '$1', '54em', $js );
$reduceJs = str_replace( '$1', '70px', $js );
- return
- '<p>'.
+ return '<p>'.
Html::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
'  ' .
htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
// JS appears the only method that works consistently with IE7+
$this->addHtml( "\n<script type=\"" . $GLOBALS['wgJsMimeType'] .
'">jQuery( document ).ready( function() { document.location=' .
- Xml::encodeJsVar( $lsUrl) . "; } );</script>\n" );
+ Xml::encodeJsVar( $lsUrl ) . "; } );</script>\n" );
} else {
$this->parent->request->response()->header( "Refresh: 0;url=$lsUrl" );
}
fclose( $f );
// Extract binary form of width and height from the header
- $w = substr( $header, 18, 4);
- $h = substr( $header, 22, 4);
+ $w = substr( $header, 18, 4 );
+ $h = substr( $header, 22, 4 );
// Convert the unsigned long 32 bits (little endian):
try {
public function rotate( $file, $params ) {
global $wgImageMagickConvertCommand;
- $rotation = ( $params[ 'rotation' ] + $this->getRotation( $file ) ) % 360;
+ $rotation = ( $params['rotation'] + $this->getRotation( $file ) ) % 360;
$scene = false;
$scaler = self::getScalerType( null, false );
switch ( $scaler ) {
case 'im':
$cmd = wfEscapeShellArg( $wgImageMagickConvertCommand ) . " " .
- wfEscapeShellArg( $this->escapeMagickInput( $params[ 'srcPath' ], $scene ) ) .
+ wfEscapeShellArg( $this->escapeMagickInput( $params['srcPath'], $scene ) ) .
" -rotate -$rotation " .
- wfEscapeShellArg( $this->escapeMagickOutput( $params[ 'dstPath' ] ) ) . " 2>&1";
+ wfEscapeShellArg( $this->escapeMagickOutput( $params['dstPath'] ) ) . " 2>&1";
wfDebug( __METHOD__ . ": running ImageMagick: $cmd\n" );
wfProfileIn( 'convert' );
$retval = 0;
$retval = '';
$txt = wfShellExec( $cmd, $retval, array(), array( 'memory' => self::DJVUTXT_MEMORY_LIMIT ) );
wfProfileOut( 'djvutxt' );
- if( $retval == 0) {
+ if( $retval == 0 ) {
# Strip some control characters
$txt = preg_replace( "/[\013\035\037]/", "", $txt );
$reg = <<<EOR
// Treat Software as a special case because in can contain
// an array of (SoftwareName, Version).
- if (isset( $metadata['Software'] )
+ if ( isset( $metadata['Software'] )
&& is_array( $metadata['Software'] )
- && is_array( $metadata['Software'][0])
+ && is_array( $metadata['Software'][0] )
&& isset( $metadata['Software'][0][0] )
- && isset( $metadata['Software'][0][1])
+ && isset( $metadata['Software'][0][1] )
) {
$metadata['Software'] = $metadata['Software'][0][0] . ' (Version '
. $metadata['Software'][0][1] . ')';
}
//This is done differently as the tag is an array.
- if ( $tag == 'GPSTimeStamp' && count( $vals ) === 3) {
+ if ( $tag == 'GPSTimeStamp' && count( $vals ) === 3 ) {
//hour min sec array
$h = explode( '/', $vals[0] );
$urgency = 'high';
} elseif ( $val == 5 ) {
$urgency = 'normal';
- } elseif ( $val <= 8 && $val > 5) {
+ } elseif ( $val <= 8 && $val > 5 ) {
$urgency = 'low';
}
$width = intval( $width );
# Sanity check $width
- if( $width <= 0) {
+ if( $width <= 0 ) {
wfDebug( __METHOD__ . ": Invalid destination width: $width\n" );
return false;
}
public function rotate( $file, $params ) {
global $wgJpegTran;
- $rotation = ( $params[ 'rotation' ] + $this->getRotation( $file ) ) % 360;
+ $rotation = ( $params['rotation'] + $this->getRotation( $file ) ) % 360;
- if( $wgJpegTran && is_file( $wgJpegTran ) ){
+ if( $wgJpegTran && is_file( $wgJpegTran ) ) {
$cmd = wfEscapeShellArg( $wgJpegTran ) .
" -rotate " . wfEscapeShellArg( $rotation ) .
- " -outfile " . wfEscapeShellArg( $params[ 'dstPath' ] ) .
- " " . wfEscapeShellArg( $params[ 'srcPath' ] ) . " 2>&1";
- wfDebug( __METHOD__ . ": running jpgtran: $cmd\n" );
- wfProfileIn( 'jpegtran' );
- $retval = 0;
- $err = wfShellExec( $cmd, $retval, $env );
- wfProfileOut( 'jpegtran' );
+ " -outfile " . wfEscapeShellArg( $params['dstPath'] ) .
+ " " . wfEscapeShellArg( $params['srcPath'] ) . " 2>&1";
+ wfDebug( __METHOD__ . ": running jpgtran: $cmd\n" );
+ wfProfileIn( 'jpegtran' );
+ $retval = 0;
+ $err = wfShellExec( $cmd, $retval, $env );
+ wfProfileOut( 'jpegtran' );
if ( $retval !== 0 ) {
$this->logErrorForExternalProcess( $retval, $err, $cmd );
return new MediaTransformError( 'thumbnail_error', 0, 0, $err );
static function getMetadataVersion() {
$version = Array( '2' ); // core metadata version
wfRunHooks( 'GetMetadataVersion', Array( &$version ) );
- return implode( ';', $version);
+ return implode( ';', $version );
}
/**
continue;
}
}
- $finalKeyword = self::$text_chunks[ $items[1] ];
- $text[ $finalKeyword ][ $items[3] ] = $items[5];
- $text[ $finalKeyword ]['_type'] = 'lang';
+ $finalKeyword = self::$text_chunks[$items[1]];
+ $text[$finalKeyword][$items[3]] = $items[5];
+ $text[$finalKeyword]['_type'] = 'lang';
} else {
// Error reading iTXt chunk
throw new Exception( __METHOD__ . ": Read error (error with iconv)" );
}
- $finalKeyword = self::$text_chunks[ $keyword ];
- $text[ $finalKeyword ][ 'x-default' ] = $content;
- $text[ $finalKeyword ]['_type'] = 'lang';
+ $finalKeyword = self::$text_chunks[$keyword];
+ $text[$finalKeyword]['x-default'] = $content;
+ $text[$finalKeyword]['_type'] = 'lang';
} elseif ( $chunk_type == 'zTXt' ) {
if ( function_exists( 'gzuncompress' ) ) {
throw new Exception( __METHOD__ . ": Read error (error with iconv)" );
}
- $finalKeyword = self::$text_chunks[ $keyword ];
- $text[ $finalKeyword ][ 'x-default' ] = $content;
- $text[ $finalKeyword ]['_type'] = 'lang';
+ $finalKeyword = self::$text_chunks[$keyword];
+ $text[$finalKeyword]['x-default'] = $content;
+ $text[$finalKeyword]['_type'] = 'lang';
} else {
wfDebug( __METHOD__ . " Cannot decompress zTXt chunk due to lack of zlib. Skipping." );
* @param string $metafield that we will fill with the result
*/
private function readField( $name, $metafield=null ) {
- $this->debug ( "Read field $metafield" );
+ $this->debug( "Read field $metafield" );
if( !$metafield || $this->reader->nodeType != XmlReader::ELEMENT ) {
return;
}
* @throws MWException
*/
private function readXml( $metafield=null ) {
- $this->debug ( "Read top level metadata" );
+ $this->debug( "Read top level metadata" );
if( !$metafield || $this->reader->nodeType != XmlReader::ELEMENT ) {
return;
}
* @param string $name of the element that we are reading from
*/
private function animateFilter( $name ) {
- $this->debug ( "animate filter for tag $name" );
+ $this->debug( "animate filter for tag $name" );
if( $this->reader->nodeType != XmlReader::ELEMENT ) {
return;
}
if ( $elm !== self::NS_RDF . ' li' ) {
throw new MWException( __METHOD__ . " <rdf:li> expected but got $elm." );
}
- if ( !isset( $attribs[ self::NS_XML . ' lang'] )
- || !preg_match( '/^[-A-Za-z0-9]{2,}$/D', $attribs[ self::NS_XML . ' lang' ] ) )
+ if ( !isset( $attribs[self::NS_XML . ' lang'] )
+ || !preg_match( '/^[-A-Za-z0-9]{2,}$/D', $attribs[self::NS_XML . ' lang'] ) )
{
throw new MWException( __METHOD__
. " <rdf:li> did not contain, or has invalid xml:lang attribute in lang alternative" );
}
// Lang is case-insensitive.
- $this->itemLang = strtolower( $attribs[ self::NS_XML . ' lang' ] );
+ $this->itemLang = strtolower( $attribs[self::NS_XML . ' lang'] );
// need to add curItem[0] on again since one is for the specific item
// and one is for the entire group.
// this only validates standalone properties, not arrays, etc
return;
}
- if ( !preg_match( '/^[-A-Za-z0-9]{2,}$/D', $val) ) {
+ if ( !preg_match( '/^[-A-Za-z0-9]{2,}$/D', $val ) ) {
//this is a rather naive check.
wfDebugLog( 'XMP', __METHOD__ . " Expected Lang code but got $val" );
$val = null;
* 'compress_threshold' => 10240,
* 'persistent' => true));
*
- * $mc->add('key', array('some', 'array'));
- * $mc->replace('key', 'some random string');
- * $val = $mc->get('key');
+ * $mc->add( 'key', array( 'some', 'array' ) );
+ * $mc->replace( 'key', 'some random string' );
+ * $val = $mc->get( 'key' );
*
* @author Ryan T. Dean <rtdean@cytherianage.net>
* @version 0.1.2
}
$key = is_array( $key ) ? $key[1] : $key;
if ( !isset( $sock_keys[$sock] ) ) {
- $sock_keys[ intval( $sock ) ] = array();
+ $sock_keys[intval( $sock )] = array();
$socks[] = $sock;
}
- $sock_keys[ intval( $sock ) ][] = $key;
+ $sock_keys[intval( $sock )][] = $key;
}
$gather = array();
// Send out the requests
foreach ( $socks as $sock ) {
$cmd = 'gets';
- foreach ( $sock_keys[ intval( $sock ) ] as $key ) {
+ foreach ( $sock_keys[intval( $sock )] as $key ) {
$cmd .= ' ' . $key;
}
$cmd .= "\r\n";
function makeIsoYear( $year ) {
# Assumes the year is in a nice format, as enforced by the regex
if ( substr( $year, -2 ) == 'BC' ) {
- $num = intval(substr( $year, 0, -3 )) - 1;
+ $num = intval( substr( $year, 0, -3 ) ) - 1;
# PHP bug note: sprintf( "%04d", -1 ) fails poorly
$text = sprintf( '-%04d', $num );
$text = preg_replace_callback(
'/(<!--LINK .*?-->)/',
$replacer->cb(),
- $text);
+ $text
+ );
wfProfileOut( __METHOD__ . '-replace' );
wfProfileOut( __METHOD__ );
}
$dom = $this->preprocessToDom( $text, self::PTD_FOR_INCLUSION );
- $this->mTplDomCache[ $titleText ] = $dom;
+ $this->mTplDomCache[$titleText] = $dom;
if ( !$title->equals( $cacheTitle ) ) {
$this->mTplRedirCache[$cacheTitle->getPrefixedDBkey()] =
$dbw->replace( 'transcache', array( 'tc_url' ), array(
'tc_url' => $url,
'tc_time' => $dbw->timestamp( time() ),
- 'tc_contents' => $text)
- );
+ 'tc_contents' => $text
+ ) );
return $text;
}
if ( $stack->top ) {
$part = $stack->top->getCurrentPart();
- if ( !(isset( $part->commentEnd ) && $part->commentEnd == $wsStart - 1 )) {
+ if ( !( isset( $part->commentEnd ) && $part->commentEnd == $wsStart - 1 ) ) {
$part->visualEnd = $wsStart;
}
// Else comments abutting, no change in visual end
$class = $this->elementClass;
$this->stack[] = new $class( $data );
}
- $this->top = $this->stack[ count( $this->stack ) - 1 ];
+ $this->top = $this->stack[count( $this->stack ) - 1];
$this->accum =& $this->top->getAccum();
}
$temp = array_pop( $this->stack );
if ( count( $this->stack ) ) {
- $this->top = $this->stack[ count( $this->stack ) - 1 ];
+ $this->top = $this->stack[count( $this->stack ) - 1];
$this->accum =& $this->top->getAccum();
} else {
$this->top = self::$false;
while ( count( $iteratorStack ) > 1 ) {
$level = count( $outStack ) - 1;
- $iteratorNode =& $iteratorStack[ $level ];
+ $iteratorNode =& $iteratorStack[$level];
$out =& $outStack[$level];
$index =& $indexStack[$level];
- if ( $iteratorNode instanceof PPNode_DOM ) $iteratorNode = $iteratorNode->node;
+ if ( $iteratorNode instanceof PPNode_DOM ) {
+ $iteratorNode = $iteratorNode->node;
+ }
if ( is_array( $iteratorNode ) ) {
if ( $index >= count( $iteratorNode ) ) {
# Insert a heading marker only for <h> children of <root>
# This is to stop extractSections from going over multiple tree levels
- if ( $contextNode->parentNode->nodeName == 'root'
- && $this->parser->ot['html'] )
- {
+ if ( $contextNode->parentNode->nodeName == 'root' && $this->parser->ot['html'] ) {
# Insert heading index marker
$headingIndex = $contextNode->getAttribute( 'i' );
$titleText = $this->title->getPrefixedDBkey();
if ( $stack->top ) {
$part = $stack->top->getCurrentPart();
- if ( !(isset( $part->commentEnd ) && $part->commentEnd == $wsStart - 1 )) {
+ if ( !( isset( $part->commentEnd ) && $part->commentEnd == $wsStart - 1 ) ) {
$part->visualEnd = $wsStart;
}
// Else comments abutting, no change in visual end
while ( count( $iteratorStack ) > 1 ) {
$level = count( $outStack ) - 1;
- $iteratorNode =& $iteratorStack[ $level ];
+ $iteratorNode =& $iteratorStack[$level];
$out =& $outStack[$level];
$index =& $indexStack[$level];
$eventCount = $this->mCalls[$name];
$timeSum = (float) ($elapsed * 1000);
$memorySum = (float)$this->mMemory[$name];
- $name = substr($name, 0, 255);
+ $name = substr( $name, 0, 255 );
// Kludge
$timeSum = ($timeSum >= 0) ? $timeSum : 0;
continue;
}
$pfline = sprintf( "%s %s %d %f %f %f %f %s\n", $this->getProfileID(), "-", $pfdata['count'],
- $pfdata['cpu'], $pfdata['cpu_sq'], $pfdata['real'], $pfdata['real_sq'], $entry);
+ $pfdata['cpu'], $pfdata['cpu_sq'], $pfdata['real'], $pfdata['real_sq'], $entry );
$length = strlen( $pfline );
/* printf("<!-- $pfline -->"); */
if ( $length + $plength > 1400 ) {
* @return array|int|Mixed
*/
public function getModifiedTime( ResourceLoaderContext $context ) {
- $this->language = Language::factory( $context ->getLanguage() );
+ $this->language = Language::factory( $context->getLanguage() );
$cache = wfGetCache( CACHE_ANYTHING );
$key = wfMemcKey( 'resourceloader', 'langdatamodule', 'changeinfo' );
if ( $this->isDeleted() && !$this->canViewContent() ) {
return $this->list->msg( 'diff' )->escaped();
} else {
- return
- Linker::linkKnown(
+ return Linker::linkKnown(
$this->list->title,
$this->list->msg( 'diff' )->escaped(),
array(),
for ( $this->reset(); $this->current(); $this->next() ) {
$item = $this->current();
- unset( $missing[ $item->getId() ] );
+ unset( $missing[$item->getId()] );
$oldBits = $item->getBits();
// Build the actual new rev_deleted bitfield
*/
protected static function checkItem( $desc, $field, $diff, $new, &$arr ) {
if( $diff & $field ) {
- $arr[ ( $new & $field ) ? 0 : 1 ][] = $desc;
+ $arr[( $new & $field ) ? 0 : 1][] = $desc;
}
}
$strippedVariants = array_unique( $strippedVariants );
$searchon .= $modifier;
- if( count( $strippedVariants) > 1 )
+ if( count( $strippedVariants ) > 1 )
$searchon .= '(';
foreach( $strippedVariants as $stripped ) {
$stripped = $this->normalizeText( $stripped );
}
$searchon .= "$quote$stripped$quote$wildcard ";
}
- if( count( $strippedVariants) > 1 )
+ if( count( $strippedVariants ) > 1 )
$searchon .= ')';
// Match individual terms or quoted phrase in result highlighting...
*/
class SearchOracle extends SearchEngine {
- private $reservedWords = array ('ABOUT' => 1,
- 'ACCUM' => 1,
- 'AND' => 1,
- 'BT' => 1,
- 'BTG' => 1,
- 'BTI' => 1,
- 'BTP' => 1,
- 'FUZZY' => 1,
- 'HASPATH' => 1,
- 'INPATH' => 1,
- 'MINUS' => 1,
- 'NEAR' => 1,
- 'NOT' => 1,
- 'NT' => 1,
- 'NTG' => 1,
- 'NTI' => 1,
- 'NTP' => 1,
- 'OR' => 1,
- 'PT' => 1,
- 'RT' => 1,
- 'SQE' => 1,
- 'SYN' => 1,
- 'TR' => 1,
- 'TRSYN' => 1,
- 'TT' => 1,
- 'WITHIN' => 1);
+ private $reservedWords = array(
+ 'ABOUT' => 1,
+ 'ACCUM' => 1,
+ 'AND' => 1,
+ 'BT' => 1,
+ 'BTG' => 1,
+ 'BTI' => 1,
+ 'BTP' => 1,
+ 'FUZZY' => 1,
+ 'HASPATH' => 1,
+ 'INPATH' => 1,
+ 'MINUS' => 1,
+ 'NEAR' => 1,
+ 'NOT' => 1,
+ 'NT' => 1,
+ 'NTG' => 1,
+ 'NTI' => 1,
+ 'NTP' => 1,
+ 'OR' => 1,
+ 'PT' => 1,
+ 'RT' => 1,
+ 'SQE' => 1,
+ 'SYN' => 1,
+ 'TR' => 1,
+ 'TRSYN' => 1,
+ 'TT' => 1,
+ 'WITHIN' => 1,
+ );
/**
* Creates an instance of this class
// Search terms in all variant forms, only
// apply on wiki with LanguageConverter
$temp_terms = $wgContLang->autoConvertToAllVariants( $terms[2] );
- if( is_array( $temp_terms )) {
- $temp_terms = array_unique( array_values( $temp_terms ));
+ if( is_array( $temp_terms ) ) {
+ $temp_terms = array_unique( array_values( $temp_terms ) );
foreach( $temp_terms as $t ) {
$searchon .= ($terms[1] == '-' ? ' ~' : ' & ') . $this->escapeTerm( $t );
}
private function escapeTerm( $t ) {
global $wgContLang;
$t = $wgContLang->normalizeForSearch( $t );
- $t = isset( $this->reservedWords[strtoupper( $t )] ) ? '{'.$t.'}' : $t;
- $t = preg_replace('/^"(.*)"$/', '($1)', $t);
- $t = preg_replace('/([-&|])/', '\\\\$1', $t);
+ $t = isset( $this->reservedWords[strtoupper( $t )] ) ? '{' . $t . '}' : $t;
+ $t = preg_replace( '/^"(.*)"$/', '($1)', $t );
+ $t = preg_replace( '/([-&|])/', '\\\\$1', $t );
return $t;
}
/**
wfDebug( "parseQuery received: $term \n" );
## No backslashes allowed
- $term = preg_replace('/\\\/', '', $term);
+ $term = preg_replace( '/\\\/', '', $term );
## Collapse parens into nearby words:
- $term = preg_replace('/\s*\(\s*/', ' (', $term);
- $term = preg_replace('/\s*\)\s*/', ') ', $term);
+ $term = preg_replace( '/\s*\(\s*/', ' (', $term );
+ $term = preg_replace( '/\s*\)\s*/', ') ', $term );
## Treat colons as word separators:
- $term = preg_replace('/:/', ' ', $term);
+ $term = preg_replace( '/:/', ' ', $term );
$searchstring = '';
$m = array();
- if( preg_match_all('/([-!]?)(\S+)\s*/', $term, $m, PREG_SET_ORDER ) ) {
+ if( preg_match_all( '/([-!]?)(\S+)\s*/', $term, $m, PREG_SET_ORDER ) ) {
foreach( $m as $terms ) {
if ( strlen( $terms[1] ) ) {
$searchstring .= ' & !';
}
## Strip out leading junk
- $searchstring = preg_replace('/^[\s\&\|]+/', '', $searchstring);
+ $searchstring = preg_replace( '/^[\s\&\|]+/', '', $searchstring );
## Remove any doubled-up operators
- $searchstring = preg_replace('/([\!\&\|]) +(?:[\&\|] +)+/', "$1 ", $searchstring);
+ $searchstring = preg_replace( '/([\!\&\|]) +(?:[\&\|] +)+/', "$1 ", $searchstring );
## Remove any non-spaced operators (e.g. "Zounds!")
- $searchstring = preg_replace('/([^ ])[\!\&\|]/', "$1", $searchstring);
+ $searchstring = preg_replace( '/([^ ])[\!\&\|]/', "$1", $searchstring );
## Remove any trailing whitespace or operators
- $searchstring = preg_replace('/[\s\!\&\|]+$/', '', $searchstring);
+ $searchstring = preg_replace( '/[\s\!\&\|]+$/', '', $searchstring );
## Remove unnecessary quotes around everything
- $searchstring = preg_replace('/^[\'"](.*)[\'"]$/', "$1", $searchstring);
+ $searchstring = preg_replace( '/^[\'"](.*)[\'"]$/', "$1", $searchstring );
## Quote the whole thing
$searchstring = $this->db->addQuotes( $searchstring );
}
else {
$m = array();
- if( preg_match_all("/'([^']+)'/", $top, $m, PREG_SET_ORDER ) ) {
+ if( preg_match_all( "/'([^']+)'/", $top, $m, PREG_SET_ORDER ) ) {
foreach( $m as $terms ) {
$this->searchTerms[$terms[1]] = $terms[1];
}
$strippedVariants = array_unique( $strippedVariants );
$searchon .= $modifier;
- if( count( $strippedVariants) > 1 )
+ if( count( $strippedVariants ) > 1 )
$searchon .= '(';
foreach( $strippedVariants as $stripped ) {
if( $nonQuoted && strpos( $stripped, ' ' ) !== false ) {
}
$searchon .= "$quote$stripped$quote$wildcard ";
}
- if( count( $strippedVariants) > 1 )
+ if( count( $strippedVariants ) > 1 )
$searchon .= ')';
// Match individual terms or quoted phrase in result highlighting...
$lc = SearchEngine::legalSearchChars() . '&#;';
if( $this->mText === false ) {
- $search->updateTitle($this->mId,
+ $search->updateTitle( $this->mId,
$search->normalizeText( Title::indexTitle( $this->mNamespace, $this->mTitle ) ) );
wfProfileOut( __METHOD__ );
return;
// the single page in the "pages" substructure.
if ( isset( $externalData['query']['pages'] ) ) {
$pages = array_values( $externalData['query']['pages'] );
- if ( count( $pages) === 1 ) {
+ if ( count( $pages ) === 1 ) {
return $pages[0];
}
}
$namespaces = $wgContLang->getNamespaces();
$out->setPageTitle(
- ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces) ) ) ?
+ ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces ) ) ) ?
$this->msg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) ) :
$this->msg( 'allarticles' )
);
return array( 'badipaddress' );
}
- if ( ( strlen( $data['Expiry'] ) == 0) || ( strlen( $data['Expiry'] ) > 50 )
+ if ( ( strlen( $data['Expiry'] ) == 0 ) || ( strlen( $data['Expiry'] ) > 50 )
|| !self::parseExpiryInput( $data['Expiry'] ) )
{
return array( 'ipb_expiry_invalid' );
public function getStartForm( $from ) {
global $wgScript;
- return
- Xml::tags( 'form', array( 'method' => 'get', 'action' => $wgScript ),
+ return Xml::tags( 'form', array( 'method' => 'get', 'action' => $wgScript ),
Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
Xml::fieldset( $this->msg( 'categories' )->text(),
Xml::inputLabel( $this->msg( 'categoriesfrom' )->text(),
if ( !$this->associated ) {
return array( "page_namespace $eq_op $selectedNS" );
} else {
- $associatedNS = $this->mDb->addQuotes (
+ $associatedNS = $this->mDb->addQuotes(
MWNamespace::getAssociated( $this->namespace )
);
return array(
throw new ThrottledError;
case 'mailnologin':
case 'usermaildisabled':
- throw new ErrorPageError( $error, "{$error}text" );
+ throw new ErrorPageError( $error, "{$error}text" );
default:
# It's a hook error
list( $title, $msg, $params ) = $error;
- throw new ErrorPageError( $title, $msg, $params );
+ throw new ErrorPageError( $title, $msg, $params );
}
// Got a valid target user name? Else ask for one.
$ret = self::getTarget( $this->mTarget );
if( !in_array( $state, $validStates ) ) {
throw new MWException( __METHOD__
. ' given an invalid state. Must be one of "'
- . join( '", "', $validStates) . '".'
+ . join( '", "', $validStates ) . '".'
);
}
return "<div id=\"mw-javascripttest-summary\" class=\"mw-javascripttest-$state\">$html</div>";
* @return string Formatted HTML
*/
protected function getExpiryCheck( $indefOnly ) {
- return
- Xml::checkLabel( $this->msg( 'protectedpages-indef' )->text(), 'indefonly', 'indefonly', $indefOnly ) . "\n";
+ return Xml::checkLabel( $this->msg( 'protectedpages-indef' )->text(), 'indefonly', 'indefonly', $indefOnly ) . "\n";
}
/**
* @return string Formatted HTML
*/
protected function getCascadeCheck( $cascadeOnly ) {
- return
- Xml::checkLabel( $this->msg( 'protectedpages-cascade' )->text(), 'cascadeonly', 'cascadeonly', $cascadeOnly ) . "\n";
+ return Xml::checkLabel( $this->msg( 'protectedpages-cascade' )->text(), 'cascadeonly', 'cascadeonly', $cascadeOnly ) . "\n";
}
/**
protected function getSizeLimit( $sizetype, $size ) {
$max = $sizetype === 'max';
- return
- Xml::radioLabel( $this->msg( 'minimum-size' )->text(), 'sizetype', 'min', 'wpmin', !$max ) .
+ return Xml::radioLabel( $this->msg( 'minimum-size' )->text(), 'sizetype', 'min', 'wpmin', !$max ) .
' ' .
Xml::radioLabel( $this->msg( 'maximum-size' )->text(), 'sizetype', 'max', 'wpmax', $max ) .
' ' .
$options[] = Xml::option( $text, $type, $selected );
}
- return
- Xml::label( $this->msg( 'restriction-level' )->text(), $this->IdLevel ) . ' ' .
+ return Xml::label( $this->msg( 'restriction-level' )->text(), $this->IdLevel ) . ' ' .
Xml::tags( 'select',
array( 'id' => $this->IdLevel, 'name' => $this->IdLevel ),
implode( "\n", $options ) );
$this->mConds = $conds;
$this->level = $level;
$this->namespace = $namespace;
- $this->size = intval($size);
+ $this->size = intval( $size );
parent::__construct( $form->getContext() );
}
}
}
- if( $dbr->unionSupportsOrderAndLimit()) {
+ if( $dbr->unionSupportsOrderAndLimit() ) {
$order = array( 'ORDER BY' => 'rc_timestamp DESC' );
} else {
$order = array();
$join_conds + array( $link_table => array( 'INNER JOIN', $subjoin ) )
);
- if( $dbr->unionSupportsOrderAndLimit())
+ if( $dbr->unionSupportsOrderAndLimit() )
$query = $dbr->limitResult( $query, $limit );
$subsql[] = $query;
foreach( $this->checks as $item ) {
list( /* message */, $name, $field ) = $item;
$val = $this->getRequest()->getInt( $name, 0 /* unchecked */ );
- if( $val < -1 || $val > 1) {
+ if( $val < -1 || $val > 1 ) {
$val = -1; // -1 for existing value
}
$bitfield[$field] = $val;
$hidden .= Html::hidden( $key, $value );
}
// Return final output
- return
- Xml::openElement(
+ return Xml::openElement(
'fieldset',
array( 'id' => 'mw-searchoptions', 'style' => 'margin:0em;' )
) .
'a',
array(
'href' => $this->getTitle()->getLocalURL( $stParams ),
- 'title' => $tooltip),
+ 'title' => $tooltip
+ ),
$label
);
}
$user = $this->getUser();
$lang = $this->getLanguage();
$rdel = Linker::getRevDeleteLink( $user, $rev, $this->mTargetObj );
- if ( $rdel ) $rdel = " $rdel";
- return
- '<div id="mw-diff-' . $prefix . 'title1"><strong>' .
+ if ( $rdel ) {
+ $rdel = " $rdel";
+ }
+ return '<div id="mw-diff-' . $prefix . 'title1"><strong>' .
Linker::link(
$targetPage,
$this->msg(
# Show watchlist header
$form .= $this->msg( 'watchlist-details' )->numParams( $nitems )->parse() . "\n";
- if( $user->getOption( 'enotifwatchlistpages' ) && $wgEnotifWatchlist) {
+ if( $user->getOption( 'enotifwatchlistpages' ) && $wgEnotifWatchlist ) {
$form .= $this->msg( 'wlheader-enotif' )->parseAsBlock() . "\n";
}
if( $wgShowUpdatedMarker ) {
$options['ORDER BY'] = 'pl_from';
$plRes = $dbr->select( array( 'pagelinks', 'page', 'redirect' ), $fields,
$plConds, __METHOD__, $options,
- $joinConds);
+ $joinConds
+ );
}
if( !$hidetrans ) {
$options['ORDER BY'] = 'tl_from';
$tlRes = $dbr->select( array( 'templatelinks', 'page', 'redirect' ), $fields,
$tlConds, __METHOD__, $options,
- $joinConds);
+ $joinConds
+ );
}
if( !$hideimages ) {
$options['ORDER BY'] = 'il_from';
$ilRes = $dbr->select( array( 'imagelinks', 'page', 'redirect' ), $fields,
$ilConds, __METHOD__, $options,
- $joinConds);
+ $joinConds
+ );
}
if( ( !$fetchlinks || !$plRes->numRows() ) && ( $hidetrans || !$tlRes->numRows() ) && ( $hideimages || !$ilRes->numRows() ) ) {
*/
if ( !defined( 'MEDIAWIKI' ) ) {
- die( "NoLocalSettings.php is not a valid MediaWiki entry point\n" );
+ die( "NoLocalSettings.php is not a valid MediaWiki entry point\n" );
}
if ( !isset( $wgVersion ) ) {
* @return string
*/
public function getVerificationErrorCode( $error ) {
- $code_to_status = array(self::EMPTY_FILE => 'empty-file',
- self::FILE_TOO_LARGE => 'file-too-large',
- self::FILETYPE_MISSING => 'filetype-missing',
- self::FILETYPE_BADTYPE => 'filetype-banned',
- self::MIN_LENGTH_PARTNAME => 'filename-tooshort',
- self::ILLEGAL_FILENAME => 'illegal-filename',
- self::OVERWRITE_EXISTING_FILE => 'overwrite',
- self::VERIFICATION_ERROR => 'verification-error',
- self::HOOK_ABORTED => 'hookaborted',
- self::WINDOWS_NONASCII_FILENAME => 'windows-nonascii-filename',
- self::FILENAME_TOO_LONG => 'filename-toolong',
+ $code_to_status = array(
+ self::EMPTY_FILE => 'empty-file',
+ self::FILE_TOO_LARGE => 'file-too-large',
+ self::FILETYPE_MISSING => 'filetype-missing',
+ self::FILETYPE_BADTYPE => 'filetype-banned',
+ self::MIN_LENGTH_PARTNAME => 'filename-tooshort',
+ self::ILLEGAL_FILENAME => 'illegal-filename',
+ self::OVERWRITE_EXISTING_FILE => 'overwrite',
+ self::VERIFICATION_ERROR => 'verification-error',
+ self::HOOK_ABORTED => 'hookaborted',
+ self::WINDOWS_NONASCII_FILENAME => 'windows-nonascii-filename',
+ self::FILENAME_TOO_LONG => 'filename-toolong',
);
if( isset( $code_to_status[$error] ) ) {
return $code_to_status[$error];
global $wgVerifyMimeType;
wfProfileIn( __METHOD__ );
if ( $wgVerifyMimeType ) {
- wfDebug ( "\n\nmime: <$mime> extension: <{$this->mFinalExtension}>\n\n" );
+ wfDebug( "\n\nmime: <$mime> extension: <{$this->mFinalExtension}>\n\n" );
global $wgMimeTypeBlacklist;
if ( $this->checkFileExtension( $mime, $wgMimeTypeBlacklist ) ) {
wfProfileOut( __METHOD__ );
// Get the offset before we add the chunk to the file system
$preAppendOffset = $this->getOffset();
- if ( $preAppendOffset + $chunkSize > $this->getMaxUploadSize()) {
+ if ( $preAppendOffset + $chunkSize > $this->getMaxUploadSize() ) {
$status = Status::newFatal( 'file-too-large' );
} else {
// Make sure the client is uploading the correct chunk with a matching offset.