Skip to content
Snippets Groups Projects
Commit c063caad authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by Jan-Hendrik Willms
Browse files

throw exceptions when i18nstring is used with a composite primary key, fixes #535

parent e1b4a3b8
No related branches found
No related tags found
No related merge requests found
......@@ -52,7 +52,8 @@ class I18NString
{
$this->base = $base;
$this->lang = $lang;
$this->metadata = $metadata;
$this->setMetadata($metadata);
}
/**
......@@ -151,6 +152,10 @@ class I18NString
*/
public function setMetadata($metadata)
{
if (isset($metadata['object_id']) && (is_array($metadata['object_id']) || is_object($metadata['object_id']))) {
throw new Exception('Can not use array or object as object id');
}
$this->metadata = $metadata;
}
......
......@@ -296,6 +296,10 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
if (I18N::isEnabled()) {
if (isset($config['i18n_fields']) && count($config['i18n_fields']) > 0) {
if (count($config['pk']) > 1) {
throw new Exception('Can not define i18n fields on a composite primary key');
}
$config['registered_callbacks']['before_store'][] = 'cbI18N';
$config['registered_callbacks']['after_delete'][] = 'cbI18N';
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment