dépôts
/
lhc
/
web
/
wiklou.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e7cfe34
)
Refactor to avoid defining globals inside switches.
author
Platonides
<platonides@users.mediawiki.org>
Thu, 12 Aug 2010 14:25:07 +0000
(14:25 +0000)
committer
Platonides
<platonides@users.mediawiki.org>
Thu, 12 Aug 2010 14:25:07 +0000
(14:25 +0000)
includes/Autopromote.php
patch
|
blob
|
history
includes/api/ApiBase.php
patch
|
blob
|
history
includes/api/ApiEditPage.php
patch
|
blob
|
history
includes/api/ApiLogin.php
patch
|
blob
|
history
includes/api/ApiUpload.php
patch
|
blob
|
history
maintenance/dumpTextPass.php
patch
|
blob
|
history
diff --git
a/includes/Autopromote.php
b/includes/Autopromote.php
index
2f96998
..
560ba7a
100644
(file)
--- a/
includes/Autopromote.php
+++ b/
includes/Autopromote.php
@@
-104,6
+104,7
@@
class Autopromote {
* @return bool Whether the condition is true for the user
*/
private static function checkCondition( $cond, User $user ) {
* @return bool Whether the condition is true for the user
*/
private static function checkCondition( $cond, User $user ) {
+ global $wgEmailAuthentication;
if ( count( $cond ) < 1 ) {
return false;
}
if ( count( $cond ) < 1 ) {
return false;
}
@@
-111,7
+112,6
@@
class Autopromote {
switch( $cond[0] ) {
case APCOND_EMAILCONFIRMED:
if ( User::isValidEmailAddr( $user->getEmail() ) ) {
switch( $cond[0] ) {
case APCOND_EMAILCONFIRMED:
if ( User::isValidEmailAddr( $user->getEmail() ) ) {
- global $wgEmailAuthentication;
if ( $wgEmailAuthentication ) {
return (bool)$user->getEmailAuthenticationTimestamp();
} else {
if ( $wgEmailAuthentication ) {
return (bool)$user->getEmailAuthenticationTimestamp();
} else {
diff --git
a/includes/api/ApiBase.php
b/includes/api/ApiBase.php
index
1e3d5af
..
93d57d6
100644
(file)
--- a/
includes/api/ApiBase.php
+++ b/
includes/api/ApiBase.php
@@
-550,6
+550,7
@@
abstract class ApiBase {
* @returns mixed
*/
protected function getWatchlistValue ( $watchlist, $titleObj, $userOption = null ) {
* @returns mixed
*/
protected function getWatchlistValue ( $watchlist, $titleObj, $userOption = null ) {
+ global $wgUser;
switch ( $watchlist ) {
case 'watch':
return true;
switch ( $watchlist ) {
case 'watch':
return true;
@@
-558,7
+559,6
@@
abstract class ApiBase {
return false;
case 'preferences':
return false;
case 'preferences':
- global $wgUser;
# If the user is already watching, don't bother checking
if ( $titleObj->userIsWatching() ) {
return null;
# If the user is already watching, don't bother checking
if ( $titleObj->userIsWatching() ) {
return null;
diff --git
a/includes/api/ApiEditPage.php
b/includes/api/ApiEditPage.php
index
6e55b0a
..
8742f8b
100644
(file)
--- a/
includes/api/ApiEditPage.php
+++ b/
includes/api/ApiEditPage.php
@@
-252,6
+252,8
@@
class ApiEditPage extends ApiBase {
$retval = $ep->internalAttemptSave( $result, $wgUser->isAllowed( 'bot' ) && $params['bot'] );
$wgRequest = $oldRequest;
$retval = $ep->internalAttemptSave( $result, $wgUser->isAllowed( 'bot' ) && $params['bot'] );
$wgRequest = $oldRequest;
+ global $wgMaxArticleSize;
+
switch( $retval ) {
case EditPage::AS_HOOK_ERROR:
case EditPage::AS_HOOK_ERROR_EXPECTED:
switch( $retval ) {
case EditPage::AS_HOOK_ERROR:
case EditPage::AS_HOOK_ERROR_EXPECTED:
@@
-274,7
+276,6
@@
class ApiEditPage extends ApiBase {
case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
case EditPage::AS_CONTENT_TOO_BIG:
case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
case EditPage::AS_CONTENT_TOO_BIG:
- global $wgMaxArticleSize;
$this->dieUsageMsg( array( 'contenttoobig', $wgMaxArticleSize ) );
case EditPage::AS_READ_ONLY_PAGE_ANON:
$this->dieUsageMsg( array( 'contenttoobig', $wgMaxArticleSize ) );
case EditPage::AS_READ_ONLY_PAGE_ANON:
diff --git
a/includes/api/ApiLogin.php
b/includes/api/ApiLogin.php
index
3cd622b
..
c9b405b
100644
(file)
--- a/
includes/api/ApiLogin.php
+++ b/
includes/api/ApiLogin.php
@@
-70,12
+70,10
@@
class ApiLogin extends ApiBase {
$loginForm = new LoginForm( $req );
$loginForm = new LoginForm( $req );
- global $wgCookiePrefix;
+ global $wgCookiePrefix
, $wgUser, $wgPasswordAttemptThrottle;
;
switch ( $authRes = $loginForm->authenticateUserData() ) {
case LoginForm::SUCCESS:
switch ( $authRes = $loginForm->authenticateUserData() ) {
case LoginForm::SUCCESS:
- global $wgUser;
-
$wgUser->setOption( 'rememberpassword', 1 );
$wgUser->setCookies();
$wgUser->setOption( 'rememberpassword', 1 );
$wgUser->setCookies();
@@
-134,7
+132,6
@@
class ApiLogin extends ApiBase {
break;
case LoginForm::THROTTLED:
break;
case LoginForm::THROTTLED:
- global $wgPasswordAttemptThrottle;
$result['result'] = 'Throttled';
$result['wait'] = intval( $wgPasswordAttemptThrottle['seconds'] );
break;
$result['result'] = 'Throttled';
$result['wait'] = intval( $wgPasswordAttemptThrottle['seconds'] );
break;
diff --git
a/includes/api/ApiUpload.php
b/includes/api/ApiUpload.php
index
cf69ce0
..
9ba52ea
100644
(file)
--- a/
includes/api/ApiUpload.php
+++ b/
includes/api/ApiUpload.php
@@
-167,6
+167,8
@@
class ApiUpload extends ApiBase {
* Performs file verification, dies on error.
*/
protected function verifyUpload( ) {
* Performs file verification, dies on error.
*/
protected function verifyUpload( ) {
+ global $wgFileExtensions;
+
$verification = $this->mUpload->verifyUpload( );
if ( $verification['status'] === UploadBase::OK ) {
return;
$verification = $this->mUpload->verifyUpload( );
if ( $verification['status'] === UploadBase::OK ) {
return;
@@
-184,7
+186,6
@@
class ApiUpload extends ApiBase {
$this->dieUsage( 'The file is missing an extension', 'filetype-missing' );
break;
case UploadBase::FILETYPE_BADTYPE:
$this->dieUsage( 'The file is missing an extension', 'filetype-missing' );
break;
case UploadBase::FILETYPE_BADTYPE:
- global $wgFileExtensions;
$this->dieUsage( 'This type of file is banned', 'filetype-banned',
0, array(
'filetype' => $verification['finalExt'],
$this->dieUsage( 'This type of file is banned', 'filetype-banned',
0, array(
'filetype' => $verification['finalExt'],
diff --git
a/maintenance/dumpTextPass.php
b/maintenance/dumpTextPass.php
index
9da20d9
..
3687694
100644
(file)
--- a/
maintenance/dumpTextPass.php
+++ b/
maintenance/dumpTextPass.php
@@
-80,11
+80,11
@@
class TextPassDumper extends BackupDumper {
}
function processOption( $opt, $val, $param ) {
}
function processOption( $opt, $val, $param ) {
+ global $IP;
$url = $this->processFileOpt( $val, $param );
switch( $opt ) {
case 'prefetch':
$url = $this->processFileOpt( $val, $param );
switch( $opt ) {
case 'prefetch':
- global $IP;
require_once "$IP/maintenance/backupPrefetch.inc";
$this->prefetch = new BaseDump( $url );
break;
require_once "$IP/maintenance/backupPrefetch.inc";
$this->prefetch = new BaseDump( $url );
break;