if-if-else without curly braces [api/ApiQuerySiteinfo.php] --> adding
Unused global declaration: $wgGroupPermissions --> removing
Unused global declaration: $wgEmailConfirmToEdit (line 301) --> removing
Variable $id appears only once (line 1021) --> removing
Variable $m was used before it was defined (line 805) --> defining.
Variable $retval was used before it was defined (line 2346) --> renaming to $result
Variable $rcid appears only once (line 244 of RecentChange.php) --> using this instead of $change [Note: was left over from r24607 refactoring, revert if wrong please]
Unused global declaration: $wgCommandLineMode (line 11) --> removing
Variable $k appears only once (line 132 of ImagePage.php) --> removing.
Variable $info appears only once (line 311 of ImagePage.php) --> removing.
Unused global declaration: $wgTitle (line 569 of ImagePage.php) -> removing.
Variable $handlerParams was used before it was defined (line 616 of Linker.php) --> resolved by Raymond in r24966
Variable $match was used before it was defined (line 1031 of Linker.php) --> defining.
Unused global declaration: $wgEnotifWatchlist (line 253 of UserMailer.php) --> removing
Unused global declaration: $wgShowUpdatedMarker (line 253 of UserMailer.php) --> removing
Variable $img appears only once (line 446 of SpecialUpload.php) --> added definition, defined as null, flagged with @todo [Note: should $img be defined in this context, or is it intended to be null? And should the return value after the hook be checked in some way?]
Unused global declaration: $wgEnableAPI (line 739 of SpecialUpload.php) --> removing.
Unused global declaration: $wgNamespaceProtection (line 1030 of OutputPage.php) --> removing.
Unused global declaration: $wgContLang (line 18 of SpecialWatchlist.php) --> removing.
Unused global declaration: $wgRawHtml (line 269 of SpecialMovepage.php) --> removing.
The value of variable $page was never used (line 331 of SpecialUndelete.php) --> removing line, as $page gets redefined a few lines down.
Variable $synIndex appears only once (line 521 of MagicWord.php) --> commenting out.
Variable $case appears only once (line 539 of MagicWord.php) --> removing from foreach index key usage.
Variable $wgUser appears only once (line 1039 of Title.php) --> adding line to declare as a global, would be null otherwise.
Variable $m was used before it was defined (line 285 of Title.php) --> defining.
Variable $id appears only once (line 1150 of Title.php) --> removing from foreach index key usage.
Variable $subpage appears only once (line 1297 of Title.php) --> commenting out.
Variable $restrictions appears only once (line 1399 of Title.php) --> commenting out.
Variable $mime appears only once (line 210 of filerepo/OldLocalFile.php) --> removing.
Variable $deprefixedName appears only once (line 213 of filerepo/LocalFile.php) --> removing.
Variable $m appears only once (line 541 of filerepo/LocalFile.php) --> removing.
Variable $where appears only once (line 1245 of filerepo/LocalFile.php) --> removing.
Variable $info appears only once (line 1427 of filerepo/LocalFile.php) --> removing.
Variable $rel appears only once (line 138 of filerepo/RepoGroup.php) --> commenting out.
Variable $zone appears only once (line 138 of filerepo/RepoGroup.php) --> commenting out.
Variable $nbytes appears only once (line 208 of media/Generic.php) --> added a return line that uses $nbytes. [Note: I'm assuming that this was the intent]
Variable $offset appears only once (line 201 of SpecialListusers.php) --> removing.
Variable $limit appears only once (line 201 of SpecialListusers.php) --> removing.
Variable $groupTarget appears only once (line 203 of SpecialListusers.php) --> removing.
Unused global declaration: $wgLang (line 74 of SpecialWantedpages.php) --> removing.
Variable $block appears only once (line 244 of SpecialProtectedpages.php) --> removing.
Variable $offset appears only once (line 281 of SpecialProtectedpages.php) --> removing.
Variable $limit appears only once (line 281 of SpecialProtectedpages.php) --> removing.
Unused global declaration: $wgLang (line 30 of FileDeleteForm.php) --> removing.
Unused global declaration: $wgServer (line 30 of FileDeleteForm.php) --> removing.
25 files changed:
// Give hooks a chance to customise the output
if( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->mTitle, $wgOut ) ) ) {
// Wrap the whole lot in a <pre> and don't parse
// Give hooks a chance to customise the output
if( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->mTitle, $wgOut ) ) ) {
// Wrap the whole lot in a <pre> and don't parse
preg_match( '!\.(css|js)$!u', $this->mTitle->getText(), $m );
$wgOut->addHtml( "<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n" );
$wgOut->addHtml( htmlspecialchars( $this->mContent ) );
preg_match( '!\.(css|js)$!u', $this->mTitle->getText(), $m );
$wgOut->addHtml( "<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n" );
$wgOut->addHtml( htmlspecialchars( $this->mContent ) );
$wgOut->returnToMain( false, $this->mTitle );
break;
default:
$wgOut->returnToMain( false, $this->mTitle );
break;
default:
- throw new MWException( __METHOD__ . ": Unknown return value `{$retval}`" );
+ throw new MWException( __METHOD__ . ": Unknown return value `{$result}`" );
$cache = new HTMLFileCache( $t );
if( $cache->isFileCached() ) {
$cache = new HTMLFileCache( $t );
if( $cache->isFileCached() ) {
- // FIXME: $msg is not defined on the next line.
+ // @todo, FIXME: $msg is not defined on the next line.
$msg = '<p style="color: red"><b>'.$msg."<br />\n" .
$cachederror . "</b></p>\n";
$msg = '<p style="color: red"><b>'.$msg."<br />\n" .
$cachederror . "</b></p>\n";
*/
function edit() {
global $wgOut, $wgUser, $wgRequest, $wgTitle;
*/
function edit() {
global $wgOut, $wgUser, $wgRequest, $wgTitle;
- global $wgEmailConfirmToEdit;
if ( ! wfRunHooks( 'AlternateEdit', array( &$this ) ) )
return;
if ( ! wfRunHooks( 'AlternateEdit', array( &$this ) ) )
return;
if ($error[0] == 'readonlytext')
{
if ($error[0] == 'readonlytext')
{
$this->formtype = 'preview';
$this->formtype = 'preview';
- else if ($this->save || $this->preview || $this->diff)
+ } elseif ($this->save || $this->preview || $this->diff) {
}
}
# array_diff returns elements in $permErrors that are not in $remove.
}
}
# array_diff returns elements in $permErrors that are not in $remove.
if ( count($cascadeSources) > 0 ) {
# Explain, and list the titles responsible
$notice = wfMsgExt( 'cascadeprotectedwarning', array('parsemag'), count($cascadeSources) ) . "\n";
if ( count($cascadeSources) > 0 ) {
# Explain, and list the titles responsible
$notice = wfMsgExt( 'cascadeprotectedwarning', array('parsemag'), count($cascadeSources) ) . "\n";
- foreach( $cascadeSources as $id => $page )
+ foreach( $cascadeSources as $page ) {
$notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
}
$notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
}
$wgOut->addWikiText( $notice );
}
$wgOut->addWikiText( $notice );
}
* pending authentication, confirmation, etc.
*/
public function execute() {
* pending authentication, confirmation, etc.
*/
public function execute() {
- global $wgOut, $wgRequest, $wgUser, $wgLang, $wgServer;
+ global $wgOut, $wgRequest, $wgUser;
$this->setHeaders();
if( wfReadOnly() ) {
$this->setHeaders();
if( wfReadOnly() ) {
$r = wfMsg( 'metadata-help' ) . "\n\n";
$r .= "{| id=mw_metadata class=mw_metadata\n";
foreach ( $metadata as $type => $stuff ) {
$r = wfMsg( 'metadata-help' ) . "\n\n";
$r .= "{| id=mw_metadata class=mw_metadata\n";
foreach ( $metadata as $type => $stuff ) {
- foreach ( $stuff as $k => $v ) {
+ foreach ( $stuff as $v ) {
$class = Sanitizer::escapeId( $v['id'] );
if( $type == 'collapsed' ) {
$class .= ' collapsable';
$class = Sanitizer::escapeId( $v['id'] );
if( $type == 'collapsed' ) {
$class .= ' collapsable';
if ($showLink) {
$filename = wfEscapeWikiText( $this->img->getName() );
if ($showLink) {
$filename = wfEscapeWikiText( $this->img->getName() );
- $info = wfMsg( 'file-info', $sk->formatSize( $this->img->getSize() ), $mime );
global $wgContLang;
$dirmark = $wgContLang->getDirMark();
global $wgContLang;
$dirmark = $wgContLang->getDirMark();
}
public function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description, $dims ) {
}
public function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description, $dims ) {
- global $wgUser, $wgLang, $wgTitle, $wgContLang;
+ global $wgUser, $wgLang, $wgContLang;
$local = $this->img->isLocal();
$row = '';
$local = $this->img->isLocal();
$row = '';
$medians = '(?:' . preg_quote( Namespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
$medians .= preg_quote( $wgContLang->getNsText( NS_MEDIA ), '/' ) . '):';
$medians = '(?:' . preg_quote( Namespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
$medians .= preg_quote( $wgContLang->getNsText( NS_MEDIA ), '/' ) . '):';
while(preg_match('/\[\[:?(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
# Handle link renaming [[foo|text]] will show link as "text"
if( "" != $match[3] ) {
while(preg_match('/\[\[:?(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
# Handle link renaming [[foo|text]] will show link as "text"
if( "" != $match[3] ) {
// continue;
throw new MWException( __METHOD__ . ': bad parameter name' );
}
// continue;
throw new MWException( __METHOD__ . ': bad parameter name' );
}
- list( $synIndex, $magicName ) = $parts;
+ list( /* $synIndex */, $magicName ) = $parts;
$paramValue = next( $m );
return array( $magicName, $paramValue );
}
$paramValue = next( $m );
return array( $magicName, $paramValue );
}
public function matchVariableStartToEnd( $text ) {
global $wgContLang;
$regexes = $this->getVariableStartToEndRegex();
public function matchVariableStartToEnd( $text ) {
global $wgContLang;
$regexes = $this->getVariableStartToEndRegex();
- foreach ( $regexes as $case => $regex ) {
+ foreach ( $regexes as $regex ) {
if ( $regex !== '' ) {
$m = false;
if ( preg_match( $regex, $text, $m ) ) {
if ( $regex !== '' ) {
$m = false;
if ( preg_match( $regex, $text, $m ) ) {
$this->addWikiText( wfMsgExt( 'cascadeprotected', 'parsemag', $count ) . "\n{$titles}" );
} elseif( !$wgTitle->isProtected( 'edit' ) && $wgTitle->isNamespaceProtected() ) {
// Namespace protection
$this->addWikiText( wfMsgExt( 'cascadeprotected', 'parsemag', $count ) . "\n{$titles}" );
} elseif( !$wgTitle->isProtected( 'edit' ) && $wgTitle->isNamespaceProtected() ) {
// Namespace protection
- global $wgNamespaceProtection;
$ns = $wgTitle->getNamespace() == NS_MAIN
? wfMsg( 'nstab-main' )
: $wgTitle->getNsText();
$ns = $wgTitle->getNamespace() == NS_MAIN
? wfMsg( 'nstab-main' )
: $wgTitle->getNsText();
'rc_patrolled' => 1
),
array(
'rc_patrolled' => 1
),
array(
function wfSpecialListusers( $par = null ) {
global $wgRequest, $wgOut;
function wfSpecialListusers( $par = null ) {
global $wgRequest, $wgOut;
- list( $limit, $offset ) = wfCheckLimits();
-
- $groupTarget = isset($par) ? $par : $wgRequest->getVal( 'group' );
-
$up = new UsersPager($par);
# getBody() first to check, if empty
$up = new UsersPager($par);
# getBody() first to check, if empty
}
function showSuccess() {
}
function showSuccess() {
- global $wgOut, $wgRequest, $wgUser, $wgRawHtml;
+ global $wgOut, $wgRequest, $wgUser;
$old = Title::newFromText( $wgRequest->getVal( 'oldtitle' ) );
$new = Title::newFromText( $wgRequest->getVal( 'newtitle' ) );
$old = Title::newFromText( $wgRequest->getVal( 'oldtitle' ) );
$new = Title::newFromText( $wgRequest->getVal( 'newtitle' ) );
}
function formatRow( $row ) {
}
function formatRow( $row ) {
return $this->mForm->formatRow( $row );
}
return $this->mForm->formatRow( $row );
}
*/
function wfSpecialProtectedpages() {
*/
function wfSpecialProtectedpages() {
- list( $limit, $offset ) = wfCheckLimits();
-
$ppForm = new ProtectedPagesForm();
$ppForm->showList();
$ppForm = new ProtectedPagesForm();
$ppForm->showList();
$restoreAll = empty( $timestamps );
$dbw = wfGetDB( DB_MASTER );
$restoreAll = empty( $timestamps );
$dbw = wfGetDB( DB_MASTER );
- $page = $dbw->tableName( 'archive' );
# Does this page already exist? We'll have to update it...
$article = new Article( $this->title );
# Does this page already exist? We'll have to update it...
$article = new Article( $this->title );
}
// Success, redirect to description page
$wgOut->redirect( $this->mLocalFile->getTitle()->getFullURL() );
}
// Success, redirect to description page
$wgOut->redirect( $this->mLocalFile->getTitle()->getFullURL() );
+ $img = null; // @todo: added to avoid passing a ref to null - should this be defined somewhere?
wfRunHooks( 'UploadComplete', array( &$img ) );
}
}
wfRunHooks( 'UploadComplete', array( &$img ) );
}
}
function mainUploadForm( $msg='' ) {
global $wgOut, $wgUser, $wgContLang;
global $wgUseCopyrightUpload, $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview;
function mainUploadForm( $msg='' ) {
global $wgOut, $wgUser, $wgContLang;
global $wgUseCopyrightUpload, $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview;
- global $wgRequest, $wgAllowCopyUploads, $wgEnableAPI;
+ global $wgRequest, $wgAllowCopyUploads;
global $wgStylePath, $wgStyleVersion;
$useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck;
global $wgStylePath, $wgStyleVersion;
$useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck;
* constructor
*/
function wfSpecialUserlogin() {
* constructor
*/
function wfSpecialUserlogin() {
- global $wgCommandLineMode;
global $wgRequest;
if( session_id() == '' ) {
wfSetupSession();
global $wgRequest;
if( session_id() == '' ) {
wfSetupSession();
* @return Array array( 'add' => array( addablegroups ), 'remove' => array( removablegroups ) )
*/
private function changeableGroups() {
* @return Array array( 'add' => array( addablegroups ), 'remove' => array( removablegroups ) )
*/
private function changeableGroups() {
- global $wgUser, $wgGroupPermissions;
$groups = array( 'add' => array(), 'remove' => array() );
$addergroups = $wgUser->getEffectiveGroups();
$groups = array( 'add' => array(), 'remove' => array() );
$addergroups = $wgUser->getEffectiveGroups();
* @return string
*/
public function formatResult( $skin, $result ) {
* @return string
*/
public function formatResult( $skin, $result ) {
$title = Title::makeTitleSafe( $result->namespace, $result->title );
if( $title instanceof Title ) {
if( $this->isCached() ) {
$title = Title::makeTitleSafe( $result->namespace, $result->title );
if( $title instanceof Title ) {
if( $this->isCached() ) {
* @param $par Parameter passed to the page
*/
function wfSpecialWatchlist( $par ) {
* @param $par Parameter passed to the page
*/
function wfSpecialWatchlist( $par ) {
- global $wgUser, $wgOut, $wgLang, $wgRequest, $wgContLang;
+ global $wgUser, $wgOut, $wgLang, $wgRequest;
global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker;
global $wgEnotifWatchlist;
$fname = 'wfSpecialWatchlist';
global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker;
global $wgEnotifWatchlist;
$fname = 'wfSpecialWatchlist';
$redir = MagicWord::get( 'redirect' );
if( $redir->matchStart( $text ) ) {
// Extract the first link and see if it's usable
$redir = MagicWord::get( 'redirect' );
if( $redir->matchStart( $text ) ) {
// Extract the first link and see if it's usable
if( preg_match( '!\[{2}(.*?)(?:\||\]{2})!', $text, $m ) ) {
// Strip preceding colon used to "escape" categories, etc.
// and URL-decode links
if( preg_match( '!\[{2}(.*?)(?:\||\]{2})!', $text, $m ) ) {
// Strip preceding colon used to "escape" categories, etc.
// and URL-decode links
$errors[] = array( 'readonlytext' );
}
$errors[] = array( 'readonlytext' );
}
- global $wgEmailConfirmToEdit;
+ global $wgEmailConfirmToEdit, $wgUser;
if ( $wgEmailConfirmToEdit && !$wgUser->isEmailConfirmed() )
{
if ( $wgEmailConfirmToEdit && !$wgUser->isEmailConfirmed() )
{
$right = ( $right == 'sysop' ) ? 'protect' : $right;
if( '' != $right && !$user->isAllowed( $right ) ) {
$pages = '';
$right = ( $right == 'sysop' ) ? 'protect' : $right;
if( '' != $right && !$user->isAllowed( $right ) ) {
$pages = '';
- foreach( $cascadingSources as $id => $page )
+ foreach( $cascadingSources as $page )
$pages .= '* [[:' . $page->getPrefixedText() . "]]\n";
$errors[] = array( 'cascadeprotected', count( $cascadingSources ), $pages );
}
$pages .= '* [[:' . $page->getPrefixedText() . "]]\n";
$errors[] = array( 'cascadeprotected', count( $cascadingSources ), $pages );
}
*/
if( $this->getNamespace() == NS_SPECIAL ) {
$name = $this->getText();
*/
if( $this->getNamespace() == NS_SPECIAL ) {
$name = $this->getText();
- list( $name, $subpage ) = SpecialPage::resolveAliasWithSubpage( $name );
+ list( $name, /* $subpage */) = SpecialPage::resolveAliasWithSubpage( $name );
$pure = SpecialPage::getTitleFor( $name )->getPrefixedText();
if( in_array( $pure, $wgWhitelistRead, true ) )
return true;
$pure = SpecialPage::getTitleFor( $name )->getPrefixedText();
if( in_array( $pure, $wgWhitelistRead, true ) )
return true;
* @return bool If the page is subject to cascading restrictions.
*/
public function isCascadeProtected() {
* @return bool If the page is subject to cascading restrictions.
*/
public function isCascadeProtected() {
- list( $sources, $restrictions ) = $this->getCascadeProtectionSources( false );
+ list( $sources, /* $restrictions */ ) = $this->getCascadeProtectionSources( false );
return ( $sources > 0 );
}
return ( $sources > 0 );
}
function notifyOnPageChange($editor, &$title, $timestamp, $summary, $minorEdit, $oldid = false) {
global $wgEnotifUseJobQ;
function notifyOnPageChange($editor, &$title, $timestamp, $summary, $minorEdit, $oldid = false) {
global $wgEnotifUseJobQ;
- global $wgEnotifWatchlist, $wgShowUpdatedMarker;
if( $title->getNamespace() < 0 )
return;
if( $title->getNamespace() < 0 )
return;
$this->addTables('interwiki');
$this->addFields(array('iw_prefix', 'iw_local', 'iw_url'));
$this->addTables('interwiki');
$this->addFields(array('iw_prefix', 'iw_local', 'iw_url'));
- if($filter === 'local')
+ if($filter === 'local') {
$this->addWhere('iw_local = 1');
$this->addWhere('iw_local = 1');
- else if($filter === '!local')
+ } elseif($filter === '!local') {
$this->addWhere('iw_local = 0');
$this->addWhere('iw_local = 0');
- else if($filter !== false)
+ } elseif($filter !== false) {
ApiBase :: dieDebug(__METHOD__, "Unknown filter=$filter");
ApiBase :: dieDebug(__METHOD__, "Unknown filter=$filter");
$this->addOption('ORDER BY', 'iw_prefix');
$this->addOption('ORDER BY', 'iw_prefix');
}
$decoded = array();
foreach ( $array as $name => $value ) {
}
$decoded = array();
foreach ( $array as $name => $value ) {
- $deprefixedName = substr( $name, $prefixLength );
$decoded[substr( $name, $prefixLength )] = $value;
}
$decoded['timestamp'] = wfTimestamp( TS_MW, $decoded['timestamp'] );
$decoded[substr( $name, $prefixLength )] = $value;
}
$decoded['timestamp'] = wfTimestamp( TS_MW, $decoded['timestamp'] );
$dir = $this->getThumbPath();
$urls = array();
foreach ( $files as $file ) {
$dir = $this->getThumbPath();
$urls = array();
foreach ( $files as $file ) {
# Check that the base file name is part of the thumb name
# This is a basic sanity check to avoid erasing unrelated directories
if ( strpos( $file, $this->getName() ) !== false ) {
# Check that the base file name is part of the thumb name
# This is a basic sanity check to avoid erasing unrelated directories
if ( strpos( $file, $this->getName() ) !== false ) {
$dbw = $this->file->repo->getMasterDB();
list( $oldRels, $deleteCurrent ) = $this->getOldRels();
if ( $deleteCurrent ) {
$dbw = $this->file->repo->getMasterDB();
list( $oldRels, $deleteCurrent ) = $this->getOldRels();
if ( $deleteCurrent ) {
- $where = array( 'img_name' => $this->file->getName() );
$dbw->delete( 'image', array( 'img_name' => $this->file->getName() ), __METHOD__ );
}
if ( count( $oldRels ) ) {
$dbw->delete( 'image', array( 'img_name' => $this->file->getName() ), __METHOD__ );
}
if ( count( $oldRels ) ) {
if ( $first && !$exists ) {
// This revision will be published as the new current version
$destRel = $this->file->getRel();
if ( $first && !$exists ) {
// This revision will be published as the new current version
$destRel = $this->file->getRel();
- $info = $this->file->repo->getFileProps( $deletedUrl );
$insertCurrent = array(
'img_name' => $row->fa_name,
'img_size' => $row->fa_size,
$insertCurrent = array(
'img_name' => $row->fa_name,
'img_size' => $row->fa_size,
$dbw = $this->repo->getMasterDB();
list( $major, $minor ) = self::splitMime( $this->mime );
$dbw = $this->repo->getMasterDB();
list( $major, $minor ) = self::splitMime( $this->mime );
wfDebug(__METHOD__.': upgrading '.$this->archive_name." to the current schema\n");
$dbw->update( 'oldimage',
wfDebug(__METHOD__.': upgrading '.$this->archive_name." to the current schema\n");
$dbw->update( 'oldimage',
function getFileProps( $fileName ) {
if ( FileRepo::isVirtualUrl( $fileName ) ) {
function getFileProps( $fileName ) {
if ( FileRepo::isVirtualUrl( $fileName ) ) {
- list( $repoName, $zone, $rel ) = $this->splitVirtualUrl( $fileName );
+ list( $repoName, /* $zone */, /* $rel */ ) = $this->splitVirtualUrl( $fileName );
if ( $repoName === '' ) {
$repoName = 'local';
}
if ( $repoName === '' ) {
$repoName = 'local';
}
global $wgLang;
$nbytes = '(' . wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
$wgLang->formatNum( $file->getSize() ) ) . ')';
global $wgLang;
$nbytes = '(' . wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
$wgLang->formatNum( $file->getSize() ) ) . ')';
}
function getLongDesc( $file ) {
}
function getLongDesc( $file ) {