[BUGFIX] Missing stream_cast() in FileStreamWrapper 22/36522/7
authorPhilipp Gampe <philipp.gampe@typo3.org>
Sat, 31 Jan 2015 15:51:31 +0000 (16:51 +0100)
committerSascha Egerer <sascha@sascha-egerer.de>
Sat, 31 Jan 2015 23:00:42 +0000 (00:00 +0100)
Resolves: #64693
Releases: master
Change-Id: Ib3eeee53d9937e4ae8a1cdfd0da2acf51644241f
Reviewed-on: http://review.typo3.org/36522
Reviewed-by: Altan Tosun <a.tosun@gmx.de>
Tested-by: Altan Tosun <a.tosun@gmx.de>
Reviewed-by: Sascha Egerer <sascha@sascha-egerer.de>
Tested-by: Sascha Egerer <sascha@sascha-egerer.de>
typo3/sysext/core/Tests/FileStreamWrapper.php
typo3/sysext/core/Tests/Unit/FileStreamWrapperTest.php

index 3f1fe02..b262bc3 100644 (file)
@@ -311,6 +311,22 @@ class FileStreamWrapper {
        }
 
        /**
+        * Retrieve the underlying resource
+        *
+        * @param int $castAs Can be STREAM_CAST_FOR_SELECT when stream_select()
+        * is calling stream_cast() or STREAM_CAST_AS_STREAM when stream_cast()
+        * is called for other uses.
+        * @return resource|bool
+        */
+       public function stream_cast($castAs) {
+               if ($this->fileHandle !== NULL && $castAs & STREAM_CAST_AS_STREAM) {
+                       return $this->fileHandle;
+               } else {
+                       return FALSE;
+               }
+       }
+
+       /**
         * Close a file
         *
         */
index 29cc693..d7c24bd 100644 (file)
@@ -51,7 +51,6 @@ class FileStreamWrapperTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        ),
                );
                $this->assertEquals($expectedFileSystem, vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure());
-
                FileStreamWrapper::destroy();
        }
 
@@ -93,5 +92,6 @@ class FileStreamWrapperTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                symlink($path . 'file1.txt', $path . 'file2.txt');
 
                $this->assertTrue(is_link($path . 'file2.txt'));
+               FileStreamWrapper::destroy();
        }
-}
\ No newline at end of file
+}