Verified Commit 37fb0a99 authored by Dave Long's avatar Dave Long
Browse files

Issue #3328694 by murilohp, rpayanm, jonathan1055, xjm, cilefen: Incorrect sprintf parameter usage

(cherry picked from commit 465482a5)
parent d46d0196
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ public function __construct(FileSystemInterface $fileSystem, StreamWrapperManage
   */
  public function writeData(string $data, string $destination, int $replace = FileSystemInterface::EXISTS_RENAME): FileInterface {
    if (!$this->streamWrapperManager->isValidUri($destination)) {
      throw new InvalidStreamWrapperException(sprintf('Invalid stream wrapper: %destination', ['%destination' => $destination]));
      throw new InvalidStreamWrapperException("Invalid stream wrapper: {$destination}");
    }
    $uri = $this->fileSystem->saveData($data, $destination, $replace);
    return $this->createOrUpdate($uri, $destination, $replace === FileSystemInterface::EXISTS_RENAME);
@@ -132,7 +132,7 @@ protected function createOrUpdate(string $uri, string $destination, bool $rename
   */
  public function copy(FileInterface $source, string $destination, int $replace = FileSystemInterface::EXISTS_RENAME): FileInterface {
    if (!$this->streamWrapperManager->isValidUri($destination)) {
      throw new InvalidStreamWrapperException(sprintf('Invalid stream wrapper: %destination', ['%destination' => $destination]));
      throw new InvalidStreamWrapperException("Invalid stream wrapper: {$destination}");
    }
    $uri = $this->fileSystem->copy($source->getFileUri(), $destination, $replace);

@@ -166,7 +166,7 @@ public function copy(FileInterface $source, string $destination, int $replace =
   */
  public function move(FileInterface $source, string $destination, int $replace = FileSystemInterface::EXISTS_RENAME): FileInterface {
    if (!$this->streamWrapperManager->isValidUri($destination)) {
      throw new InvalidStreamWrapperException(sprintf('Invalid stream wrapper: %destination', ['%destination' => $destination]));
      throw new InvalidStreamWrapperException("Invalid stream wrapper: {$destination}");
    }
    $uri = $this->fileSystem->move($source->getFileUri(), $destination, $replace);
    $delete_source = FALSE;
+1 −0
Original line number Diff line number Diff line
@@ -185,6 +185,7 @@ public function testExistingError() {
   */
  public function testInvalidStreamWrapper() {
    $this->expectException(InvalidStreamWrapperException::class);
    $this->expectExceptionMessage('Invalid stream wrapper: foo://');
    $source = $this->createFile();
    $this->fileRepository->copy($source, 'foo://');
  }
+1 −0
Original line number Diff line number Diff line
@@ -170,6 +170,7 @@ public function testExistingError() {
   */
  public function testInvalidStreamWrapper() {
    $this->expectException(InvalidStreamWrapperException::class);
    $this->expectExceptionMessage('Invalid stream wrapper: foo://');
    $this->fileRepository->writeData('asdf', 'foo://');
  }

+1 −0
Original line number Diff line number Diff line
@@ -209,6 +209,7 @@ public function testExistingError() {
   */
  public function testInvalidStreamWrapper() {
    $this->expectException(InvalidStreamWrapperException::class);
    $this->expectExceptionMessage('Invalid stream wrapper: foo://');
    $source = $this->createFile();
    $this->fileRepository->move($source, 'foo://');
  }