diff --git a/lib/class/Metadata/Model/Metadata.php b/lib/class/Metadata/Model/Metadata.php index aa164cce..d5eaac11 100644 --- a/lib/class/Metadata/Model/Metadata.php +++ b/lib/class/Metadata/Model/Metadata.php @@ -98,9 +98,9 @@ class Metadata extends \Lib\DatabaseObject implements \Lib\Interfaces\Model /** * - * @param \library_item $object + * @param integer $object */ - public function setObjectId(\library_item $object) + public function setObjectId($object) { $this->objectId = $object; } diff --git a/lib/class/Repository.php b/lib/class/Repository.php index f291b844..37a5859f 100644 --- a/lib/class/Repository.php +++ b/lib/class/Repository.php @@ -23,6 +23,8 @@ namespace Lib; +use Lib\Interfaces\Model; + /** * Description of Repository * @@ -178,7 +180,7 @@ class Repository * @param string $property * @param mixed $value */ - protected function setPrivateProperty(Object $object, $property, $value) + protected function setPrivateProperty(Model $object, $property, $value) { $reflectionClass = new \ReflectionClass(get_class($object)); $ReflectionProperty = $reflectionClass->getProperty($property); diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 48995678..0279424c 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -2219,3 +2219,4 @@ abstract class Catalog extends database_object } // end of catalog class + diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 435599af..f7d7083d 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -853,6 +853,11 @@ class Song extends database_object implements media, library_item // Foreach them foreach ($fields as $key=>$value) { + // Skip the item if it is no string nor something we can turn into a string + if (!is_string($song->$key) || (is_object($song->$key) && method_exists($song->key, '__toString'))) { + continue; + } + $key = trim($key); if (empty($key) || in_array($key,$skip_array)) { continue; @@ -2031,3 +2036,4 @@ class Song extends database_object implements media, library_item return $deleted; } } // end of song class + diff --git a/modules/catalog/local/local.catalog.php b/modules/catalog/local/local.catalog.php index 573e207e..9227059c 100644 --- a/modules/catalog/local/local.catalog.php +++ b/modules/catalog/local/local.catalog.php @@ -813,16 +813,13 @@ class Catalog_local extends Catalog */ protected function getCleanMetadata(library_item $libraryItem, $metadata) { - $tags = array_diff($metadata, get_object_vars($libraryItem)); - $keys = array_merge( - isset($libraryItem::$aliases) ? $libraryItem::$aliases : array(), - array_keys(get_object_vars($libraryItem)) + $tags = array_diff_key( + $metadata, + get_object_vars($libraryItem), + array_flip($libraryItem::$aliases ?: array()) ); - foreach ($keys as $key) { - unset($tags[$key]); - } - return $tags; + return array_filter($tags); } /** @@ -861,7 +858,7 @@ class Catalog_local extends Catalog $tags = $this->getCleanMetadata($media, $results); if (method_exists($media, 'updateOrInsertMetadata') && $media::isCustomMetadataEnabled()) { - $tags = array_diff_key($results, array_flip($media->getDisabledMetadataFields())); + $tags = array_diff_key($tags, array_flip($media->getDisabledMetadataFields())); foreach ($tags as $tag => $value) { $field = $media->getField($tag); $media->updateOrInsertMetadata($field, $value); @@ -869,3 +866,4 @@ class Catalog_local extends Catalog } } } // end of local catalog class +