Merge "Indicate the actual version of HHVM in use"
[lhc/web/wiklou.git] / includes / filerepo / LocalRepo.php
index bcccb71..926fd0b 100644 (file)
@@ -49,7 +49,7 @@ class LocalRepo extends FileRepo {
 
        /**
         * @throws MWException
-        * @param array $row
+        * @param stdClass $row
         * @return LocalFile
         */
        function newFileFromRow( $row ) {
@@ -91,7 +91,7 @@ class LocalRepo extends FileRepo {
                        $hashPath = $this->getDeletedHashPath( $key );
                        $path = "$root/$hashPath$key";
                        $dbw->begin( __METHOD__ );
-                       // Check for usage in deleted/hidden files and pre-emptively
+                       // Check for usage in deleted/hidden files and preemptively
                        // lock the key to avoid any future use until we are finished.
                        $deleted = $this->deletedFileHasKey( $key, 'lock' );
                        $hidden = $this->hiddenFileHasKey( $key, 'lock' );
@@ -167,7 +167,7 @@ class LocalRepo extends FileRepo {
         * Checks if there is a redirect named as $title
         *
         * @param Title $title Title of file
-        * @return bool
+        * @return bool|Title
         */
        function checkRedirect( Title $title ) {
                global $wgMemc;
@@ -258,11 +258,12 @@ class LocalRepo extends FileRepo {
                        }
                }
 
-               $fileMatchesSearch = function( File $file, array $search ) {
+               $fileMatchesSearch = function ( File $file, array $search ) {
                        // Note: file name comparison done elsewhere (to handle redirects)
                        $user = ( !empty( $search['private'] ) && $search['private'] instanceof User )
                                ? $search['private']
                                : null;
+
                        return (
                                $file->exists() &&
                                (
@@ -275,7 +276,7 @@ class LocalRepo extends FileRepo {
                };
 
                $repo = $this;
-               $applyMatchingFiles = function( ResultWrapper $res, &$searchSet, &$finalFiles )
+               $applyMatchingFiles = function ( ResultWrapper $res, &$searchSet, &$finalFiles )
                        use ( $repo, $fileMatchesSearch, $flags )
                {
                        global $wgContLang;
@@ -290,7 +291,7 @@ class LocalRepo extends FileRepo {
                                        $dbKeysLook[] = $wgContLang->lcfirst( $file->getName() );
                                }
                                foreach ( $dbKeysLook as $dbKey ) {
-                                       if ( isset( $searchSet[$dbKey])
+                                       if ( isset( $searchSet[$dbKey] )
                                                && $fileMatchesSearch( $file, $searchSet[$dbKey] )
                                        ) {
                                                $finalFiles[$dbKey] = ( $flags & FileRepo::NAME_AND_TIME_ONLY )
@@ -309,6 +310,7 @@ class LocalRepo extends FileRepo {
                foreach ( array_keys( $searchSet ) as $dbKey ) {
                        $imgNames[] = $this->getNameFromTitle( File::normalizeTitle( $dbKey ) );
                }
+
                if ( count( $imgNames ) ) {
                        $res = $dbr->select( 'image',
                                LocalFile::selectFields(), array( 'img_name' => $imgNames ), __METHOD__ );
@@ -328,6 +330,7 @@ class LocalRepo extends FileRepo {
                                );
                        }
                }
+
                if ( count( $oiConds ) ) {
                        $res = $dbr->select( 'oldimage',
                                OldLocalFile::selectFields(), $dbr->makeList( $oiConds, LIST_OR ), __METHOD__ );
@@ -339,15 +342,17 @@ class LocalRepo extends FileRepo {
                        if ( !empty( $search['ignoreRedirect'] ) ) {
                                continue;
                        }
+
                        $title = File::normalizeTitle( $dbKey );
                        $redir = $this->checkRedirect( $title ); // hopefully hits memcached
+
                        if ( $redir && $redir->getNamespace() == NS_FILE ) {
                                $file = $this->newFile( $redir );
                                if ( $file && $fileMatchesSearch( $file, $search ) ) {
                                        $file->redirectedFrom( $title->getDBkey() );
                                        if ( $flags & FileRepo::NAME_AND_TIME_ONLY ) {
                                                $finalFiles[$dbKey] = array(
-                                                       'title'     => $file->getTitle()->getDBkey(),
+                                                       'title' => $file->getTitle()->getDBkey(),
                                                        'timestamp' => $file->getTimestamp()
                                                );
                                        } else {
@@ -364,8 +369,8 @@ class LocalRepo extends FileRepo {
         * Get an array or iterator of file objects for files that have a given
         * SHA-1 content hash.
         *
-        * @param string $hash a sha1 hash to look for
-        * @return array
+        * @param string $hash A sha1 hash to look for
+        * @return File[]
         */
        function findBySha1( $hash ) {
                $dbr = $this->getSlaveDB();
@@ -503,6 +508,7 @@ class LocalRepo extends FileRepo {
         */
        function getInfo() {
                global $wgFavicon;
+
                return array_merge( parent::getInfo(), array(
                        'favicon' => wfExpandUrl( $wgFavicon ),
                ) );