[FileBackend] Tweaked TempFSFile::bind() to handle __get().
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 5 Oct 2012 19:56:32 +0000 (12:56 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 5 Oct 2012 19:56:44 +0000 (12:56 -0700)
Change-Id: I0ce288742bba1335bf26ce38fb3b7e441b2d8b1f

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 fa2afaa..bdb5c42 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() {