Merge "Move LoadBalancer::pickRandom() to wfPickRandom()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 28 Feb 2013 21:09:49 +0000 (21:09 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 28 Feb 2013 21:09:49 +0000 (21:09 +0000)
includes/EditPage.php
includes/api/ApiUpload.php
includes/filebackend/FSFile.php
includes/templates/NoLocalSettings.php
includes/upload/UploadBase.php
includes/upload/UploadFromStash.php

index 6aed2d3..d42edd7 100644 (file)
@@ -1167,7 +1167,7 @@ class EditPage {
         * since the post-edit state should only apply to the load right after the save.
         */
        protected function setPostEditCookie() {
-               global $wgCookiePrefix, $wgCookieDomain;;
+               global $wgCookiePrefix, $wgCookieDomain;
                $revisionId = $this->mArticle->getLatest();
                $postEditKey = self::POST_EDIT_COOKIE_KEY_PREFIX . $revisionId;
 
index 6ec3a71..eabcf9b 100644 (file)
@@ -184,8 +184,6 @@ class ApiUpload extends ApiBase {
         * @return array
         */
        private function getChunkResult( $warnings ) {
-               global $IP;
-
                $result = array();
 
                $result['result'] = 'Continue';
@@ -564,8 +562,6 @@ class ApiUpload extends ApiBase {
         * @return array
         */
        protected function performUpload( $warnings ) {
-               global $IP;
-
                // Use comment as initial page text by default
                if ( is_null( $this->mParams['text'] ) ) {
                        $this->mParams['text'] = $this->mParams['comment'];
index acbc4a9..17a88c6 100644 (file)
@@ -28,6 +28,7 @@
  */
 class FSFile {
        protected $path; // path to file
+       private $sha1Base36 = null; // File Sha1Base36
 
        /**
         * Sets up the file object
@@ -193,20 +194,27 @@ class FSFile {
         * 160 log 2 / log 36 = 30.95, so the 160-bit hash fills 31 digits in base 36
         * fairly neatly.
         *
+        * @param $recache bool
         * @return bool|string False on failure
         */
-       public function getSha1Base36() {
+       public function getSha1Base36( $recache = false ) {
                wfProfileIn( __METHOD__ );
 
+               if ( $this->sha1Base36 !== null && !$recache ) {
+                       wfProfileOut( __METHOD__ );
+                       return $this->sha1Base36;
+               }
+
                wfSuppressWarnings();
-               $hash = sha1_file( $this->path );
+               $this->sha1Base36 = sha1_file( $this->path );
                wfRestoreWarnings();
-               if ( $hash !== false ) {
-                       $hash = wfBaseConvert( $hash, 16, 36, 31 );
+
+               if ( $this->sha1Base36 !== false ) {
+                       $this->sha1Base36 = wfBaseConvert( $this->sha1Base36, 16, 36, 31 );
                }
 
                wfProfileOut( __METHOD__ );
-               return $hash;
+               return $this->sha1Base36;
        }
 
        /**
@@ -242,11 +250,18 @@ class FSFile {
         * fairly neatly.
         *
         * @param $path string
+        * @param $recache bool
         *
         * @return bool|string False on failure
         */
-       public static function getSha1Base36FromPath( $path ) {
-               $fsFile = new self( $path );
-               return $fsFile->getSha1Base36();
+       public static function getSha1Base36FromPath( $path, $recache = false ) {
+               static $sha1Base36 = array();
+
+               if ( !isset( $sha1Base36[$path] ) || $recache ) {
+                       $fsFile = new self( $path );
+                       $sha1Base36[$path] = $fsFile->getSha1Base36();
+               }
+
+               return $sha1Base36[$path];
        }
 }
index bf5c487..2483e58 100644 (file)
  * @ingroup Templates
  */
 
+if ( !defined( 'MEDIAWIKI' ) ) {
+        die( "NoLocalSettings.php is not a valid MediaWiki entry point\n" );
+}
+
 if ( !isset( $wgVersion ) ) {
        $wgVersion = 'VERSION';
 }
index 3a37f11..49713fc 100644 (file)
@@ -239,7 +239,7 @@ abstract class UploadBase {
         * Get the base 36 SHA1 of the file
         * @return string
         */
-       protected function getTempFileSha1Base36() {
+       public function getTempFileSha1Base36() {
                return FSFile::getSha1Base36FromPath( $this->mTempPath );
        }
 
index 71ee96b..fd2416d 100644 (file)
@@ -133,7 +133,7 @@ class UploadFromStash extends UploadBase {
         * Get the base 36 SHA1 of the file
         * @return string
         */
-       protected function getTempFileSha1Base36() {
+       public function getTempFileSha1Base36() {
                return $this->mFileProps['sha1'];
        }