r100779 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100778‎ | r100779 | r100780 >
Date:03:45, 26 October 2011
Author:reedy
Status:ok
Tags:
Comment:
Add, update, tweak documentation

Fix document comment blocks

Tweak some returns
Modified paths:
  • /trunk/phase3/includes/WebRequest.php (modified) (history)
  • /trunk/phase3/includes/WikiFilePage.php (modified) (history)
  • /trunk/phase3/includes/WikiMap.php (modified) (history)
  • /trunk/phase3/includes/WikiPage.php (modified) (history)
  • /trunk/phase3/includes/ZhClient.php (modified) (history)
  • /trunk/phase3/includes/ZipDirectoryReader.php (modified) (history)
  • /trunk/phase3/index.php5 (modified) (history)
  • /trunk/phase3/maintenance/fetchText.php (modified) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)
  • /trunk/phase3/skins/common/upload.js (modified) (history)
  • /trunk/phase3/tests/parser/parserTest.inc (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/IPTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/SeleniumConfigurationTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/search/SearchEngineTest.php (modified) (history)
  • /trunk/phase3/tests/selenium/SeleniumConfig.php (modified) (history)
  • /trunk/phase3/tests/selenium/suites/MediawikiCoreSmokeTestCase.php (modified) (history)
  • /trunk/phase3/tests/selenium/suites/SimpleSeleniumTestCase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/fetchText.php
@@ -29,7 +29,7 @@
3030 $this->mDescription = "Fetch the revision text from an old_id";
3131 }
3232
33 - /*
 33+ /**
3434 * returns a string containing the following in order:
3535 * textid
3636 * \n
Index: trunk/phase3/skins/common/upload.js
@@ -34,46 +34,45 @@
3535 }
3636 }
3737 }
38 -
39 -
 38+
4039 // AJAX wpDestFile warnings
4140 if ( wgAjaxUploadDestCheck ) {
4241 // Insert an event handler that fetches upload warnings when wpDestFile
4342 // has been changed
44 - document.getElementById( 'wpDestFile' ).onchange = function ( e ) {
 43+ document.getElementById( 'wpDestFile' ).onchange = function ( e ) {
4544 wgUploadWarningObj.checkNow(this.value);
4645 };
47 - // Insert a row where the warnings will be displayed just below the
 46+ // Insert a row where the warnings will be displayed just below the
4847 // wpDestFile row
4948 var optionsTable = document.getElementById( 'mw-htmlform-description' ).tBodies[0];
5049 var row = optionsTable.insertRow( 1 );
5150 var td = document.createElement( 'td' );
5251 td.id = 'wpDestFile-warning';
5352 td.colSpan = 2;
54 -
 53+
5554 row.appendChild( td );
5655 }
57 -
 56+
5857 var wpLicense = document.getElementById( 'wpLicense' );
5958 if ( wgAjaxLicensePreview && wpLicense ) {
6059 // License selector check
6160 wpLicense.onchange = licenseSelectorCheck;
62 -
 61+
6362 // License selector table row
6463 var wpLicenseRow = wpLicense.parentNode.parentNode;
6564 var wpLicenseTbody = wpLicenseRow.parentNode;
66 -
 65+
6766 var row = document.createElement( 'tr' );
6867 var td = document.createElement( 'td' );
6968 row.appendChild( td );
7069 td = document.createElement( 'td' );
7170 td.id = 'mw-license-preview';
7271 row.appendChild( td );
73 -
 72+
7473 wpLicenseTbody.insertBefore( row, wpLicenseRow.nextSibling );
7574 }
76 -
77 -
 75+
 76+
7877 // fillDestFile setup
7978 for ( var i = 0; i < wgUploadSourceIds.length; i++ )
8079 document.getElementById( wgUploadSourceIds[i] ).onchange = function (e) {
@@ -150,7 +149,7 @@
151150 var ackElt = document.getElementsByName( 'wpDestFileWarningAck' );
152151
153152 this.setInnerHTML(warningElt, warning);
154 -
 153+
155154 // Set a value in the form indicating that the warning is acknowledged and
156155 // doesn't need to be redisplayed post-upload
157156 if ( warning == '' || warning == '&nbsp;' ) {
@@ -196,7 +195,7 @@
197196 }
198197
199198 // Clear the filename if it does not have a valid extension.
200 - // URLs are less likely to have a useful extension, so don't include them in the
 199+ // URLs are less likely to have a useful extension, so don't include them in the
201200 // extension check.
202201 if( wgStrictFileExtensions && wgFileExtensions && id != 'wpUploadFileURL' ) {
203202 var found = false;
@@ -262,15 +261,15 @@
263262 }
264263 }
265264 injectSpinner( document.getElementById( 'wpLicense' ), 'license' );
266 -
 265+
267266 var title = document.getElementById('wpDestFile').value;
268267 if ( !title ) title = 'File:Sample.jpg';
269 -
 268+
270269 var url = wgScriptPath + '/api' + wgScriptExtension
271270 + '?action=parse&text={{' + encodeURIComponent( license ) + '}}'
272 - + '&title=' + encodeURIComponent( title )
 271+ + '&title=' + encodeURIComponent( title )
273272 + '&prop=text&pst&format=json';
274 -
 273+
275274 var req = sajax_init_object();
276275 req.onreadystatechange = function() {
277276 if ( req.readyState == 4 && req.status == 200 )
@@ -284,7 +283,6 @@
285284 removeSpinner( 'license' );
286285 this.responseCache[license] = result['parse']['text']['*'];
287286 this.showPreview( this.responseCache[license] );
288 -
289287 },
290288
291289 'showPreview' : function( preview ) {
Index: trunk/phase3/tests/selenium/suites/MediawikiCoreSmokeTestCase.php
@@ -1,44 +1,44 @@
22 <?php
3 -/*
 3+/*
44 * Stub of tests be need as part of the hack-a-ton
55 */
66 class MediawikiCoreSmokeTestCase extends SeleniumTestCase {
77 public function testUserLogin() {
8 -
 8+
99 }
10 -
 10+
1111 public function testChangeUserPreference() {
12 -
 12+
1313 }
14 -
15 - /*
 14+
 15+ /**
1616 * TODO: generalize this test to be reusable for different skins
1717 */
1818 public function testCreateNewPageVector() {
19 -
 19+
2020 }
21 -
22 - /*
 21+
 22+ /**
2323 * TODO: generalize this test to be reusable for different skins
2424 */
2525 public function testEditExistingPageVector() {
26 -
 26+
2727 }
28 -
29 - /*
 28+
 29+ /**
3030 * TODO: generalize this test to be reusable for different skins
3131 */
3232 public function testCreateNewPageMonobook() {
33 -
 33+
3434 }
35 -
36 - /*
 35+
 36+ /**
3737 * TODO: generalize this test to be reusable for different skins
3838 */
3939 public function testEditExistingPageMonobook() {
40 -
 40+
4141 }
42 -
 42+
4343 public function testImageUpload() {
4444 $this->login();
4545 $this->open( $this->getUrl() .
@@ -48,10 +48,10 @@
4949 $this->check( 'wpIgnoreWarning' );
5050 $this->click( 'wpUpload' );
5151 $this->waitForPageToLoad( 30000 );
52 -
 52+
5353 $this->assertSeleniumHTMLContains(
5454 '//h1[@class="firstHeading"]', "Wikipedia-logo-v2-de.png" );
55 -
 55+
5656 /*
5757 $this->open( $this->getUrl() . '/index.php?title=Image:'
5858 . ucfirst( $this->filename ) . '&action=delete' );
@@ -64,6 +64,6 @@
6565 ucfirst( $this->filename ) . '.*has been deleted.' );
6666 */
6767 }
68 -
6968
 69+
7070 }
Index: trunk/phase3/tests/selenium/suites/SimpleSeleniumTestCase.php
@@ -1,11 +1,11 @@
22 <?php
3 -/*
 3+/*
44 * This test case is part of the SimpleSeleniumTestSuite.
55 * Configuration for these tests are documented as part of SimpleSeleniumTestSuite.php
66 */
77 class SimpleSeleniumTestCase extends SeleniumTestCase {
88 public function testBasic() {
9 - $this->open( $this->getUrl() .
 9+ $this->open( $this->getUrl() .
1010 '/index.php?title=Selenium&action=edit' );
1111 $this->type( "wpTextbox1", "This is a basic test" );
1212 $this->click( "wpPreview" );
@@ -16,8 +16,8 @@
1717 $correct = strstr( $source, "This is a basic test" );
1818 $this->assertEquals( $correct, true );
1919 }
20 -
21 - /*
 20+
 21+ /**
2222 * All this test really does is verify that a global var was set.
2323 * It depends on $wgDefaultSkin = 'chick'; being set
2424 */
@@ -26,9 +26,9 @@
2727 $bodyClass = $this->getAttribute( "//body/@class" );
2828 $this-> assertContains('skin-chick', $bodyClass, 'Chick skin not set');
2929 }
30 -
31 - /*
32 - * Just verify that the test db was loaded correctly
 30+
 31+ /**
 32+ * Just verify that the test db was loaded correctly
3333 */
3434 public function testDatabaseResourceLoadedCorrectly() {
3535 $this->open( $this->getUrl() . '/index.php/TestResources?action=purge' );
Index: trunk/phase3/tests/selenium/SeleniumConfig.php
@@ -5,7 +5,7 @@
66
77 class SeleniumConfig {
88
9 - /*
 9+ /**
1010 * Retreives the Selenium configuration values from an ini file.
1111 * See sample config file in selenium_settings.ini.sample
1212 *
@@ -72,14 +72,14 @@
7373 return false;
7474 }
7575 $header = '';
76 -
 76+
7777 $configArray = array();
78 -
 78+
7979 while ( ( $line = fgets( $file ) ) !== false ) {
8080 $line = strtok( $line, "\r\n" );
81 -
 81+
8282 if ( !$line || $line[0] == ';' ) continue;
83 -
 83+
8484 if ( $line[0] == '[' && substr( $line, -1 ) == ']' ) {
8585 $header = substr( $line, 1, -1 );
8686 $configArray[$header] = array();
@@ -95,19 +95,19 @@
9696 list( $key, $value ) = explode( '=', $iniLine, 2 );
9797 $key = trim( $key );
9898 $value = trim( $value );
99 -
 99+
100100 if ( isset( $specialValues[$value] ) ) {
101101 $value = $specialValues[$value];
102102 } else {
103103 $value = trim( $value, '"' );
104104 }
105 -
 105+
106106 /* Support one-level arrays */
107107 if ( preg_match( '/^([A-Za-z]+)\[([A-Za-z]+)\]/', $key, $m ) ) {
108108 $key = $m[1];
109109 $value = array( $m[2] => $value );
110110 }
111 -
 111+
112112 return array( $key => $value );
113113 }
114114 }
Index: trunk/phase3/tests/phpunit/includes/search/SearchEngineTest.php
@@ -12,7 +12,7 @@
1313 unset( $this->search );
1414 }
1515
16 - /*
 16+ /**
1717 * Checks for database type & version.
1818 * Will skip current test if DB does not support search.
1919 */
Index: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
@@ -729,7 +729,7 @@
730730 }
731731 //Various "cleanup" functions
732732
733 - /*
 733+ /**
734734 * Run the "tidy" command on text if the $wgUseTidy
735735 * global is true
736736 *
Index: trunk/phase3/tests/phpunit/includes/IPTest.php
@@ -43,20 +43,20 @@
4444 $this->assertFalse( IP::isIPv6( 'fc:100:::' ), 'IPv6 ending with a ":::"' );
4545 $this->assertFalse( IP::isIPv6( 'fc:300' ), 'IPv6 with only 2 words' );
4646 $this->assertFalse( IP::isIPv6( 'fc:100:300' ), 'IPv6 with only 3 words' );
47 -
 47+
4848 $this->assertTrue( IP::isIPv6( 'fc:100::' ) );
4949 $this->assertTrue( IP::isIPv6( 'fc:100:a::' ) );
5050 $this->assertTrue( IP::isIPv6( 'fc:100:a:d::' ) );
5151 $this->assertTrue( IP::isIPv6( 'fc:100:a:d:1::' ) );
5252 $this->assertTrue( IP::isIPv6( 'fc:100:a:d:1:e::' ) );
5353 $this->assertTrue( IP::isIPv6( 'fc:100:a:d:1:e:ac::' ) );
54 -
 54+
5555 $this->assertFalse( IP::isIPv6( 'fc:100:a:d:1:e:ac:0::' ), 'IPv6 with 8 words ending with "::"' );
5656 $this->assertFalse( IP::isIPv6( 'fc:100:a:d:1:e:ac:0:1::' ), 'IPv6 with 9 words ending with "::"' );
5757
5858 $this->assertFalse( IP::isIPv6( ':::' ) );
5959 $this->assertFalse( IP::isIPv6( '::0:' ), 'IPv6 ending in a lone ":"' );
60 -
 60+
6161 $this->assertTrue( IP::isIPv6( '::' ), 'IPv6 zero address' );
6262 $this->assertTrue( IP::isIPv6( '::0' ) );
6363 $this->assertTrue( IP::isIPv6( '::fc' ) );
@@ -66,14 +66,14 @@
6767 $this->assertTrue( IP::isIPv6( '::fc:100:a:d:1' ) );
6868 $this->assertTrue( IP::isIPv6( '::fc:100:a:d:1:e' ) );
6969 $this->assertTrue( IP::isIPv6( '::fc:100:a:d:1:e:ac' ) );
70 -
 70+
7171 $this->assertFalse( IP::isIPv6( '::fc:100:a:d:1:e:ac:0' ), 'IPv6 with "::" and 8 words' );
7272 $this->assertFalse( IP::isIPv6( '::fc:100:a:d:1:e:ac:0:1' ), 'IPv6 with 9 words' );
7373
7474 $this->assertFalse( IP::isIPv6( ':fc::100' ), 'IPv6 starting with lone ":"' );
7575 $this->assertFalse( IP::isIPv6( 'fc::100:' ), 'IPv6 ending with lone ":"' );
7676 $this->assertFalse( IP::isIPv6( 'fc:::100' ), 'IPv6 with ":::" in the middle' );
77 -
 77+
7878 $this->assertTrue( IP::isIPv6( 'fc::100' ), 'IPv6 with "::" and 2 words' );
7979 $this->assertTrue( IP::isIPv6( 'fc::100:a' ), 'IPv6 with "::" and 3 words' );
8080 $this->assertTrue( IP::isIPv6( 'fc::100:a:d', 'IPv6 with "::" and 4 words' ) );
@@ -83,7 +83,7 @@
8484 $this->assertTrue( IP::isIPv6( '2001::df'), 'IPv6 with "::" and 2 words' );
8585 $this->assertTrue( IP::isIPv6( '2001:5c0:1400:a::df'), 'IPv6 with "::" and 5 words' );
8686 $this->assertTrue( IP::isIPv6( '2001:5c0:1400:a::df:2'), 'IPv6 with "::" and 6 words' );
87 -
 87+
8888 $this->assertFalse( IP::isIPv6( 'fc::100:a:d:1:e:ac:0' ), 'IPv6 with "::" and 8 words' );
8989 $this->assertFalse( IP::isIPv6( 'fc::100:a:d:1:e:ac:0:1' ), 'IPv6 with 9 words' );
9090
@@ -135,11 +135,11 @@
136136 $this->assertFalse( IP::isValid( 'fc:100:::' ), 'IPv6 ending with a ":::"' );
137137 $this->assertFalse( IP::isValid( 'fc:300' ), 'IPv6 with only 2 words' );
138138 $this->assertFalse( IP::isValid( 'fc:100:300' ), 'IPv6 with only 3 words' );
139 -
 139+
140140 $this->assertTrue( IP::isValid( 'fc:100::' ) );
141141 $this->assertTrue( IP::isValid( 'fc:100:a:d:1:e::' ) );
142142 $this->assertTrue( IP::isValid( 'fc:100:a:d:1:e:ac::' ) );
143 -
 143+
144144 $this->assertTrue( IP::isValid( 'fc::100' ), 'IPv6 with "::" and 2 words' );
145145 $this->assertTrue( IP::isValid( 'fc::100:a' ), 'IPv6 with "::" and 3 words' );
146146 $this->assertTrue( IP::isValid( '2001::df'), 'IPv6 with "::" and 2 words' );
@@ -147,7 +147,7 @@
148148 $this->assertTrue( IP::isValid( '2001:5c0:1400:a::df:2'), 'IPv6 with "::" and 6 words' );
149149 $this->assertTrue( IP::isValid( 'fc::100:a:d:1' ), 'IPv6 with "::" and 5 words' );
150150 $this->assertTrue( IP::isValid( 'fc::100:a:d:1:e:ac' ), 'IPv6 with "::" and 7 words' );
151 -
 151+
152152 $this->assertFalse( IP::isValid( 'fc:100:a:d:1:e:ac:0::' ), 'IPv6 with 8 words ending with "::"' );
153153 $this->assertFalse( IP::isValid( 'fc:100:a:d:1:e:ac:0:1::' ), 'IPv6 with 9 words ending with "::"' );
154154 }
@@ -332,7 +332,7 @@
333333 $this->assertEquals( '0:0:0:0:0:0:FCCF:FAFF', IP::hexToOctet( 'FCCFFAFF' ) );
334334 }
335335
336 - /*
 336+ /**
337337 * IP::parseCIDR() returns an array containing a signed IP address
338338 * representing the network mask and the bit mask.
339339 * @covers IP::parseCIDR
@@ -391,7 +391,7 @@
392392 }
393393
394394 /**
395 - * Issues there are most probably from IP::toHex() or IP::parseRange()
 395+ * Issues there are most probably from IP::toHex() or IP::parseRange()
396396 * @covers IP::isInRange
397397 * @dataProvider provideIPsAndRanges
398398 */
@@ -464,9 +464,9 @@
465465 */
466466 function testCombineHostAndPort( $expected, $input, $description ) {
467467 list( $host, $port, $defaultPort ) = $input;
468 - $this->assertEquals(
469 - $expected,
470 - IP::combineHostAndPort( $host, $port, $defaultPort ),
 468+ $this->assertEquals(
 469+ $expected,
 470+ IP::combineHostAndPort( $host, $port, $defaultPort ),
471471 $description );
472472 }
473473
Index: trunk/phase3/tests/phpunit/includes/SeleniumConfigurationTest.php
@@ -2,13 +2,13 @@
33
44 class SeleniumConfigurationTest extends MediaWikiTestCase {
55
6 - /*
 6+ /**
77 * The file where the test temporarity stores the selenium config.
88 * This should be cleaned up as part of teardown.
99 */
1010 private $tempFileName;
1111
12 - /*
 12+ /**
1313 * String containing the a sample selenium settings
1414 */
1515 private $testConfig0 =
@@ -32,14 +32,14 @@
3333 testSuite[SimpleSeleniumTestSuite] = "tests/selenium/SimpleSeleniumTestSuite.php"
3434 testSuite[TestSuiteName] = "testSuitePath"
3535 ';
36 - /*
 36+ /**
3737 * Array of expected browsers from $testConfig0
3838 */
3939 private $testBrowsers0 = array( 'firefox' => '*firefox',
4040 'iexplorer' => '*iexploreproxy',
4141 'chrome' => '*chrome'
4242 );
43 - /*
 43+ /**
4444 * Array of expected selenium settings from $testConfig0
4545 */
4646 private $testSettings0 = array(
@@ -55,7 +55,7 @@
5656 'jUnitLogFile' => null,
5757 'runAgainstGrid' => null
5858 );
59 - /*
 59+ /**
6060 * Array of expected testSuites from $testConfig0
6161 */
6262 private $testSuites0 = array(
@@ -64,7 +64,7 @@
6565 );
6666
6767
68 - /*
 68+ /**
6969 * Another sample selenium settings file contents
7070 */
7171 private $testConfig1 =
@@ -73,11 +73,11 @@
7474 host = "localhost"
7575 testBrowser = "firefox"
7676 ';
77 - /*
 77+ /**
7878 * Expected browsers from $testConfig1
7979 */
8080 private $testBrowsers1 = null;
81 - /*
 81+ /**
8282 * Expected selenium settings from $testConfig1
8383 */
8484 private $testSettings1 = array(
@@ -93,7 +93,7 @@
9494 'jUnitLogFile' => null,
9595 'runAgainstGrid' => null
9696 );
97 - /*
 97+ /**
9898 * Expected test suites from $testConfig1
9999 */
100100 private $testSuites1 = null;
@@ -105,7 +105,7 @@
106106 }
107107 }
108108
109 - /*
 109+ /**
110110 * Clean up the temporary file used to store the selenium settings.
111111 */
112112 public function tearDown() {
@@ -199,7 +199,7 @@
200200
201201 }
202202
203 - /*
 203+ /**
204204 * create a temp file and write text to it.
205205 * @param $testToWrite the text to write to the temp file
206206 */
@@ -210,7 +210,7 @@
211211 fclose($tempFile);
212212 }
213213
214 - /*
 214+ /**
215215 * Returns an array containing:
216216 * The contents of the selenium cingiguration ini file
217217 * The expected selenium configuration array that getSeleniumSettings should return
Index: trunk/phase3/tests/parser/parserTest.inc
@@ -1199,7 +1199,7 @@
12001200 return true;
12011201 }
12021202
1203 - /*
 1203+ /**
12041204 * Run the "tidy" command on text if the $wgUseTidy
12051205 * global is true
12061206 *
Index: trunk/phase3/includes/WikiFilePage.php
@@ -25,13 +25,15 @@
2626
2727 /**
2828 * @param $file File:
29 - * @return void
3029 */
3130 public function setFile( $file ) {
3231 $this->mFile = $file;
3332 $this->mFileLoaded = true;
3433 }
3534
 35+ /**
 36+ * @return bool
 37+ */
3638 protected function loadFile() {
3739 if ( $this->mFileLoaded ) {
3840 return true;
@@ -49,6 +51,9 @@
5052 return true;
5153 }
5254
 55+ /**
 56+ * @return mixed|null|Title
 57+ */
5358 public function getRedirectTarget() {
5459 $this->loadFile();
5560 if ( $this->mFile->isLocal() ) {
@@ -63,6 +68,9 @@
6469 return $this->mRedirectTarget = Title::makeTitle( NS_FILE, $to );
6570 }
6671
 72+ /**
 73+ * @return bool|mixed|Title
 74+ */
6775 public function followRedirect() {
6876 $this->loadFile();
6977 if ( $this->mFile->isLocal() ) {
@@ -76,6 +84,10 @@
7785 return Title::makeTitle( NS_FILE, $to );
7886 }
7987
 88+ /**
 89+ * @param bool $text
 90+ * @return bool
 91+ */
8092 public function isRedirect( $text = false ) {
8193 $this->loadFile();
8294 if ( $this->mFile->isLocal() ) {
@@ -85,16 +97,25 @@
8698 return (bool)$this->mFile->getRedirected();
8799 }
88100
 101+ /**
 102+ * @return bool
 103+ */
89104 public function isLocal() {
90105 $this->loadFile();
91106 return $this->mFile->isLocal();
92107 }
93108
 109+ /**
 110+ * @return bool|File
 111+ */
94112 public function getFile() {
95113 $this->loadFile();
96114 return $this->mFile;
97115 }
98116
 117+ /**
 118+ * @return array|null
 119+ */
99120 public function getDuplicates() {
100121 $this->loadFile();
101122 if ( !is_null( $this->mDupes ) ) {
@@ -108,6 +129,10 @@
109130 // Remove duplicates with self and non matching file sizes
110131 $self = $this->mFile->getRepoName() . ':' . $this->mFile->getName();
111132 $size = $this->mFile->getSize();
 133+
 134+ /**
 135+ * @var $file File
 136+ */
112137 foreach ( $dupes as $index => $file ) {
113138 $key = $file->getRepoName() . ':' . $file->getName();
114139 if ( $key == $self ) {
Index: trunk/phase3/includes/ZhClient.php
@@ -41,10 +41,7 @@
4242 $errno = $errstr = '';
4343 $this->mFP = fsockopen( $this->mHost, $this->mPort, $errno, $errstr, 30 );
4444 wfRestoreWarnings();
45 - if ( !$this->mFP ) {
46 - return false;
47 - }
48 - return true;
 45+ return !$this->mFP;
4946 }
5047
5148 /**
@@ -77,10 +74,7 @@
7875 $data .= $str;
7976 }
8077 // data should be of length $len. otherwise something is wrong
81 - if ( strlen( $data ) != $len ) {
82 - return false;
83 - }
84 - return $data;
 78+ return strlen( $data ) == $len;
8579 }
8680
8781 /**
@@ -124,6 +118,7 @@
125119 }
126120 return $ret;
127121 }
 122+
128123 /**
129124 * Perform word segmentation
130125 *
Index: trunk/phase3/includes/WebRequest.php
@@ -1192,6 +1192,10 @@
11931193 $this->session = $session;
11941194 }
11951195
 1196+ /**
 1197+ * @param $method string
 1198+ * @throws MWException
 1199+ */
11961200 private function notImplemented( $method ) {
11971201 throw new MWException( "{$method}() not implemented" );
11981202 }
Index: trunk/phase3/includes/WikiMap.php
@@ -28,7 +28,7 @@
2929 array( 'lang' => $minor, 'site' => $major ) );
3030 return new WikiReference( $major, $minor, $canonicalServer, $path, $server );
3131 }
32 -
 32+
3333 /**
3434 * Convenience to get the wiki's display name
3535 *
@@ -87,11 +87,11 @@
8888 */
8989 public static function getForeignURL( $wikiID, $page ) {
9090 $wiki = WikiMap::getWiki( $wikiID );
91 -
 91+
9292 if ( $wiki ) {
9393 return $wiki->getUrl( $page );
9494 }
95 -
 95+
9696 return false;
9797 }
9898 }
@@ -114,6 +114,10 @@
115115 $this->mServer = $server === null ? $canonicalServer : $server;
116116 }
117117
 118+ /**
 119+ * @return string
 120+ * @throws MWException
 121+ */
118122 public function getHostname() {
119123 $prefixes = array( 'http://', 'https://' );
120124 foreach ( $prefixes as $prefix ) {
@@ -159,22 +163,21 @@
160164 * @return String: Url
161165 */
162166 public function getCanonicalUrl( $page ) {
163 - return
164 - $this->mCanonicalServer .
165 - $this->getLocalUrl( $page );
 167+ return $this->mCanonicalServer . $this->getLocalUrl( $page );
166168 }
167 -
 169+
168170 /**
169171 * Alias for getCanonicalUrl(), for backwards compatibility.
 172+ * @return String
170173 */
171174 public function getUrl( $page ) {
172175 return $this->getCanonicalUrl( $page );
173176 }
174 -
 177+
175178 /**
176179 * Get a URL based on $wgServer, like Title::getFullUrl() would produce
177180 * when called locally on the wiki.
178 - *
 181+ *
179182 * @param $page String: page name (must be normalized before calling this function!)
180183 * @return String: URL
181184 */
Index: trunk/phase3/includes/WikiPage.php
@@ -26,8 +26,17 @@
2727 public $mIsRedirect = false; // !< Boolean
2828 public $mLatest = false; // !< Boolean
2929 public $mPreparedEdit = false; // !< Array
30 - public $mRedirectTarget = null; // !< Title object
31 - public $mLastRevision = null; // !< Revision object
 30+
 31+ /**
 32+ * @var Title
 33+ */
 34+ public $mRedirectTarget = null;
 35+
 36+ /**
 37+ * @var Revision
 38+ */
 39+ public $mLastRevision = null;
 40+
3241 public $mTimestamp = ''; // !< String
3342 public $mTouched = '19700101000000'; // !< String
3443 /**@}}*/
@@ -700,6 +709,7 @@
701710 * Should the parser cache be used?
702711 *
703712 * @param $user User The relevant user
 713+ * @param $oldid int
704714 * @return boolean
705715 */
706716 public function isParserCacheUsed( User $user, $oldid ) {
@@ -756,7 +766,6 @@
757767 *
758768 * @param $dbw DatabaseBase
759769 * @return int The newly created page_id key, or false if the title already existed
760 - * @private
761770 */
762771 public function insertOn( $dbw ) {
763772 wfProfileIn( __METHOD__ );
@@ -1585,7 +1594,7 @@
15861595 * Deletes the article with database consistency, writes logs, purges caches
15871596 *
15881597 * @param $reason string delete reason for deletion log
1589 - * @param suppress bitfield
 1598+ * @param $suppress bitfield
15901599 * Revision::DELETED_TEXT
15911600 * Revision::DELETED_COMMENT
15921601 * Revision::DELETED_USER
@@ -2585,7 +2594,7 @@
25862595 * Updates cascading protections
25872596 *
25882597 * @param $parserOutput ParserOutput object for the current version
2589 - **/
 2598+ */
25902599 public function doCascadeProtectionUpdates( ParserOutput $parserOutput ) {
25912600 if ( wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) {
25922601 return;
@@ -2632,25 +2641,25 @@
26332642 }
26342643 }
26352644
2636 - /*
2637 - * @deprecated since 1.18
2638 - */
 2645+ /**
 2646+ * @deprecated since 1.18
 2647+ */
26392648 public function quickEdit( $text, $comment = '', $minor = 0 ) {
26402649 global $wgUser;
26412650 return $this->doQuickEdit( $text, $wgUser, $comment, $minor );
26422651 }
26432652
2644 - /*
2645 - * @deprecated since 1.18
2646 - */
 2653+ /**
 2654+ * @deprecated since 1.18
 2655+ */
26472656 public function viewUpdates() {
26482657 global $wgUser;
26492658 return $this->doViewUpdates( $wgUser );
26502659 }
26512660
2652 - /*
2653 - * @deprecated since 1.18
2654 - */
 2661+ /**
 2662+ * @deprecated since 1.18
 2663+ */
26552664 public function useParserCache( $oldid ) {
26562665 global $wgUser;
26572666 return $this->isParserCacheUsed( $wgUser, $oldid );
Index: trunk/phase3/includes/ZipDirectoryReader.php
@@ -1,8 +1,8 @@
22 <?php
33
44 /**
5 - * A class for reading ZIP file directories, for the purposes of upload
6 - * verification.
 5+ * A class for reading ZIP file directories, for the purposes of upload
 6+ * verification.
77 *
88 * Only a functional interface is provided: ZipFileReader::read(). No access is
99 * given to object instances.
@@ -12,7 +12,7 @@
1313 /**
1414 * Read a ZIP file and call a function for each file discovered in it.
1515 *
16 - * Because this class is aimed at verification, an error is raised on
 16+ * Because this class is aimed at verification, an error is raised on
1717 * suspicious or ambiguous input, instead of emulating some standard
1818 * behaviour.
1919 *
@@ -20,7 +20,7 @@
2121 * @param $callback Array The callback function. It will be called for each file
2222 * with a single associative array each time, with members:
2323 *
24 - * - name: The file name. Directories conventionally have a trailing
 24+ * - name: The file name. Directories conventionally have a trailing
2525 * slash.
2626 *
2727 * - mtime: The file modification time, in MediaWiki 14-char format
@@ -30,18 +30,18 @@
3131 * @param $options Array An associative array of read options, with the option
3232 * name in the key. This may currently contain:
3333 *
34 - * - zip64: If this is set to true, then we will emulate a
35 - * library with ZIP64 support, like OpenJDK 7. If it is set to
36 - * false, then we will emulate a library with no knowledge of
 34+ * - zip64: If this is set to true, then we will emulate a
 35+ * library with ZIP64 support, like OpenJDK 7. If it is set to
 36+ * false, then we will emulate a library with no knowledge of
3737 * ZIP64.
3838 *
39 - * NOTE: The ZIP64 code is untested and probably doesn't work. It
40 - * turned out to be easier to just reject ZIP64 archive uploads,
41 - * since they are likely to be very rare. Confirming safety of a
42 - * ZIP64 file is fairly complex. What do you do with a file that is
43 - * ambiguous and broken when read with a non-ZIP64 reader, but valid
44 - * when read with a ZIP64 reader? This situation is normal for a
45 - * valid ZIP64 file, and working out what non-ZIP64 readers will make
 39+ * NOTE: The ZIP64 code is untested and probably doesn't work. It
 40+ * turned out to be easier to just reject ZIP64 archive uploads,
 41+ * since they are likely to be very rare. Confirming safety of a
 42+ * ZIP64 file is fairly complex. What do you do with a file that is
 43+ * ambiguous and broken when read with a non-ZIP64 reader, but valid
 44+ * when read with a ZIP64 reader? This situation is normal for a
 45+ * valid ZIP64 file, and working out what non-ZIP64 readers will make
4646 * of such a file is not trivial.
4747 *
4848 * @return Status object. The following fatal errors are defined:
@@ -50,20 +50,20 @@
5151 *
5252 * - zip-wrong-format: The file does not appear to be a ZIP file.
5353 *
54 - * - zip-bad: There was something wrong or ambiguous about the file
 54+ * - zip-bad: There was something wrong or ambiguous about the file
5555 * data.
5656 *
57 - * - zip-unsupported: The ZIP file uses features which
 57+ * - zip-unsupported: The ZIP file uses features which
5858 * ZipDirectoryReader does not support.
5959 *
60 - * The default messages for those fatal errors are written in a way that
 60+ * The default messages for those fatal errors are written in a way that
6161 * makes sense for upload verification.
6262 *
63 - * If a fatal error is returned, more information about the error will be
 63+ * If a fatal error is returned, more information about the error will be
6464 * available in the debug log.
6565 *
6666 * Note that the callback function may be called any number of times before
67 - * a fatal error is returned. If this occurs, the data sent to the callback
 67+ * a fatal error is returned. If this occurs, the data sent to the callback
6868 * function should be discarded.
6969 */
7070 public static function read( $fileName, $callback, $options = array() ) {
@@ -92,6 +92,8 @@
9393 /** Stored headers */
9494 var $eocdr, $eocdr64, $eocdr64Locator;
9595
 96+ var $data;
 97+
9698 /** The "extra field" ID for ZIP64 central directory entries */
9799 const ZIP64_EXTRA_HEADER = 0x0001;
98100
@@ -104,7 +106,6 @@
105107 /** The index of the "general field" bit for central directory encryption */
106108 const GENERAL_CD_ENCRYPTED = 13;
107109
108 -
109110 /**
110111 * Private constructor
111112 */
@@ -165,8 +166,8 @@
166167 }
167168
168169 /**
169 - * Read the header which is at the end of the central directory,
170 - * unimaginatively called the "end of central directory record" by the ZIP
 170+ * Read the header which is at the end of the central directory,
 171+ * unimaginatively called the "end of central directory record" by the ZIP
171172 * spec.
172173 */
173174 function readEndOfCentralDirectoryRecord() {
@@ -189,7 +190,7 @@
190191 $block = $this->getBlock( $startPos );
191192 $sigPos = strrpos( $block, "PK\x05\x06" );
192193 if ( $sigPos === false ) {
193 - $this->error( 'zip-wrong-format',
 194+ $this->error( 'zip-wrong-format',
194195 "zip file lacks EOCDR signature. It probably isn't a zip file." );
195196 }
196197
@@ -212,7 +213,7 @@
213214 }
214215
215216 /**
216 - * Read the header called the "ZIP64 end of central directory locator". An
 217+ * Read the header called the "ZIP64 end of central directory locator". An
217218 * error will be raised if it does not exist.
218219 */
219220 function readZip64EndOfCentralDirectoryLocator() {
@@ -224,20 +225,20 @@
225226 );
226227 $structSize = $this->getStructSize( $info );
227228
228 - $block = $this->getBlock( $this->getFileLength() - $this->eocdr['EOCDR size']
 229+ $block = $this->getBlock( $this->getFileLength() - $this->eocdr['EOCDR size']
229230 - $structSize, $structSize );
230231 $this->eocdr64Locator = $data = $this->unpack( $block, $info );
231232
232233 if ( $data['signature'] !== "PK\x06\x07" ) {
233 - // Note: Java will allow this and continue to read the
234 - // EOCDR64, so we have to reject the upload, we can't
 234+ // Note: Java will allow this and continue to read the
 235+ // EOCDR64, so we have to reject the upload, we can't
235236 // just use the EOCDR header instead.
236237 $this->error( 'zip-bad', 'wrong signature on Zip64 end of central directory locator' );
237238 }
238239 }
239240
240241 /**
241 - * Read the header called the "ZIP64 end of central directory record". It
 242+ * Read the header called the "ZIP64 end of central directory record". It
242243 * may replace the regular "end of central directory record" in ZIP64 files.
243244 */
244245 function readZip64EndOfCentralDirectoryRecord() {
@@ -266,14 +267,14 @@
267268 $this->error( 'zip-bad', 'wrong signature on Zip64 end of central directory record' );
268269 }
269270 if ( $data['disk'] !== 0
270 - || $data['CD start disk'] !== 0 )
 271+ || $data['CD start disk'] !== 0 )
271272 {
272273 $this->error( 'zip-unsupported', 'more than one disk (in EOCDR64)' );
273274 }
274275 }
275276
276277 /**
277 - * Find the location of the central directory, as would be seen by a
 278+ * Find the location of the central directory, as would be seen by a
278279 * non-ZIP64 reader.
279280 *
280281 * @return List containing offset, size and end position.
@@ -286,27 +287,27 @@
287288 // Some readers use the EOCDR position instead of the offset field
288289 // to find the directory, so to be safe, we check if they both agree.
289290 if ( $offset + $size != $endPos ) {
290 - $this->error( 'zip-bad', 'the central directory does not immediately precede the end ' .
 291+ $this->error( 'zip-bad', 'the central directory does not immediately precede the end ' .
291292 'of central directory record' );
292293 }
293294 return array( $offset, $size );
294295 }
295296
296297 /**
297 - * Find the location of the central directory, as would be seen by a
 298+ * Find the location of the central directory, as would be seen by a
298299 * ZIP64-compliant reader.
299300 *
300301 * @return List containing offset, size and end position.
301302 */
302303 function findZip64CentralDirectory() {
303 - // The spec is ambiguous about the exact rules of precedence between the
304 - // ZIP64 headers and the original headers. Here we follow zip_util.c
 304+ // The spec is ambiguous about the exact rules of precedence between the
 305+ // ZIP64 headers and the original headers. Here we follow zip_util.c
305306 // from OpenJDK 7.
306307 $size = $this->eocdr['CD size'];
307308 $offset = $this->eocdr['CD offset'];
308309 $numEntries = $this->eocdr['CD entries total'];
309310 $endPos = $this->eocdr['position'];
310 - if ( $size == 0xffffffff
 311+ if ( $size == 0xffffffff
311312 || $offset == 0xffffffff
312313 || $numEntries == 0xffff )
313314 {
@@ -324,7 +325,7 @@
325326 // Some readers use the EOCDR position instead of the offset field
326327 // to find the directory, so to be safe, we check if they both agree.
327328 if ( $offset + $size != $endPos ) {
328 - $this->error( 'zip-bad', 'the central directory does not immediately precede the end ' .
 329+ $this->error( 'zip-bad', 'the central directory does not immediately precede the end ' .
329330 'of central directory record' );
330331 }
331332 return array( $offset, $size );
@@ -390,7 +391,7 @@
391392 }
392393
393394 // Convert the timestamp into MediaWiki format
394 - // For the format, please see the MS-DOS 2.0 Programmer's Reference,
 395+ // For the format, please see the MS-DOS 2.0 Programmer's Reference,
395396 // pages 3-5 and 3-6.
396397 $time = $data['mod time'];
397398 $date = $data['mod date'];
@@ -405,8 +406,8 @@
406407 $year, $month, $day, $hour, $minute, $second );
407408
408409 // Convert the character set in the file name
409 - if ( !function_exists( 'iconv' )
410 - || $this->testBit( $data['general bits'], self::GENERAL_UTF8 ) )
 410+ if ( !function_exists( 'iconv' )
 411+ || $this->testBit( $data['general bits'], self::GENERAL_UTF8 ) )
411412 {
412413 $name = $data['name'];
413414 } else {
@@ -444,7 +445,7 @@
445446 while ( $extraPos < strlen( $extraField ) ) {
446447 $extra = $this->unpack( $extraField, $extraHeaderInfo, $extraPos );
447448 $extraPos += $extraHeaderSize;
448 - $extra += $this->unpack( $extraField,
 449+ $extra += $this->unpack( $extraField,
449450 array( 'data' => array( 'string', $extra['size'] ) ),
450451 $extraPos );
451452 $extraPos += $extra['size'];
@@ -473,7 +474,7 @@
474475 * in the file to satisfy the request, an exception will be thrown.
475476 *
476477 * @param $start The byte offset of the start of the block.
477 - * @param $length The number of bytes to return. If omitted, the remainder
 478+ * @param $length The number of bytes to return. If omitted, the remainder
478479 * of the file will be returned.
479480 *
480481 * @return string
@@ -500,10 +501,10 @@
501502 $block .= $this->getSegment( $segIndex );
502503 }
503504
504 - $block = substr( $block,
 505+ $block = substr( $block,
505506 $start - $startSeg * self::SEGSIZE,
506507 $length );
507 -
 508+
508509 if ( strlen( $block ) < $length ) {
509510 $this->error( 'zip-bad', 'getBlock() returned an unexpectedly small amount of data' );
510511 }
@@ -512,12 +513,12 @@
513514 }
514515
515516 /**
516 - * Get a section of the file starting at position $segIndex * self::SEGSIZE,
517 - * of length self::SEGSIZE. The result is cached. This is a helper function
 517+ * Get a section of the file starting at position $segIndex * self::SEGSIZE,
 518+ * of length self::SEGSIZE. The result is cached. This is a helper function
518519 * for getBlock().
519520 *
520 - * If there are not enough bytes in the file to satsify the request, the
521 - * return value will be truncated. If a request is made for a segment beyond
 521+ * If there are not enough bytes in the file to satsify the request, the
 522+ * return value will be truncated. If a request is made for a segment beyond
522523 * the end of the file, an empty string will be returned.
523524 */
524525 function getSegment( $segIndex ) {
@@ -556,25 +557,25 @@
557558 }
558559
559560 /**
560 - * Unpack a binary structure. This is like the built-in unpack() function
 561+ * Unpack a binary structure. This is like the built-in unpack() function
561562 * except nicer.
562563 *
563564 * @param $string The binary data input
564565 *
565 - * @param $struct An associative array giving structure members and their
566 - * types. In the key is the field name. The value may be either an
567 - * integer, in which case the field is a little-endian unsigned integer
568 - * encoded in the given number of bytes, or an array, in which case the
569 - * first element of the array is the type name, and the subsequent
 566+ * @param $struct An associative array giving structure members and their
 567+ * types. In the key is the field name. The value may be either an
 568+ * integer, in which case the field is a little-endian unsigned integer
 569+ * encoded in the given number of bytes, or an array, in which case the
 570+ * first element of the array is the type name, and the subsequent
570571 * elements are type-dependent parameters. Only one such type is defined:
571 - * - "string": The second array element gives the length of string.
 572+ * - "string": The second array element gives the length of string.
572573 * Not null terminated.
573574 *
574575 * @param $offset The offset into the string at which to start unpacking.
575576 *
576 - * @return Unpacked associative array. Note that large integers in the input
577 - * may be represented as floating point numbers in the return value, so
578 - * the use of weak comparison is advised.
 577+ * @return Unpacked associative array. Note that large integers in the input
 578+ * may be represented as floating point numbers in the return value, so
 579+ * the use of weak comparison is advised.
579580 */
580581 function unpack( $string, $struct, $offset = 0 ) {
581582 $size = $this->getStructSize( $struct );
@@ -600,8 +601,8 @@
601602 $length = intval( $type );
602603 $bytes = substr( $string, $pos, $length );
603604
604 - // Calculate the value. Use an algorithm which automatically
605 - // upgrades the value to floating point if necessary.
 605+ // Calculate the value. Use an algorithm which automatically
 606+ // upgrades the value to floating point if necessary.
606607 $value = 0;
607608 for ( $i = $length - 1; $i >= 0; $i-- ) {
608609 $value *= 256;
@@ -623,7 +624,7 @@
624625 }
625626
626627 /**
627 - * Returns a bit from a given position in an integer value, converted to
 628+ * Returns a bit from a given position in an integer value, converted to
628629 * boolean.
629630 *
630631 * @param $value integer
@@ -678,6 +679,9 @@
679680 parent::__construct( "ZipDirectoryReader error: $code" );
680681 }
681682
 683+ /**
 684+ * @return mixed
 685+ */
682686 function getErrorCode() {
683687 return $this->code;
684688 }
Index: trunk/phase3/index.php5
@@ -1 +1 @@
2 -<?php require './index.php';
\ No newline at end of file
 2+<?php require './index.php';
Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -222,7 +222,7 @@
223223
224224 /* Public Members */
225225
226 - /*
 226+ /**
227227 * Dummy function which in debug mode can be replaced with a function that
228228 * emulates console.log in console-less environments.
229229 */
@@ -249,7 +249,7 @@
250250 */
251251 this.libs = {};
252252
253 - /*
 253+ /**
254254 * Localization system
255255 */
256256 this.messages = new this.Map();
@@ -556,7 +556,7 @@
557557 callback();
558558 return;
559559 }
560 -
 560+
561561 addScript( arr[i], function() {
562562 nestedAddScript( arr, callback, i + 1 );
563563 } );
@@ -1175,7 +1175,7 @@
11761176 } );
11771177 return names;
11781178 };
1179 -
 1179+
11801180 /**
11811181 * For backwards-compatibility with Squid-cached pages. Loads mw.user
11821182 */

Status & tagging log