Merge "Stop doing $that = $this in includes/changes"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 11 Feb 2016 02:26:06 +0000 (02:26 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 11 Feb 2016 02:26:06 +0000 (02:26 +0000)
12 files changed:
autoload.php
docs/hooks.txt
includes/WebResponse.php
includes/db/Database.php
includes/db/DatabaseSqlite.php
includes/diff/DiffFormatter.php
includes/diff/TableDiffFormatter.php
includes/diff/UnifiedDiffFormatter.php
includes/installer/Installer.php
includes/installer/InstallerSessionProvider.php [new file with mode: 0644]
includes/specialpage/QueryPage.php
tests/phpunit/phpunit.php

index 0a9d80c..d6e4077 100644 (file)
@@ -593,6 +593,7 @@ $wgAutoloadLocalClasses = array(
        'InstallDocFormatter' => __DIR__ . '/includes/installer/InstallDocFormatter.php',
        'Installer' => __DIR__ . '/includes/installer/Installer.php',
        'InstallerOverrides' => __DIR__ . '/mw-config/overrides.php',
+       'InstallerSessionProvider' => __DIR__ . '/includes/installer/InstallerSessionProvider.php',
        'Interwiki' => __DIR__ . '/includes/interwiki/Interwiki.php',
        'InvalidPassword' => __DIR__ . '/includes/password/InvalidPassword.php',
        'IteratorDecorator' => __DIR__ . '/includes/utils/iterators/IteratorDecorator.php',
index 79bc5f5..0fe888f 100644 (file)
@@ -3483,7 +3483,7 @@ Return false to prevent setting of the cookie.
 &$name: Cookie name passed to WebResponse::setcookie()
 &$value: Cookie value passed to WebResponse::setcookie()
 &$expire: Cookie expiration, as for PHP's setcookie()
-$options: Options passed to WebResponse::setcookie()
+&$options: Options passed to WebResponse::setcookie()
 
 'wfShellWikiCmd': Called when generating a shell-escaped command line string to
 run a MediaWiki cli script.
index fd48005..e46d86f 100644 (file)
@@ -128,7 +128,7 @@ class WebResponse {
 
                $func = $options['raw'] ? 'setrawcookie' : 'setcookie';
 
-               if ( Hooks::run( 'WebResponseSetCookie', array( &$name, &$value, &$expire, $options ) ) ) {
+               if ( Hooks::run( 'WebResponseSetCookie', array( &$name, &$value, &$expire, &$options ) ) ) {
                        $cookie = $options['prefix'] . $name;
                        $data = array(
                                'name' => (string)$cookie,
index 564cd2e..bd1e375 100644 (file)
@@ -1925,7 +1925,6 @@ abstract class DatabaseBase implements IDatabase {
        /**
         * Get the name of an index in a given table.
         *
-        * @protected Don't use outside of DatabaseBase and childs
         * @param string $index
         * @return string
         */
index bb3028d..664484b 100644 (file)
@@ -429,7 +429,7 @@ class DatabaseSqlite extends Database {
         * @param string $index
         * @return string
         */
-       function indexName( $index ) {
+       protected function indexName( $index ) {
                return $index;
        }
 
index 33ca931..23e39ea 100644 (file)
@@ -49,6 +49,9 @@ abstract class DiffFormatter {
         */
        protected $trailingContextLines = 0;
 
+       /** @var string The output buffer; holds the output while it is built. */
+       private $result = '';
+
        /**
         * Format a diff.
         *
@@ -146,15 +149,24 @@ abstract class DiffFormatter {
        }
 
        protected function startDiff() {
-               ob_start();
+               $this->result = '';
+       }
+
+       /**
+        * Writes a string to the output buffer.
+        *
+        * @param string $text
+        */
+       protected function writeOutput( $text ) {
+               $this->result .= $text;
        }
 
        /**
         * @return string
         */
        protected function endDiff() {
-               $val = ob_get_contents();
-               ob_end_clean();
+               $val = $this->result;
+               $this->result = '';
 
                return $val;
        }
@@ -185,7 +197,7 @@ abstract class DiffFormatter {
         * @param string $header
         */
        protected function startBlock( $header ) {
-               echo $header . "\n";
+               $this->writeOutput( $header . "\n" );
        }
 
        /**
@@ -203,7 +215,7 @@ abstract class DiffFormatter {
         */
        protected function lines( $lines, $prefix = ' ' ) {
                foreach ( $lines as $line ) {
-                       echo "$prefix $line\n";
+                       $this->writeOutput( "$prefix $line\n" );
                }
        }
 
@@ -236,7 +248,7 @@ abstract class DiffFormatter {
         */
        protected function changed( $orig, $closing ) {
                $this->deleted( $orig );
-               echo "---\n";
+               $this->writeOutput( "---\n" );
                $this->added( $closing );
        }
 
index be38e87..f1826ed 100644 (file)
@@ -80,7 +80,7 @@ class TableDiffFormatter extends DiffFormatter {
         * @param string $header
         */
        protected function startBlock( $header ) {
-               echo $header;
+               $this->writeOutput( $header );
        }
 
        protected function endBlock() {
@@ -157,9 +157,9 @@ class TableDiffFormatter extends DiffFormatter {
         */
        protected function added( $lines ) {
                foreach ( $lines as $line ) {
-                       echo '<tr>' . $this->emptyLine() .
+                       $this->writeOutput( '<tr>' . $this->emptyLine() .
                                $this->addedLine( '<ins class="diffchange">' .
-                                       htmlspecialchars( $line ) . '</ins>' ) . "</tr>\n";
+                                       htmlspecialchars( $line ) . '</ins>' ) . "</tr>\n" );
                }
        }
 
@@ -170,9 +170,9 @@ class TableDiffFormatter extends DiffFormatter {
         */
        protected function deleted( $lines ) {
                foreach ( $lines as $line ) {
-                       echo '<tr>' . $this->deletedLine( '<del class="diffchange">' .
+                       $this->writeOutput( '<tr>' . $this->deletedLine( '<del class="diffchange">' .
                                        htmlspecialchars( $line ) . '</del>' ) .
-                               $this->emptyLine() . "</tr>\n";
+                               $this->emptyLine() . "</tr>\n" );
                }
        }
 
@@ -183,9 +183,9 @@ class TableDiffFormatter extends DiffFormatter {
         */
        protected function context( $lines ) {
                foreach ( $lines as $line ) {
-                       echo '<tr>' .
+                       $this->writeOutput( '<tr>' .
                                $this->contextLine( htmlspecialchars( $line ) ) .
-                               $this->contextLine( htmlspecialchars( $line ) ) . "</tr>\n";
+                               $this->contextLine( htmlspecialchars( $line ) ) . "</tr>\n" );
                }
        }
 
@@ -207,13 +207,13 @@ class TableDiffFormatter extends DiffFormatter {
                $line = array_shift( $del );
                while ( $line ) {
                        $aline = array_shift( $add );
-                       echo '<tr>' . $this->deletedLine( $line ) .
-                               $this->addedLine( $aline ) . "</tr>\n";
+                       $this->writeOutput( '<tr>' . $this->deletedLine( $line ) .
+                               $this->addedLine( $aline ) . "</tr>\n" );
                        $line = array_shift( $del );
                }
                foreach ( $add as $line ) { # If any leftovers
-                       echo '<tr>' . $this->emptyLine() .
-                               $this->addedLine( $line ) . "</tr>\n";
+                       $this->writeOutput( '<tr>' . $this->emptyLine() .
+                               $this->addedLine( $line ) . "</tr>\n" );
                }
        }
 
index 5f3ad3d..72f1a66 100644 (file)
@@ -42,7 +42,7 @@ class UnifiedDiffFormatter extends DiffFormatter {
         */
        protected function lines( $lines, $prefix = ' ' ) {
                foreach ( $lines as $line ) {
-                       echo "{$prefix}{$line}\n";
+                       $this->writeOutput( "{$prefix}{$line}\n" );
                }
        }
 
index 40e51f0..0e8633d 100644 (file)
@@ -1785,6 +1785,15 @@ abstract class Installer {
 
                // Some of the environment checks make shell requests, remove limits
                $GLOBALS['wgMaxShellMemory'] = 0;
+
+               $GLOBALS['wgSessionProviders'] = array(
+                       array(
+                               'class' => 'InstallerSessionProvider',
+                               'args' => array( array(
+                                       'priority' => 1,
+                               ) )
+                       )
+               );
        }
 
        /**
diff --git a/includes/installer/InstallerSessionProvider.php b/includes/installer/InstallerSessionProvider.php
new file mode 100644 (file)
index 0000000..2b9f418
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/**
+ * Session provider which always provides the same session ID and doesn't
+ * persist the session. For use in the installer when ObjectCache doesn't
+ * work anyway.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Deployment
+ */
+
+use MediaWiki\Session\SessionProvider;
+use MediaWiki\Session\SessionBackend;
+use MediaWiki\Session\SessionInfo;
+
+class InstallerSessionProvider extends SessionProvider {
+       /**
+        * Pretend there is a session, to avoid MWCryptRand overhead
+        */
+       public function provideSessionInfo( WebRequest $request ) {
+               return new SessionInfo( 1, array(
+                       'provider' => $this,
+                       'id' => str_repeat( 'x', 32 ),
+               ) );
+       }
+
+       /**
+        * Yes we will treat your data with great care!
+        */
+       public function persistsSessionId() {
+               return true;
+       }
+
+       /**
+        * Sure, you can be whoever you want, as long as you have ID 0
+        */
+       public function canChangeUser() {
+               return true;
+       }
+
+       public function persistSession( SessionBackend $session, WebRequest $request ) {
+       }
+
+       public function unpersistSession( WebRequest $request ) {
+       }
+}
index 27e645a..bb26cf3 100644 (file)
@@ -336,13 +336,12 @@ abstract class QueryPage extends SpecialPage {
                                        );
                                }
 
-                               $that = $this;
                                $dbw->doAtomicSection(
                                        __METHOD__,
-                                       function ( IDatabase $dbw, $fname ) use ( $that, $vals ) {
+                                       function ( IDatabase $dbw, $fname ) use ( $vals ) {
                                                # Clear out any old cached data
                                                $dbw->delete( 'querycache',
-                                                       array( 'qc_type' => $that->getName() ),
+                                                       array( 'qc_type' => $this->getName() ),
                                                        $fname
                                                );
                                                # Save results into the querycache table on the master
@@ -351,11 +350,11 @@ abstract class QueryPage extends SpecialPage {
                                                }
                                                # Update the querycache_info record for the page
                                                $dbw->delete( 'querycache_info',
-                                                       array( 'qci_type' => $that->getName() ),
+                                                       array( 'qci_type' => $this->getName() ),
                                                        $fname
                                                );
                                                $dbw->insert( 'querycache_info',
-                                                       array( 'qci_type' => $that->getName(),
+                                                       array( 'qci_type' => $this->getName(),
                                                                'qci_timestamp' => $dbw->timestamp() ),
                                                        $fname
                                                );
index 673bb2d..81dc412 100755 (executable)
@@ -254,14 +254,6 @@ class PHPUnitMaintClass extends Maintenance {
 $maintClass = 'PHPUnitMaintClass';
 require RUN_MAINTENANCE_IF_MAIN;
 
-// Prevent segfault when we have lots of unit tests (bug 62623)
-if ( version_compare( PHP_VERSION, '5.4.0', '<' ) ) {
-       register_shutdown_function( function () {
-               gc_collect_cycles();
-               gc_disable();
-       } );
-}
-
 $ok = false;
 
 if ( class_exists( 'PHPUnit_TextUI_Command' ) ) {