r92586 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92585‎ | r92586 | r92587 >
Date:21:29, 19 July 2011
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Merge code cleanup revisions so that code analysis can also be performed in the branch:
r92551, r92552, r92560, r92563, r92564, r92570, r92573, r92574, r92576, r92581
Modified paths:
  • /branches/REL1_18/phase3/includes/OutputPage.php (modified) (history)
  • /branches/REL1_18/phase3/includes/SkinTemplate.php (modified) (history)
  • /branches/REL1_18/phase3/includes/Title.php (modified) (history)
  • /branches/REL1_18/phase3/includes/api/ApiFormatBase.php (modified) (history)
  • /branches/REL1_18/phase3/includes/api/ApiQueryWatchlist.php (modified) (history)
  • /branches/REL1_18/phase3/includes/diff/DifferenceEngine.php (modified) (history)
  • /branches/REL1_18/phase3/includes/libs/jsminplus.php (modified) (history)
  • /branches/REL1_18/phase3/includes/parser/Tidy.php (modified) (history)
  • /branches/REL1_18/phase3/includes/specials/SpecialUndelete.php (modified) (history)
  • /branches/REL1_18/phase3/tests/phpunit/includes/GlobalFunctions/GlobalTest.php (modified) (history)

Diff [purge]

Index: branches/REL1_18/phase3/tests/phpunit/includes/GlobalFunctions/GlobalTest.php
@@ -2,8 +2,7 @@
33
44 class GlobalTest extends MediaWikiTestCase {
55 function setUp() {
6 - global $wgReadOnlyFile, $wgContLang, $wgLang, $wgUrlProtocols, $wgLanguageCode;
7 - parent::setUp();
 6+ global $wgReadOnlyFile, $wgUrlProtocols;
87 $this->originals['wgReadOnlyFile'] = $wgReadOnlyFile;
98 $this->originals['wgUrlProtocols'] = $wgUrlProtocols;
109 $wgReadOnlyFile = tempnam( wfTempDir(), "mwtest_readonly" );
Index: branches/REL1_18/phase3/includes/diff/DifferenceEngine.php
@@ -779,7 +779,7 @@
780780 function generateDiffBody( $otext, $ntext ) {
781781 global $wgExternalDiffEngine, $wgContLang;
782782
783 - wfProfileIn( __METHOD__ );
 783+ wfProfileIn( __METHOD__ );
784784
785785 $otext = str_replace( "\r\n", "\n", $otext );
786786 $ntext = str_replace( "\r\n", "\n", $ntext );
@@ -791,6 +791,7 @@
792792 # input text to be HTML-escaped already
793793 $otext = htmlspecialchars ( $wgContLang->segmentForDiff( $otext ) );
794794 $ntext = htmlspecialchars ( $wgContLang->segmentForDiff( $ntext ) );
 795+ wfProfileOut( __METHOD__ );
795796 return $wgContLang->unsegmentForDiff( wikidiff_do_diff( $otext, $ntext, 2 ) ) .
796797 $this->debug( 'wikidiff1' );
797798 }
@@ -802,6 +803,7 @@
803804 $text = wikidiff2_do_diff( $otext, $ntext, 2 );
804805 $text .= $this->debug( 'wikidiff2' );
805806 wfProfileOut( 'wikidiff2_do_diff' );
 807+ wfProfileOut( __METHOD__ );
806808 return $text;
807809 }
808810 if ( $wgExternalDiffEngine != 'wikidiff3' && $wgExternalDiffEngine !== false ) {
Index: branches/REL1_18/phase3/includes/parser/Tidy.php
@@ -217,6 +217,8 @@
218218 if ( !MWInit::classExists( 'tidy' ) ) {
219219 wfWarn( "Unable to load internal tidy class." );
220220 $retval = -1;
 221+
 222+ wfProfileOut( __METHOD__ );
221223 return null;
222224 }
223225
Index: branches/REL1_18/phase3/includes/OutputPage.php
@@ -2261,14 +2261,16 @@
22622262 * @return String: The doctype, opening <html>, and head element.
22632263 */
22642264 public function headElement( Skin $sk, $includeStyle = true ) {
2265 - global $wgUseTrackbacks, $wgLang;
 2265+ global $wgLang, $wgContLang, $wgUseTrackbacks;
 2266+ $userdir = $wgLang->getDir();
 2267+ $sitedir = $wgContLang->getDir();
22662268
22672269 if ( $sk->commonPrintStylesheet() ) {
22682270 $this->addModuleStyles( 'mediawiki.legacy.wikiprintable' );
22692271 }
22702272 $sk->setupUserCss( $this );
22712273
2272 - $ret = Html::htmlHeader( array( 'lang' => $wgLang->getCode(), 'dir' => $wgLang->getDir() ) );
 2274+ $ret = Html::htmlHeader( array( 'lang' => $wgLang->getCode(), 'dir' => $userdir ) );
22732275
22742276 if ( $this->getHTMLTitle() == '' ) {
22752277 $this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ) );
@@ -2315,9 +2317,6 @@
23162318 }
23172319
23182320 # Classes for LTR/RTL directionality support
2319 - global $wgLang, $wgContLang;
2320 - $userdir = $wgLang->getDir();
2321 - $sitedir = $wgContLang->getDir();
23222321 $bodyAttrs['class'] = "mediawiki $userdir sitedir-$sitedir";
23232322
23242323 if ( $this->getContext()->getLang()->capitalizeAllNouns() ) {
Property changes on: branches/REL1_18/phase3/includes/OutputPage.php
___________________________________________________________________
Modified: svn:mergeinfo
23252324 Merged /trunk/phase3/includes/OutputPage.php:r92551-92552,92560,92563-92564,92568,92570,92573-92574,92576,92581
Index: branches/REL1_18/phase3/includes/api/ApiFormatBase.php
@@ -257,8 +257,6 @@
258258 * @return string
259259 */
260260 protected function formatHTML( $text ) {
261 - global $wgUrlProtocols;
262 -
263261 // Escape everything first for full coverage
264262 $text = htmlspecialchars( $text );
265263
@@ -374,4 +372,4 @@
375373 public function getVersion() {
376374 return __CLASS__ . ': $Id$';
377375 }
378 -}
\ No newline at end of file
 376+}
Index: branches/REL1_18/phase3/includes/api/ApiQueryWatchlist.php
@@ -292,7 +292,6 @@
293293 }
294294
295295 if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) {
296 - global $wgUser;
297296 $vals['parsedcomment'] = $this->getSkin()->formatComment( $row->rc_comment, $title );
298297 }
299298
Index: branches/REL1_18/phase3/includes/Title.php
@@ -2355,7 +2355,7 @@
23562356 $conditions = array( 'ar_namespace' => $this->getNamespace(), 'ar_title' => $this->getDBkey() );
23572357
23582358 if( !$includeSuppressed ) {
2359 - $suppressedTextBits = REVISION::DELETED_TEXT | REVISION::DELETED_RESTRICTED;
 2359+ $suppressedTextBits = Revision::DELETED_TEXT | Revision::DELETED_RESTRICTED;
23602360 $conditions[] = $dbr->bitAnd('ar_deleted', $suppressedTextBits ) .
23612361 ' != ' . $suppressedTextBits;
23622362 }
@@ -2367,7 +2367,7 @@
23682368 if ( $this->getNamespace() == NS_FILE ) {
23692369 $fconditions = array( 'fa_name' => $this->getDBkey() );
23702370 if( !$includeSuppressed ) {
2371 - $suppressedTextBits = FILE::DELETED_FILE | FILE::DELETED_RESTRICTED;
 2371+ $suppressedTextBits = File::DELETED_FILE | File::DELETED_RESTRICTED;
23722372 $fconditions[] = $dbr->bitAnd('fa_deleted', $suppressedTextBits ) .
23732373 ' != ' . $suppressedTextBits;
23742374 }
Property changes on: branches/REL1_18/phase3/includes/Title.php
___________________________________________________________________
Modified: svn:mergeinfo
23752375 Merged /trunk/phase3/includes/Title.php:r92551-92552,92560,92563-92564,92568,92570,92573-92574,92576,92581
Index: branches/REL1_18/phase3/includes/SkinTemplate.php
@@ -107,7 +107,7 @@
108108 *
109109 * @param $out OutputPage
110110 */
111 - function setupSkinUserCss( OutputPage $out ){
 111+ function setupSkinUserCss( OutputPage $out ) {
112112 $out->addModuleStyles( array( 'mediawiki.legacy.shared', 'mediawiki.legacy.commonPrint' ) );
113113 }
114114
@@ -133,7 +133,7 @@
134134 */
135135 function outputPage( OutputPage $out ) {
136136 global $wgUser, $wgLang, $wgContLang;
137 - global $wgScript, $wgStylePath, $wgLanguageCode;
 137+ global $wgScript, $wgStylePath;
138138 global $wgMimeType, $wgJsMimeType, $wgRequest;
139139 global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version;
140140 global $wgDisableCounters, $wgLogo, $wgHideInterlanguageLinks;
Index: branches/REL1_18/phase3/includes/libs/jsminplus.php
@@ -15,6 +15,7 @@
1616 * Usage: $minified = JSMinPlus::minify($script [, $filename])
1717 *
1818 * Versionlog (see also changelog.txt):
 19+ * 19-07-2011 - expanded operator and keyword defines. Fixes the notices when creating several JSTokenizer
1920 * 17-05-2009 - fixed hook:colon precedence, fixed empty body in loop and if-constructs
2021 * 18-04-2009 - fixed crashbug in PHP 5.2.9 and several other bugfixes
2122 * 12-04-2009 - some small bugfixes and performance improvements
@@ -89,6 +90,83 @@
9091 define('EXPRESSED_FORM', 1);
9192 define('STATEMENT_FORM', 2);
9293
 94+/* Operators */
 95+define('OP_SEMICOLON', ';');
 96+define('OP_COMMA', ',');
 97+define('OP_HOOK', '?');
 98+define('OP_COLON', ':');
 99+define('OP_OR', '||');
 100+define('OP_AND', '&&');
 101+define('OP_BITWISE_OR', '|');
 102+define('OP_BITWISE_XOR', '^');
 103+define('OP_BITWISE_AND', '&');
 104+define('OP_STRICT_EQ', '===');
 105+define('OP_EQ', '==');
 106+define('OP_ASSIGN', '=');
 107+define('OP_STRICT_NE', '!==');
 108+define('OP_NE', '!=');
 109+define('OP_LSH', '<<');
 110+define('OP_LE', '<=');
 111+define('OP_LT', '<');
 112+define('OP_URSH', '>>>');
 113+define('OP_RSH', '>>');
 114+define('OP_GE', '>=');
 115+define('OP_GT', '>');
 116+define('OP_INCREMENT', '++');
 117+define('OP_DECREMENT', '--');
 118+define('OP_PLUS', '+');
 119+define('OP_MINUS', '-');
 120+define('OP_MUL', '*');
 121+define('OP_DIV', '/');
 122+define('OP_MOD', '%');
 123+define('OP_NOT', '!');
 124+define('OP_BITWISE_NOT', '~');
 125+define('OP_DOT', '.');
 126+define('OP_LEFT_BRACKET', '[');
 127+define('OP_RIGHT_BRACKET', ']');
 128+define('OP_LEFT_CURLY', '{');
 129+define('OP_RIGHT_CURLY', '}');
 130+define('OP_LEFT_PAREN', '(');
 131+define('OP_RIGHT_PAREN', ')');
 132+define('OP_CONDCOMMENT_END', '@*/');
 133+
 134+define('OP_UNARY_PLUS', 'U+');
 135+define('OP_UNARY_MINUS', 'U-');
 136+
 137+/* Keywords */
 138+define('KEYWORD_BREAK', 'break');
 139+define('KEYWORD_CASE', 'case');
 140+define('KEYWORD_CATCH', 'catch');
 141+define('KEYWORD_CONST', 'const');
 142+define('KEYWORD_CONTINUE', 'continue');
 143+define('KEYWORD_DEBUGGER', 'debugger');
 144+define('KEYWORD_DEFAULT', 'default');
 145+define('KEYWORD_DELETE', 'delete');
 146+define('KEYWORD_DO', 'do');
 147+define('KEYWORD_ELSE', 'else');
 148+define('KEYWORD_ENUM', 'enum');
 149+define('KEYWORD_FALSE', 'false');
 150+define('KEYWORD_FINALLY', 'finally');
 151+define('KEYWORD_FOR', 'for');
 152+define('KEYWORD_FUNCTION', 'function');
 153+define('KEYWORD_IF', 'if');
 154+define('KEYWORD_IN', 'in');
 155+define('KEYWORD_INSTANCEOF', 'instanceof');
 156+define('KEYWORD_NEW', 'new');
 157+define('KEYWORD_NULL', 'null');
 158+define('KEYWORD_RETURN', 'return');
 159+define('KEYWORD_SWITCH', 'switch');
 160+define('KEYWORD_THIS', 'this');
 161+define('KEYWORD_THROW', 'throw');
 162+define('KEYWORD_TRUE', 'true');
 163+define('KEYWORD_TRY', 'try');
 164+define('KEYWORD_TYPEOF', 'typeof');
 165+define('KEYWORD_VAR', 'var');
 166+define('KEYWORD_VOID', 'void');
 167+define('KEYWORD_WHILE', 'while');
 168+define('KEYWORD_WITH', 'with');
 169+
 170+
93171 class JSMinPlus
94172 {
95173 private $parser;
@@ -1536,7 +1614,7 @@
15371615
15381616 if (($numargs = func_num_args()) > 2)
15391617 {
1540 - $args = func_get_args();;
 1618+ $args = func_get_args();
15411619 for ($i = 2; $i < $numargs; $i++)
15421620 $this->addNode($args[$i]);
15431621 }
@@ -1646,16 +1724,6 @@
16471725 public function __construct()
16481726 {
16491727 $this->opRegExp = '#^(' . implode('|', array_map('preg_quote', array_keys($this->opTypeNames))) . ')#';
1650 -
1651 - // this is quite a hidden yet convenient place to create the defines for operators and keywords
1652 - foreach ($this->opTypeNames as $operand => $name)
1653 - define('OP_' . $name, $operand);
1654 -
1655 - define('OP_UNARY_PLUS', 'U+');
1656 - define('OP_UNARY_MINUS', 'U-');
1657 -
1658 - foreach ($this->keywords as $keyword)
1659 - define('KEYWORD_' . strtoupper($keyword), $keyword);
16601728 }
16611729
16621730 public function init($source, $filename = '', $lineno = 1)
@@ -1977,4 +2045,3 @@
19782046 public $assignOp;
19792047 }
19802048
1981 -?>
\ No newline at end of file
Index: branches/REL1_18/phase3/includes/specials/SpecialUndelete.php
@@ -80,7 +80,7 @@
8181 );
8282
8383 // bug 19725
84 - $suppressedText = REVISION::DELETED_TEXT | REVISION::DELETED_RESTRICTED;
 84+ $suppressedText = Revision::DELETED_TEXT | Revision::DELETED_RESTRICTED;
8585 if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
8686 $conds[] = $dbr->bitAnd('ar_deleted', $suppressedText ) .
8787 ' != ' . $suppressedText;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r92551Follow up to r91561: Use the canonical class names.platonides19:00, 19 July 2011
r92552Profiling errors. r92106 missed a wfProfileOut...platonides19:05, 19 July 2011
r92560Remove double ; and final ?> from jsminplus (imported in r91591)....platonides19:53, 19 July 2011
r92563Expand the defines from JSTokenizer::__construct() placing them at the top of...platonides20:03, 19 July 2011
r92564Follow up r91561. Use canonical class names.platonides20:06, 19 July 2011
r92570Follow-up r91246. The global is no longer needed.platonides20:28, 19 July 2011
r92573Follow up r92036. The global is not needed now.platonides20:31, 19 July 2011
r92574Follow-up r91518platonides20:36, 19 July 2011
r92576Remove the globals. r91570 was wrong saying that parent::setUp()...platonides21:05, 19 July 2011
r92581Spacing, removed unneded global.platonides21:22, 19 July 2011

Comments

#Comment by Nikerabbit (talk | contribs)   09:09, 20 July 2011

jsminplus change is code cleanup?

#Comment by Platonides (talk | contribs)   17:43, 22 July 2011

That file was giving many warnings. To be fair, I didn't expect JSMin+ to be in 1.18 branch.

Status & tagging log