diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-11-13 15:43:59 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-11-13 15:43:59 +0000 |
| commit | 2394ba61250dc67915488c71dea42eb4e0492833 (patch) | |
| tree | 8f859d8542f5341a7681530adcaa2e1b3589e3fa | |
| parent | 4d62dac9edb0bb0161579f740306d109b98c95cb (diff) | |
load translations before comparing i18n field contents in SimpleORMap::isFieldDirty(), fixes #4864
Closes #4864
Merge request studip/studip!3643
| -rw-r--r-- | lib/classes/SimpleORMap.php | 8 | ||||
| -rw-r--r-- | tests/unit/lib/classes/SimpleOrMapNodbTest.php | 11 |
2 files changed, 16 insertions, 3 deletions
diff --git a/lib/classes/SimpleORMap.php b/lib/classes/SimpleORMap.php index d2cbcdc..f3993c2 100644 --- a/lib/classes/SimpleORMap.php +++ b/lib/classes/SimpleORMap.php @@ -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]; diff --git a/tests/unit/lib/classes/SimpleOrMapNodbTest.php b/tests/unit/lib/classes/SimpleOrMapNodbTest.php index 3ede1aa..9fa1eed 100644 --- a/tests/unit/lib/classes/SimpleOrMapNodbTest.php +++ b/tests/unit/lib/classes/SimpleOrMapNodbTest.php @@ -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 = []) { |
