Merge "[FileBackend] Tweaked TempFSFile::bind() to handle __get()."
authorDemon <chadh@wikimedia.org>
Tue, 9 Oct 2012 16:08:55 +0000 (16:08 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 9 Oct 2012 16:08:55 +0000 (16:08 +0000)
includes/filebackend/TempFSFile.php
tests/phpunit/includes/filerepo/FileBackendTest.php

index 5032bf6..2e45093 100644 (file)
@@ -86,6 +86,10 @@ class TempFSFile extends FSFile {
         */
        public function bind( $object ) {
                if ( is_object( $object ) ) {
+                       if ( !isset( $object->tempFSFileReferences ) ) {
+                               // Init first since $object might use __get() and return only a copy variable
+                               $object->tempFSFileReferences = array();
+                       }
                        $object->tempFSFileReferences[] = $this;
                }
        }
index 2303c78..f159d5d 100644 (file)
@@ -1026,6 +1026,9 @@ class FileBackendTest extends MediaWikiTestCase {
                        $this->assertNotEquals( false, $contents, "Local copy of $source exists ($backendName)." );
                        $this->assertEquals( $content[0], $contents, "Local copy of $source is correct ($backendName)." );
                }
+
+               $obj = new stdClass();
+               $tmpFile->bind( $obj );
        }
 
        function provider_testGetLocalCopy() {