From b3df4babc224b748107ee6b99c1b404ad306b246 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Tue, 8 Mar 2011 18:12:17 +0000 Subject: [PATCH] =?utf8?q?misc=20w/s=20cleanups,=20=E2=80=9Csvn=20diff=20-?= =?utf8?q?x-w=E2=80=9D=20clean?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- includes/Article.php | 2 +- includes/Html.php | 2 +- includes/HttpFunctions.php | 8 ++-- includes/Import.php | 18 ++++---- includes/User.php | 2 +- includes/WatchlistEditor.php | 2 +- includes/upload/UploadBase.php | 72 +++++++++++++++---------------- includes/upload/UploadStash.php | 72 +++++++++++++++---------------- languages/messages/MessagesEn.php | 6 +-- 9 files changed, 92 insertions(+), 92 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 63d9bf9569..b5f4d4f8e2 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1834,7 +1834,7 @@ class Article { if ( !$isRedirect && !is_null( $lastRevIsRedirect ) && $lastRevIsRedirect === $isRedirect ) { return true; } - + wfProfileIn( __METHOD__ ); if ( $isRedirect ) { $this->insertRedirectEntry( $redirectTitle ); diff --git a/includes/Html.php b/includes/Html.php index 4e6e611433..daef9e0e44 100644 --- a/includes/Html.php +++ b/includes/Html.php @@ -200,7 +200,7 @@ class Html { /** * Returns "", except if $wgWellFormedXml is off, in which case * it returns the empty string when that's guaranteed to be safe. - * + * * @since 1.17 * @param $element string Name of the element, e.g., 'a' * @return string A closing tag, if required diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index 6d47a6beda..7b965565f4 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -141,7 +141,7 @@ class Http { */ class MWHttpRequest { const SUPPORTS_FILE_POSTS = false; - + protected $content; protected $timeout = 'default'; protected $headersOnly = null; @@ -205,7 +205,7 @@ class MWHttpRequest { /** * Generate a new request object - * @param $url String: url to use + * @param $url String: url to use * @param $options Array: (optional) extra params to pass (see Http::request()) * @see MWHttpRequest::__construct */ @@ -565,7 +565,7 @@ class MWHttpRequest { */ class CurlHttpRequest extends MWHttpRequest { const SUPPORTS_FILE_POSTS = true; - + static $curlMessageMap = array( 6 => 'http-host-unreachable', 28 => 'http-timed-out' @@ -692,7 +692,7 @@ class PhpHttpRequest extends MWHttpRequest { if ( is_array( $this->postData ) ) { $this->postData = wfArrayToCGI( $this->postData ); - } + } // At least on Centos 4.8 with PHP 5.1.6, using max_redirects to follow redirects // causes a segfault diff --git a/includes/Import.php b/includes/Import.php index 7228d23c52..115cf158d9 100644 --- a/includes/Import.php +++ b/includes/Import.php @@ -192,7 +192,7 @@ class WikiImporter { * Dummy for now... */ public function importUpload( $revision ) { - $revision->importUpload(); + $revision->importUpload(); //$dbw = wfGetDB( DB_MASTER ); //return $dbw->deadlockLoop( array( $revision, 'importUpload' ) ); return false; @@ -604,12 +604,12 @@ class WikiImporter { private function processUpload( $pageInfo, $uploadInfo ) { $revision = new WikiRevision; - $text = isset( $uploadInfo['text'] ) ? $uploadInfo['text'] : ''; + $text = isset( $uploadInfo['text'] ) ? $uploadInfo['text'] : ''; $revision->setTitle( $pageInfo['_title'] ); - $revision->setID( $pageInfo['id'] ); + $revision->setID( $pageInfo['id'] ); $revision->setTimestamp( $uploadInfo['timestamp'] ); - $revision->setText( $text ); + $revision->setText( $text ); $revision->setFilename( $uploadInfo['filename'] ); $revision->setSrc( $uploadInfo['src'] ); $revision->setSize( intval( $uploadInfo['size'] ) ); @@ -622,7 +622,7 @@ class WikiImporter { $revision->setUserName( $uploadInfo['contributor']['username'] ); } - return call_user_func( $this->mUploadCallback, $revision ); + return call_user_func( $this->mUploadCallback, $revision ); } private function handleContributor() { @@ -1057,7 +1057,7 @@ class WikiRevision { $resultDetails = array( 'internal' => $status->getWikiText() ); */ - // @todo Fixme: it may create a page without our desire, also wrong potentially. + // @todo Fixme: it may create a page without our desire, also wrong potentially. // and, it will record a *current* upload, but we might want an archive version here $file = wfLocalFile( $this->getTitle() ); @@ -1072,15 +1072,15 @@ class WikiRevision { return false; } - $user = User::newFromName( $this->user_text ); + $user = User::newFromName( $this->user_text ); $status = $file->upload( $source, $this->getComment(), $this->getComment(), // Initial page, if none present... File::DELETE_SOURCE, false, // props... - $this->getTimestamp(), - is_object( $user ) ? ( $user->isLoggedIn() ? $user : null ) : null ); + $this->getTimestamp(), + is_object( $user ) ? ( $user->isLoggedIn() ? $user : null ) : null ); if( $status->isGood() ) { // yay? diff --git a/includes/User.php b/includes/User.php index 4a0f2a3a9a..556252a35f 100644 --- a/includes/User.php +++ b/includes/User.php @@ -2831,7 +2831,7 @@ class User { # Some wikis were converted from ISO 8859-1 to UTF-8, the passwords can't be converted # Check for this with iconv $cp1252Password = iconv( 'UTF-8', 'WINDOWS-1252//TRANSLIT', $password ); - if ( $cp1252Password != $password && + if ( $cp1252Password != $password && self::comparePasswords( $this->mPassword, $cp1252Password, $this->mId ) ) { return true; diff --git a/includes/WatchlistEditor.php b/includes/WatchlistEditor.php index bb098d5f37..68c6b5a9da 100644 --- a/includes/WatchlistEditor.php +++ b/includes/WatchlistEditor.php @@ -60,7 +60,7 @@ class WatchlistEditor { } else { $this->clearWatchlist( $user ); $user->invalidateCache(); - $output->addHTML( wfMsgExt( 'watchlistedit-raw-removed', 'parse', + $output->addHTML( wfMsgExt( 'watchlistedit-raw-removed', 'parse', $wgLang->formatNum( count( $current ) ) ) ); $this->showTitles( $current, $output, $wgUser->getSkin() ); } diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index b485949dcd..ccb67a4b7d 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -148,12 +148,12 @@ abstract class UploadBase { } public function __construct() {} - + /** * Returns the upload type. Should be overridden by child classes - * + * * @since 1.18 - * @return string + * @return string */ public function getSourceType() { return null; } @@ -242,7 +242,7 @@ abstract class UploadBase { */ $maxSize = self::getMaxUploadSize( $this->getSourceType() ); if( $this->mFileSize > $maxSize ) { - return array( + return array( 'status' => self::FILE_TOO_LARGE, 'max' => $maxSize, ); @@ -350,9 +350,9 @@ abstract class UploadBase { protected function verifyFile() { global $wgAllowJavaUploads; # get the title, even though we are doing nothing with it, because - # we need to populate mFinalExtension + # we need to populate mFinalExtension $this->getTitle(); - + $this->mFileProps = File::getPropsFromPath( $this->mTempPath, $this->mFinalExtension ); $this->checkMacBinary(); @@ -373,11 +373,11 @@ abstract class UploadBase { } } - # Check for Java applets, which if uploaded can bypass cross-site + # Check for Java applets, which if uploaded can bypass cross-site # restrictions. if ( !$wgAllowJavaUploads ) { $this->mJavaDetected = false; - $zipStatus = ZipDirectoryReader::read( $this->mTempPath, + $zipStatus = ZipDirectoryReader::read( $this->mTempPath, array( $this, 'zipEntryCallback' ) ); if ( !$zipStatus->isOK() ) { $errors = $zipStatus->getErrorsArray(); @@ -422,16 +422,16 @@ abstract class UploadBase { $names = array( $entry['name'] ); // If there is a null character, cut off the name at it, because JDK's - // ZIP_GetEntry() uses strcmp() if the name hashes match. If a file name - // were constructed which had ".class\0" followed by a string chosen to - // make the hash collide with the truncated name, that file could be + // ZIP_GetEntry() uses strcmp() if the name hashes match. If a file name + // were constructed which had ".class\0" followed by a string chosen to + // make the hash collide with the truncated name, that file could be // returned in response to a request for the .class file. $nullPos = strpos( $entry['name'], "\000" ); if ( $nullPos !== false ) { $names[] = substr( $entry['name'], 0, $nullPos ); } - // If there is a trailing slash in the file name, we have to strip it, + // If there is a trailing slash in the file name, we have to strip it, // because that's what ZIP_GetEntry() does. if ( preg_grep( '!\.class/?$!', $names ) ) { $this->mJavaDetected = true; @@ -470,12 +470,12 @@ abstract class UploadBase { $permErrors = array_merge( $permErrors, wfArrayDiff2( $permErrorsCreate, $permErrors ) ); return $permErrors; } - + $overwriteError = $this->checkOverwrite( $user ); if ( $overwriteError !== true ) { return array( array( $overwriteError ) ); } - + return true; } @@ -555,14 +555,14 @@ abstract class UploadBase { * @return Status indicating the whether the upload succeeded. */ public function performUpload( $comment, $pageText, $watch, $user ) { - $status = $this->getLocalFile()->upload( - $this->mTempPath, - $comment, + $status = $this->getLocalFile()->upload( + $this->mTempPath, + $comment, $pageText, File::DELETE_SOURCE, - $this->mFileProps, - false, - $user + $this->mFileProps, + false, + $user ); if( $status->isGood() ) { @@ -611,7 +611,7 @@ abstract class UploadBase { $this->mFinalExtension = trim( $ext[count( $ext ) - 1] ); } else { $this->mFinalExtension = ''; - + # No extension, try guessing one $magic = MimeMagic::singleton(); $mime = $magic->guessMimeType( $this->mTempPath ); @@ -621,22 +621,22 @@ abstract class UploadBase { if ( $extList ) { # Set the extension to the canonical extension $this->mFinalExtension = strtok( $extList, ' ' ); - + # Fix up the other variables $this->mFilteredName .= ".{$this->mFinalExtension}"; $nt = Title::makeTitleSafe( NS_FILE, $this->mFilteredName ); $ext = array( $this->mFinalExtension ); } } - + } /* Don't allow users to override the blacklist (check file extension) */ global $wgCheckFileExtensions, $wgStrictFileExtensions; global $wgFileExtensions, $wgFileBlacklist; - + $blackListedExtensions = $this->checkFileExtensionList( $ext, $wgFileBlacklist ); - + if ( $this->mFinalExtension == '' ) { $this->mTitleError = self::FILETYPE_MISSING; return $this->mTitle = null; @@ -703,15 +703,15 @@ abstract class UploadBase { * * This method will stash a file in a temporary directory for later processing, and save the necessary descriptive info * into the user's session. - * This method returns the file object, which also has a 'sessionKey' property which can be passed through a form or + * This method returns the file object, which also has a 'sessionKey' property which can be passed through a form or * API request to find this stashed file again. * * @param $key String: (optional) the session key used to find the file info again. If not supplied, a key will be autogenerated. * @return UploadStashFile stashed file */ - public function stashSessionFile( $key = null ) { + public function stashSessionFile( $key = null ) { $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash(); - $data = array( + $data = array( 'mFileProps' => $this->mFileProps, 'mSourceType' => $this->getSourceType(), ); @@ -1276,18 +1276,18 @@ abstract class UploadBase { } /** - * Gets image info about the file just uploaded. + * Gets image info about the file just uploaded. * - * Also has the effect of setting metadata to be an 'indexed tag name' in returned API result if + * Also has the effect of setting metadata to be an 'indexed tag name' in returned API result if * 'metadata' was requested. Oddly, we have to pass the "result" object down just so it can do that - * with the appropriate format, presumably. + * with the appropriate format, presumably. * * @param $result ApiResult: * @return Array: image info */ public function getImageInfo( $result ) { $file = $this->getLocalFile(); - // TODO This cries out for refactoring. We really want to say $file->getAllInfo(); here. + // TODO This cries out for refactoring. We really want to say $file->getAllInfo(); here. // Perhaps "info" methods should be moved into files, and the API should just wrap them in queries. if ( $file instanceof UploadStashFile ) { $imParam = ApiQueryStashImageInfo::getPropertyNames(); @@ -1305,12 +1305,12 @@ abstract class UploadBase { unset( $code['status'] ); return Status::newFatal( $this->getVerificationErrorCode( $code ), $error ); } - + public static function getMaxUploadSize( $forType = null ) { global $wgMaxUploadSize; - + if ( is_array( $wgMaxUploadSize ) ) { - if ( !is_null( $forType ) && isset( $wgMaxUploadSize[$forType] ) ) { + if ( !is_null( $forType) && isset( $wgMaxUploadSize[$forType] ) ) { return $wgMaxUploadSize[$forType]; } else { return $wgMaxUploadSize['*']; @@ -1318,6 +1318,6 @@ abstract class UploadBase { } else { return intval( $wgMaxUploadSize ); } - + } } diff --git a/includes/upload/UploadStash.php b/includes/upload/UploadStash.php index 8a8ad80641..5c8ae2ef39 100644 --- a/includes/upload/UploadStash.php +++ b/includes/upload/UploadStash.php @@ -1,13 +1,13 @@ file mapping, on the assumption that nobody else can access + * We accomplish this by making the session serve as a URL->file mapping, on the assumption that nobody else can access * the session, even the uploading user. See SpecialUploadStash, which implements a web interface to some files stored this way. * */ @@ -18,8 +18,8 @@ class UploadStash { // repository that this uses to store temp files // public because we sometimes need to get a LocalFile within the same repo. - public $repo; - + public $repo; + // array of initialized objects obtained from session (lazily initialized upon getFile()) private $files = array(); @@ -31,7 +31,7 @@ class UploadStash { * Represents the session which contains temporarily stored files. * Designed to be compatible with the session stashing code in UploadBase (should replace it eventually) */ - public function __construct( $repo ) { + public function __construct( $repo ) { // this might change based on wiki's configuration. $this->repo = $repo; @@ -43,7 +43,7 @@ class UploadStash { if ( !isset( $_SESSION[UploadBase::SESSION_KEYNAME] ) ) { $_SESSION[UploadBase::SESSION_KEYNAME] = array(); } - + } /** @@ -58,8 +58,8 @@ class UploadStash { public function getFile( $key ) { if ( ! preg_match( self::KEY_FORMAT_REGEX, $key ) ) { throw new UploadStashBadPathException( "key '$key' is not in a proper format" ); - } - + } + if ( !isset( $this->files[$key] ) ) { if ( !isset( $_SESSION[UploadBase::SESSION_KEYNAME][$key] ) ) { throw new UploadStashFileNotFoundException( "key '$key' not found in stash" ); @@ -70,7 +70,7 @@ class UploadStash { if ($data['version'] !== UploadBase::SESSION_VERSION ) { throw new UploadStashBadVersionException( $data['version'] . " does not match current version " . UploadBase::SESSION_VERSION ); } - + // separate the stashData into the path, and then the rest of the data $path = $data['mTempPath']; unset( $data['mTempPath'] ); @@ -102,7 +102,7 @@ class UploadStash { wfDebug( "UploadStash: tried to stash file at '$path', but it doesn't exist\n" ); throw new UploadStashBadPathException( "path doesn't exist" ); } - $fileProps = File::getPropsFromPath( $path ); + $fileProps = File::getPropsFromPath( $path ); // we will be initializing from some tmpnam files that don't have extensions. // most of MediaWiki assumes all uploaded files have good extensions. So, we fix this. @@ -113,7 +113,7 @@ class UploadStash { throw new UploadStashFileException( "couldn't rename $path to have a better extension at $pathWithGoodExtension" ); } $path = $pathWithGoodExtension; - } + } // If no key was supplied, use content hash. Also has the nice property of collapsing multiple identical files // uploaded this session, which could happen if uploads had failed. @@ -123,7 +123,7 @@ class UploadStash { if ( ! preg_match( self::KEY_FORMAT_REGEX, $key ) ) { throw new UploadStashBadPathException( "key '$key' is not in a proper format" ); - } + } // if not already in a temporary area, put it there $status = $this->repo->storeTemp( basename( $path ), $path ); @@ -148,7 +148,7 @@ class UploadStash { // required info we always store. Must trump any other application info in $data // 'mTempPath', 'mFileSize', and 'mFileProps' are arbitrary names // chosen for compatibility with UploadBase's way of doing this. - $requiredData = array( + $requiredData = array( 'mTempPath' => $stashPath, 'mFileSize' => $fileProps['size'], 'mFileProps' => $fileProps, @@ -159,7 +159,7 @@ class UploadStash { // UploadWizard wants different things than say FirefoggChunkedUpload.) wfDebug( __METHOD__ . " storing under $key\n" ); $_SESSION[UploadBase::SESSION_KEYNAME][$key] = array_merge( $data, $requiredData ); - + return $this->getFile( $key ); } @@ -193,12 +193,12 @@ class UploadStash { /** * Find or guess extension -- ensuring that our extension matches our mime type. - * Since these files are constructed from php tempnames they may not start off + * Since these files are constructed from php tempnames they may not start off * with an extension. - * XXX this is somewhat redundant with the checks that ApiUpload.php does with incoming + * XXX this is somewhat redundant with the checks that ApiUpload.php does with incoming * uploads versus the desired filename. Maybe we can get that passed to us... */ - public static function getExtensionForPath( $path ) { + public static function getExtensionForPath( $path ) { // Does this have an extension? $n = strrpos( $path, '.' ); $extension = null; @@ -209,8 +209,8 @@ class UploadStash { $magic = MimeMagic::singleton(); $mimeType = $magic->guessMimeType( $path ); $extensions = explode( ' ', MimeMagic::singleton()->getExtensionsForType( $mimeType ) ); - if ( count( $extensions ) ) { - $extension = $extensions[0]; + if ( count( $extensions ) ) { + $extension = $extensions[0]; } } @@ -242,19 +242,19 @@ class UploadStashFile extends UnregisteredLocalFile { * @throws UploadStashBadPathException * @throws UploadStashFileNotFoundException */ - public function __construct( $stash, $repo, $path, $key, $data ) { + public function __construct( $stash, $repo, $path, $key, $data ) { $this->sessionStash = $stash; $this->sessionKey = $key; $this->sessionData = $data; // resolve mwrepo:// urls if ( $repo->isVirtualUrl( $path ) ) { - $path = $repo->resolveVirtualUrl( $path ); + $path = $repo->resolveVirtualUrl( $path ); } // check if path appears to be sane, no parent traversals, and is in this repo's temp zone. $repoTempPath = $repo->getZonePath( 'temp' ); - if ( ( ! $repo->validateFilename( $path ) ) || + if ( ( ! $repo->validateFilename( $path ) ) || ( strpos( $path, $repoTempPath ) !== 0 ) ) { wfDebug( "UploadStash: tried to construct an UploadStashFile from a file that should already exist at '$path', but path is not valid\n" ); throw new UploadStashBadPathException( 'path is not valid' ); @@ -285,13 +285,13 @@ class UploadStashFile extends UnregisteredLocalFile { /** * Get the path for the thumbnail (actually any transformation of this file) - * The actual argument is the result of thumbName although we seem to have + * The actual argument is the result of thumbName although we seem to have * buggy code elsewhere that expects a boolean 'suffix' * * @param $thumbName String: name of thumbnail (e.g. "120px-123456.jpg" ), or false to just get the path * @return String: path thumbnail should take on filesystem, or containing directory if thumbname is false */ - public function getThumbPath( $thumbName = false ) { + public function getThumbPath( $thumbName = false ) { $path = dirname( $this->path ); if ( $thumbName !== false ) { $path .= "/$thumbName"; @@ -300,8 +300,8 @@ class UploadStashFile extends UnregisteredLocalFile { } /** - * Return the file/url base name of a thumbnail with the specified parameters. - * We override this because we want to use the pretty url name instead of the + * Return the file/url base name of a thumbnail with the specified parameters. + * We override this because we want to use the pretty url name instead of the * ugly file name. * * @param $params Array: handler-specific parameters @@ -314,33 +314,33 @@ class UploadStashFile extends UnregisteredLocalFile { /** * Helper function -- given a 'subpage', return the local URL e.g. /wiki/Special:UploadStash/subpage * @param {String} $subPage - * @return {String} local URL for this subpage in the Special:UploadStash space. + * @return {String} local URL for this subpage in the Special:UploadStash space. */ private function getSpecialUrl( $subPage ) { return SpecialPage::getTitleFor( 'UploadStash', $subPage )->getLocalURL(); } - /** - * Get a URL to access the thumbnail - * This is required because the model of how files work requires that + /** + * Get a URL to access the thumbnail + * This is required because the model of how files work requires that * the thumbnail urls be predictable. However, in our model the URL is not based on the filename * (that's hidden in the session) * * @param $thumbName String: basename of thumbnail file -- however, we don't want to use the file exactly * @return String: URL to access thumbnail, or URL with partial path */ - public function getThumbUrl( $thumbName = false ) { + public function getThumbUrl( $thumbName = false ) { wfDebug( __METHOD__ . " getting for $thumbName \n" ); return $this->getSpecialUrl( 'thumb/' . $this->getUrlName() . '/' . $thumbName ); } - /** + /** * The basename for the URL, which we want to not be related to the filename. * Will also be used as the lookup key for a thumbnail file. * * @return String: base url name, like '120px-123456.jpg' */ - public function getUrlName() { + public function getUrlName() { if ( ! $this->urlName ) { $this->urlName = $this->sessionKey; } @@ -361,12 +361,12 @@ class UploadStashFile extends UnregisteredLocalFile { } /** - * Parent classes use this method, for no obvious reason, to return the path (relative to wiki root, I assume). + * Parent classes use this method, for no obvious reason, to return the path (relative to wiki root, I assume). * But with this class, the URL is unrelated to the path. * * @return String: url */ - public function getFullUrl() { + public function getFullUrl() { return $this->getUrl(); } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 94909567d9..322c7a9944 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2963,10 +2963,10 @@ $1', 'undelete-show-file-submit' => 'Yes', # Namespace form on various pages -'namespace' => 'Namespace:', -'invert' => 'Invert selection', +'namespace' => 'Namespace:', +'invert' => 'Invert selection', 'namespace_association' => 'Associated namespace', -'blanknamespace' => '(Main)', +'blanknamespace' => '(Main)', # Contributions 'contributions' => 'User contributions', -- 2.20.1