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

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

Closes #4864

Merge request studip/studip!3643
parent 4d62dac9
No related branches found
No related tags found
No related merge requests found
...@@ -2233,6 +2233,14 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate ...@@ -2233,6 +2233,14 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
if ($this->content[$field] === null || $this->content_db[$field] === null) { if ($this->content[$field] === null || $this->content_db[$field] === null) {
return $this->content[$field] !== $this->content_db[$field]; return $this->content[$field] !== $this->content_db[$field];
} else if ($this->content[$field] instanceof I18NString || $this->content_db[$field] instanceof I18NString) { } 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]; return $this->content[$field] != $this->content_db[$field];
} else { } else {
return (string)$this->content[$field] !== (string)$this->content_db[$field]; return (string)$this->content[$field] !== (string)$this->content_db[$field];
......
...@@ -25,8 +25,6 @@ class auth_user_md5 extends SimpleORMap ...@@ -25,8 +25,6 @@ class auth_user_md5 extends SimpleORMap
$config['serialized_fields']['jsondata'] = 'JSONArrayObject'; $config['serialized_fields']['jsondata'] = 'JSONArrayObject';
$config['notification_map']['after_store'] = 'auth_user_md5DidCreateOrUpdate'; $config['notification_map']['after_store'] = 'auth_user_md5DidCreateOrUpdate';
$config['i18n_fields'] = ['i18n_field'];
parent::configure($config); parent::configure($config);
} }
...@@ -366,7 +364,14 @@ class SimpleOrMapNodbTest extends \Codeception\Test\Unit ...@@ -366,7 +364,14 @@ class SimpleOrMapNodbTest extends \Codeception\Test\Unit
self::setupFixture(); self::setupFixture();
$result = [ $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 { 'definition as associative array' => [new class extends SimpleORMap {
protected static function configure($config = []) 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