assert that metadata['tags'] is an array

This commit is contained in:
Shish 2016-07-30 23:02:14 +01:00
parent ffce1a4683
commit bed04a1230
7 changed files with 14 additions and 10 deletions

View file

@ -37,7 +37,7 @@ class FlashFileHandler extends DataHandlerExtension {
$image->hash = $metadata['hash'];
$image->filename = $metadata['filename'];
$image->ext = $metadata['extension'];
$image->tag_array = Tag::explode($metadata['tags']);
$image->tag_array = $metadata['tags'];
$image->source = $metadata['source'];
$info = getimagesize($filename);

View file

@ -79,7 +79,7 @@ class IcoFileHandler extends Extension {
$image->hash = $metadata['hash'];
$image->filename = $metadata['filename'];
$image->ext = $metadata['extension'];
$image->tag_array = Tag::explode($metadata['tags']);
$image->tag_array = $metadata['tags'];
$image->source = $metadata['source'];
return $image;

View file

@ -55,7 +55,7 @@ class MP3FileHandler extends DataHandlerExtension {
}
$image->ext = $metadata['extension'];
$image->tag_array = Tag::explode($metadata['tags']);
$image->tag_array = $metadata['tags'];
$image->source = $metadata['source'];
return $image;

View file

@ -32,11 +32,11 @@ class PixelFileHandler extends DataHandlerExtension {
$image->height = $info[1];
$image->filesize = $metadata['size'];
$image->hash = $metadata['hash'];
$image->hash = $metadata['hash'];
$image->filename = (($pos = strpos($metadata['filename'],'?')) !== false) ? substr($metadata['filename'],0,$pos) : $metadata['filename'];
$image->ext = (($pos = strpos($metadata['extension'],'?')) !== false) ? substr($metadata['extension'],0,$pos) : $metadata['extension'];
$image->tag_array = Tag::explode($metadata['tags']);
$image->source = $metadata['source'];
$image->ext = (($pos = strpos($metadata['extension'],'?')) !== false) ? substr($metadata['extension'],0,$pos) : $metadata['extension'];
$image->tag_array = $metadata['tags'];
$image->source = $metadata['source'];
return $image;
}

View file

@ -75,7 +75,7 @@ class SVGFileHandler extends Extension {
$image->hash = $metadata['hash'];
$image->filename = $metadata['filename'];
$image->ext = $metadata['extension'];
$image->tag_array = Tag::explode($metadata['tags']);
$image->tag_array = $metadata['tags'];
$image->source = $metadata['source'];
return $image;

View file

@ -169,7 +169,7 @@ class VideoFileHandler extends DataHandlerExtension {
$image->filesize = $metadata['size'];
$image->hash = $metadata['hash'];
$image->filename = $metadata['filename'];
$image->tag_array = Tag::explode($metadata['tags']);
$image->tag_array = $metadata['tags'];
$image->source = $metadata['source'];
return $image;

View file

@ -29,7 +29,11 @@ class DataUploadEvent extends Event {
* @param array $metadata Info about the file, should contain at least "filename", "extension", "tags" and "source".
*/
public function __construct(/*string*/ $tmpname, /*array*/ $metadata) {
assert(file_exists($tmpname));
assert('file_exists($tmpname)');
assert('is_string($metadata["filename"])');
assert('is_string($metadata["extension"])');
assert('is_array($metadata["tags"])');
assert('is_string($metadata["source"]) || is_null($metadata["source"])');
$this->tmpname = $tmpname;