Commit 48b3d709 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2767269 by claudiu.cristea: LocalReadOnlyStream must declare itself not writeable

parent 570f1a97
Loading
Loading
Loading
Loading
+7 −0
Changes for core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -15,6 +15,13 @@
 */
abstract class LocalReadOnlyStream extends LocalStream {

  /**
   * {@inheritdoc}
   */
  public static function getType() {
    return StreamWrapperInterface::READ_VISIBLE;
  }

  /**
   * Support for fopen(), file_get_contents(), etc.
   *
+7 −0
Changes for core/modules/system/src/Tests/File/ReadOnlyStreamWrapperTest.php: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,9 @@

namespace Drupal\system\Tests\File;

use Drupal\Core\StreamWrapper\StreamWrapperInterface;
use Drupal\file_test\StreamWrapper\DummyReadOnlyStreamWrapper;

/**
 * Tests the read-only stream wrapper write functions.
 *
@@ -27,6 +30,10 @@ class ReadOnlyStreamWrapperTest extends FileTestBase {
   * Test read-only specific behavior.
   */
  function testReadOnlyBehavior() {
    $type = DummyReadOnlyStreamWrapper::getType();
    // Checks that the stream wrapper type is not declared as writable.
    $this->assertIdentical(0, $type & StreamWrapperInterface::WRITE);

    // Generate a test file
    $filename = $this->randomMachineName();
    $site_path = $this->container->get('site.path');