From e6935da3ceff45cb24bffa14173583a321afc207 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 5 Oct 2012 12:56:32 -0700 Subject: [PATCH] [FileBackend] Tweaked TempFSFile::bind() to handle __get(). Change-Id: I0ce288742bba1335bf26ce38fb3b7e441b2d8b1f --- includes/filebackend/TempFSFile.php | 4 ++++ tests/phpunit/includes/filerepo/FileBackendTest.php | 3 +++ 2 files changed, 7 insertions(+) diff --git a/includes/filebackend/TempFSFile.php b/includes/filebackend/TempFSFile.php index 5032bf682a..2e45093513 100644 --- a/includes/filebackend/TempFSFile.php +++ b/includes/filebackend/TempFSFile.php @@ -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; } } diff --git a/tests/phpunit/includes/filerepo/FileBackendTest.php b/tests/phpunit/includes/filerepo/FileBackendTest.php index fa2afaa6bf..bdb5c42382 100644 --- a/tests/phpunit/includes/filerepo/FileBackendTest.php +++ b/tests/phpunit/includes/filerepo/FileBackendTest.php @@ -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() { -- 2.20.1