Skip to content
Snippets Groups Projects
Commit 9cf0c49b authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by Michaela Brückner
Browse files

load translations before comparing i18n field contents in SimpleORMap::isFieldDirty(), fixes #4864

Closes #4864

Merge request !3643
parent 3b328dfa
No related branches found
No related tags found
No related merge requests found
......@@ -2233,6 +2233,14 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
if ($this->content[$field] === null || $this->content_db[$field] === null) {
return $this->content[$field] !== $this->content_db[$field];
} else if ($this->content[$field] instanceof I18NString || $this->content_db[$field] instanceof I18NString) {
// Trigger loading of translations
if ($this->content[$field] instanceof I18NString) {
$this->content[$field]->toArray();
}
if ($this->content_db[$field] instanceof I18NString) {
$this->content_db[$field]->toArray();
}
return $this->content[$field] != $this->content_db[$field];
} else {
return (string)$this->content[$field] !== (string)$this->content_db[$field];
......
......@@ -25,8 +25,6 @@ class auth_user_md5 extends SimpleORMap
$config['serialized_fields']['jsondata'] = 'JSONArrayObject';
$config['notification_map']['after_store'] = 'auth_user_md5DidCreateOrUpdate';
$config['i18n_fields'] = ['i18n_field'];
parent::configure($config);
}
......@@ -366,7 +364,14 @@ class SimpleOrMapNodbTest extends \Codeception\Test\Unit
self::setupFixture();
$result = [
'definition as list' => [new auth_user_md5()],
'definition as list' => [new class extends SimpleORMap {
protected static function configure($config = [])
{
$config['db_table'] = 'auth_user_md5';
$config['i18n_fields'] = ['i18n_field'];
parent::configure($config);
}
}],
'definition as associative array' => [new class extends SimpleORMap {
protected static function configure($config = [])
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment