Skip to content

Commit

Permalink
PHPLIB-1218 Remove GridFS fields contentType and aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Sep 13, 2024
1 parent d1d8895 commit 1bc14b9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
19 changes: 1 addition & 18 deletions src/GridFS/WritableStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@

use function array_intersect_key;
use function is_integer;
use function is_string;
use function MongoDB\is_document;
use function MongoDB\is_string_array;
use function sprintf;
use function strlen;
use function substr;
Expand Down Expand Up @@ -63,16 +61,9 @@ class WritableStream
*
* * _id (mixed): File document identifier. Defaults to a new ObjectId.
*
* * aliases (array of strings): DEPRECATED An array of aliases.
* Applications wishing to store aliases should add an aliases field to
* the metadata document instead.
*
* * chunkSizeBytes (integer): The chunk size in bytes. Defaults to
* 261120 (i.e. 255 KiB).
*
* * contentType (string): DEPRECATED content type to be stored with the
* file. This information should now be added to the metadata.
*
* * metadata (document): User data for the "metadata" field of the files
* collection document.
*
Expand All @@ -88,10 +79,6 @@ public function __construct(private CollectionWrapper $collectionWrapper, string
'chunkSizeBytes' => self::DEFAULT_CHUNK_SIZE_BYTES,
];

if (isset($options['aliases']) && ! is_string_array($options['aliases'])) {
throw InvalidArgumentException::invalidType('"aliases" option', $options['aliases'], 'array of strings');
}

if (! is_integer($options['chunkSizeBytes'])) {
throw InvalidArgumentException::invalidType('"chunkSizeBytes" option', $options['chunkSizeBytes'], 'integer');
}
Expand All @@ -100,10 +87,6 @@ public function __construct(private CollectionWrapper $collectionWrapper, string
throw new InvalidArgumentException(sprintf('Expected "chunkSizeBytes" option to be >= 1, %d given', $options['chunkSizeBytes']));
}

if (isset($options['contentType']) && ! is_string($options['contentType'])) {
throw InvalidArgumentException::invalidType('"contentType" option', $options['contentType'], 'string');
}

if (isset($options['metadata']) && ! is_document($options['metadata'])) {
throw InvalidArgumentException::expectedDocumentType('"metadata" option', $options['metadata']);
}
Expand All @@ -115,7 +98,7 @@ public function __construct(private CollectionWrapper $collectionWrapper, string
'filename' => $filename,
'length' => null,
'uploadDate' => null,
] + array_intersect_key($options, ['aliases' => 1, 'contentType' => 1, 'metadata' => 1]);
] + array_intersect_key($options, ['metadata' => 1]);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/UnifiedSpecTests/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ final class Util
'delete' => ['id'],
'downloadByName' => ['filename', 'revision'],
'download' => ['id'],
'uploadWithId' => ['id', 'filename', 'source', 'chunkSizeBytes', 'contentType', 'metadata'],
'upload' => ['filename', 'source', 'chunkSizeBytes', 'contentType', 'metadata'],
'uploadWithId' => ['id', 'filename', 'source', 'chunkSizeBytes', 'metadata'],
'upload' => ['filename', 'source', 'chunkSizeBytes', 'metadata'],
],
];

Expand Down

0 comments on commit 1bc14b9

Please sign in to comment.