r59780 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59779‎ | r59780 | r59781 >
Date:08:51, 7 December 2009
Author:tstarling
Status:ok (Comments)
Tags:
Comment:
Replaced all instances of <<<END (which breaks vim syntax highlighting), with a type-specific end token. For HTML and SQL, this causes vim to highlight the embedded text with the HTML or SQL file type plugins respectively, which is very neat.
Modified paths:
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseIbm_db2.php (modified) (history)
  • /trunk/phase3/includes/db/DatabasePostgres.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialLockdb.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUnlockdb.php (modified) (history)
  • /trunk/phase3/maintenance/importImages.php (modified) (history)
  • /trunk/phase3/maintenance/importUseModWiki.php (modified) (history)
  • /trunk/phase3/maintenance/language/checkDupeMessages.php (modified) (history)
  • /trunk/phase3/maintenance/language/checkExtensions.php (modified) (history)
  • /trunk/phase3/maintenance/language/rebuildLanguage.php (modified) (history)
  • /trunk/phase3/maintenance/language/transstat.php (modified) (history)
  • /trunk/phase3/skins/Simple.php (modified) (history)
  • /trunk/phase3/skins/common/edit.js (modified) (history)
  • /trunk/phase3/tests/SearchEngineTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/importImages.php
@@ -254,7 +254,7 @@
255255 echo( $reason . "\n" );
256256 }
257257
258 - echo <<<END
 258+ echo <<<TEXT
259259 Imports images and other media files into the wiki
260260 USAGE: php importImages.php [options] <dir>
261261
@@ -279,6 +279,6 @@
280280 --protect=<protect> Specify the protect value (autoconfirmed,sysop)
281281 --unprotect Unprotects all uploaded images
282282
283 -END;
 283+TEXT;
284284 exit(1);
285 -}
\ No newline at end of file
 285+}
Index: trunk/phase3/maintenance/importUseModWiki.php
@@ -59,7 +59,7 @@
6060 global $wgRootDirectory;
6161
6262 $gt = '>';
63 - echo <<<END
 63+ echo <<<XML
6464 <?xml version="1.0" encoding="UTF-8" ?$gt
6565 <mediawiki xmlns="http://www.mediawiki.org/xml/export-0.1/"
6666 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -69,7 +69,7 @@
7070 xml:lang="en">
7171 <!-- generated by importUseModWiki.php -->
7272
73 -END;
 73+XML;
7474 $letters = array(
7575 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
7676 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
@@ -79,10 +79,10 @@
8080 if( is_dir( $dir ) )
8181 importPageDirectory( $dir );
8282 }
83 - echo <<<END
 83+ echo <<<XML
8484 </mediawiki>
8585
86 -END;
 86+XML;
8787 }
8888
8989 function importPageDirectory( $dir, $prefix = "" )
@@ -227,11 +227,11 @@
228228 */
229229 $revisions = array( $page );
230230 }
231 - $xml = <<<END
 231+ $xml = <<<XML
232232 <page>
233233 <title>$newtitle</title>
234234
235 -END;
 235+XML;
236236
237237 # History
238238 $revisions = array_merge( $revisions, fetchKeptPages( $title ) );
@@ -247,7 +247,7 @@
248248 $timestamp = xmlsafe( timestamp2ISO8601( $rev->ts ) );
249249 $comment = xmlsafe( recodeText( $rev->summary ) );
250250
251 - $xml .= <<<END
 251+ $xml .= <<<XML
252252 <revision>
253253 <timestamp>$timestamp</timestamp>
254254 <contributor><username>$username</username></contributor>
@@ -256,7 +256,7 @@
257257 <text>$text</text>
258258 </revision>
259259
260 -END;
 260+XML;
261261 }
262262 $xml .= "</page>\n\n";
263263 return $xml;
Index: trunk/phase3/maintenance/language/rebuildLanguage.php
@@ -60,7 +60,7 @@
6161
6262 # Show help
6363 if ( isset( $options['help'] ) ) {
64 - echo <<<END
 64+ echo <<<TEXT
6565 Run this script to rewrite the messages array in the files languages/messages/MessagesXX.php.
6666 Parameters:
6767 * lang: Language code (default: the installation default language). You can also specify "all" to check all the languages.
@@ -71,7 +71,7 @@
7272 * remove-unknown: Remove unknown messages.
7373 * remove-duplicates: Remove duplicated messages based on a PHP source file.
7474
75 -END;
 75+TEXT;
7676 exit(1);
7777 }
7878
Index: trunk/phase3/maintenance/language/checkExtensions.php
@@ -11,13 +11,13 @@
1212 require_once( 'checkLanguage.inc' );
1313
1414 if( !class_exists( 'MessageGroups' ) || !class_exists( 'PremadeMediawikiExtensionGroups' ) ) {
15 - echo <<<END
 15+ echo <<<TEXT
1616 Please add the Translate extension to LocalSettings.php, and enable the extension groups:
1717 require_once( 'extensions/Translate/Translate.php' );
1818 \$wgTranslateEC = array_keys( \$wgTranslateAC );
1919 If you still get this message, update Translate to its latest version.
2020
21 -END;
 21+TEXT;
2222 exit(-1);
2323 }
2424
Index: trunk/phase3/maintenance/language/checkDupeMessages.php
@@ -27,7 +27,7 @@
2828 }
2929 $runTest = true;
3030 } else {
31 - echo <<<END
 31+ echo <<<TEXT
3232 Run this script to print out the duplicates against a message array.
3333 Parameters:
3434 * lang: Language code to be checked.
@@ -38,7 +38,7 @@
3939 * wiki: Wiki format, with * at beginning of each line
4040 * php: Output text as PHP syntax in a array $dupeMessages
4141 * raw: Raw output for duplicates
42 -END;
 42+TEXT;
4343 }
4444
4545 // Check file exists
Index: trunk/phase3/maintenance/language/transstat.php
@@ -29,7 +29,7 @@
3030
3131 /** Print a usage message*/
3232 function showUsage() {
33 - print <<<END
 33+ print <<<TEXT
3434 Usage: php transstat.php [--help] [--output=csv|text|wiki]
3535 --help : this helpful message
3636 --output : select an output engine one of:
@@ -39,7 +39,7 @@
4040 * 'text' : Text with tabs.
4141 Example: php maintenance/transstat.php --output=text
4242
43 -END;
 43+TEXT;
4444 exit(1);
4545 }
4646
Index: trunk/phase3/skins/Simple.php
@@ -36,7 +36,7 @@
3737 if( $wgUser->getOption( 'highlightbroken' ) ) {
3838 $s .= "a.new, #quickbar a.new { text-decoration: line-through; }\n";
3939 } else {
40 - $s .= <<<END
 40+ $s .= <<<CSS
4141 a.new, #quickbar a.new,
4242 a.stub, #quickbar a.stub {
4343 color: inherit;
@@ -52,7 +52,7 @@
5353 color: #772233;
5454 text-decoration: $underline;
5555 }
56 -END;
 56+CSS;
5757 }
5858 if( $wgUser->getOption( 'justify' ) ) {
5959 $s .= "#article, #bodyContent { text-align: justify; }\n";
Index: trunk/phase3/skins/common/edit.js
@@ -46,7 +46,9 @@
4747
4848 // Don't generate buttons for browsers which don't fully
4949 // support it.
50 - var textbox = document.createElement('textarea'); // abstract, don't assume wpTextbox1 is always there
 50+ var textbox = document.getElementById('wpTextbox1');
 51+ if (!textbox) { return false; }
 52+ //var textbox = document.createElement('textarea'); // abstract, don't assume wpTextbox1 is always there
5153 if (!(document.selection && document.selection.createRange)
5254 && textbox.selectionStart === null) {
5355 return false;
Index: trunk/phase3/tests/SearchEngineTest.php
@@ -7,7 +7,7 @@
88 var $db, $search;
99
1010 function insertSearchData() {
11 - $this->db->safeQuery( <<<END
 11+ $this->db->safeQuery( <<<SQL
1212 INSERT INTO ! (page_id,page_namespace,page_title,page_latest)
1313 VALUES (1, 0, 'Main_Page', 1),
1414 (2, 1, 'Main_Page', 2),
@@ -19,9 +19,9 @@
2020 (8, 0, 'Thppt', 8),
2121 (9, 0, 'Alan_Smithee', 9),
2222 (10, 0, 'Pages', 10)
23 -END
 23+SQL
2424 , $this->db->tableName( 'page' ) );
25 - $this->db->safeQuery( <<<END
 25+ $this->db->safeQuery( <<<SQL
2626 INSERT INTO ! (rev_id,rev_page)
2727 VALUES (1, 1),
2828 (2, 2),
@@ -33,9 +33,9 @@
3434 (8, 8),
3535 (9, 9),
3636 (10, 10)
37 -END
 37+SQL
3838 , $this->db->tableName( 'revision' ) );
39 - $this->db->safeQuery( <<<END
 39+ $this->db->safeQuery( <<<SQL
4040 INSERT INTO ! (old_id,old_text)
4141 VALUES (1, 'This is a main page'),
4242 (2, 'This is a talk page to the main page, see [[smithee]]'),
@@ -47,9 +47,9 @@
4848 (8, 'Blah blah'),
4949 (9, 'yum'),
5050 (10,'are food')
51 -END
 51+SQL
5252 , $this->db->tableName( 'text' ) );
53 - $this->db->safeQuery( <<<END
 53+ $this->db->safeQuery( <<<SQL
5454 INSERT INTO ! (si_page,si_title,si_text)
5555 VALUES (1, 'main page', 'this is a main page'),
5656 (2, 'main page', 'this is a talk page to the main page, see smithee'),
@@ -61,7 +61,7 @@
6262 (8, 'thppt', 'blah blah'),
6363 (9, 'alan smithee', 'yum'),
6464 (10, 'pages', 'are food')
65 -END
 65+SQL
6666 , $this->db->tableName( 'searchindex' ) );
6767 }
6868
Index: trunk/phase3/includes/db/DatabasePostgres.php
@@ -11,7 +11,7 @@
1212 static function fromText($db, $table, $field) {
1313 global $wgDBmwschema;
1414
15 - $q = <<<END
 15+ $q = <<<SQL
1616 SELECT
1717 CASE WHEN typname = 'int2' THEN 'smallint'
1818 WHEN typname = 'int4' THEN 'integer'
@@ -27,7 +27,7 @@
2828 AND nspname=%s
2929 AND relname=%s
3030 AND attname=%s;
31 -END;
 31+SQL;
3232 $res = $db->query(sprintf($q,
3333 $db->addQuotes($wgDBmwschema),
3434 $db->addQuotes($table),
@@ -1181,12 +1181,12 @@
11821182 function triggerExists( $table, $trigger ) {
11831183 global $wgDBmwschema;
11841184
1185 - $q = <<<END
 1185+ $q = <<<SQL
11861186 SELECT 1 FROM pg_class, pg_namespace, pg_trigger
11871187 WHERE relnamespace=pg_namespace.oid AND relkind='r'
11881188 AND tgrelid=pg_class.oid
11891189 AND nspname=%s AND relname=%s AND tgname=%s
1190 -END;
 1190+SQL;
11911191 $res = $this->query(sprintf($q,
11921192 $this->addQuotes($wgDBmwschema),
11931193 $this->addQuotes($table),
Index: trunk/phase3/includes/db/DatabaseIbm_db2.php
@@ -29,13 +29,13 @@
3030 static function fromText($db, $table, $field) {
3131 global $wgDBmwschema;
3232
33 - $q = <<<END
 33+ $q = <<<SQL
3434 SELECT
3535 lcase(coltype) AS typname,
3636 nulls AS attnotnull, length AS attlen
3737 FROM sysibm.syscolumns
3838 WHERE tbcreator=%s AND tbname=%s AND name=%s;
39 -END;
 39+SQL;
4040 $res = $db->query(sprintf($q,
4141 $db->addQuotes($wgDBmwschema),
4242 $db->addQuotes($table),
Index: trunk/phase3/includes/EditPage.php
@@ -1299,10 +1299,10 @@
13001300 $toolbar = '';
13011301 // @todo move this to a cleaner conditional instead of blanking a variable
13021302 }
1303 - $wgOut->addHTML( <<<END
 1303+ $wgOut->addHTML( <<<HTML
13041304 {$toolbar}
13051305 <form id="editform" name="editform" method="post" action="$action" enctype="multipart/form-data">
1306 -END
 1306+HTML
13071307 );
13081308
13091309 if ( is_callable( $formCallback ) ) {
@@ -1372,7 +1372,7 @@
13731373 $this->showTosSummary();
13741374 $this->showEditTools();
13751375
1376 - $wgOut->addHTML( <<<END
 1376+ $wgOut->addHTML( <<<HTML
13771377 {$this->editFormTextAfterTools}
13781378 <div class='templatesUsed'>
13791379 {$formattedtemplates}
@@ -1380,7 +1380,7 @@
13811381 <div class='hiddencats'>
13821382 {$formattedhiddencats}
13831383 </div>
1384 -END
 1384+HTML
13851385 );
13861386
13871387 if ( $this->isConflict )
Index: trunk/phase3/includes/specials/SpecialLockdb.php
@@ -65,7 +65,7 @@
6666 $reason = htmlspecialchars( $this->reason );
6767 $token = htmlspecialchars( $wgUser->editToken() );
6868
69 - $wgOut->addHTML( <<<END
 69+ $wgOut->addHTML( <<<HTML
7070 <form id="lockdb" method="post" action="{$action}">
7171 {$elr}:
7272 <textarea name="wpLockReason" rows="10" cols="60" wrap="virtual">{$reason}</textarea>
@@ -85,7 +85,7 @@
8686 </table>
8787 <input type="hidden" name="wpEditToken" value="{$token}" />
8888 </form>
89 -END
 89+HTML
9090 );
9191
9292 }
Index: trunk/phase3/includes/specials/SpecialUnlockdb.php
@@ -55,7 +55,7 @@
5656 $action = $titleObj->escapeLocalURL( "action=submit" );
5757 $token = htmlspecialchars( $wgUser->editToken() );
5858
59 - $wgOut->addHTML( <<<END
 59+ $wgOut->addHTML( <<<HTML
6060
6161 <form id="unlockdb" method="post" action="{$action}">
6262 <table border="0">
@@ -74,7 +74,7 @@
7575 </table>
7676 <input type="hidden" name="wpEditToken" value="{$token}" />
7777 </form>
78 -END
 78+HTML
7979 );
8080
8181 }
Index: trunk/phase3/includes/Skin.php
@@ -547,7 +547,7 @@
548548 if( $wgUser->getOption( 'highlightbroken' ) ) {
549549 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
550550 } else {
551 - $s .= <<<END
 551+ $s .= <<<CSS
552552 a.new, #quickbar a.new,
553553 a.stub, #quickbar a.stub {
554554 color: inherit;
@@ -560,7 +560,7 @@
561561 content: "!";
562562 color: #772233;
563563 }
564 -END;
 564+CSS;
565565 }
566566 if( $wgUser->getOption( 'justify' ) ) {
567567 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";

Follow-up revisions

RevisionCommit summaryAuthorDate
r59805Revert debugging code accidentally left in from r59780tstarling21:45, 7 December 2009
r61608wmf-deployment: Merge (parts of) r59780, r61431, r61489, r61557, r61558, r615...catrope21:59, 27 January 2010

Comments

#Comment by Catrope (talk | contribs)   12:12, 7 December 2009

Contains unrelated changes to edit.js

#Comment by Tim Starling (talk | contribs)   21:33, 7 December 2009

Sorry about that, it's to fix complete breakage of the edit toolbar on FF 3.5 due to r59655 and was meant to be a temporary debugging fix.

Status & tagging log