summaryrefslogtreecommitdiffstats
path: root/core/modules/node/src/Entity/Node.php
diff options
context:
space:
mode:
authorAlex Pott2015-10-02 13:23:53 +0100
committerAlex Pott2015-10-02 13:23:53 +0100
commit158d4345d16a9100518fa3c5f358d3ae4cbc7de5 (patch)
tree058dd5768eeff46aaed62b358f9b4f949a8a8342 /core/modules/node/src/Entity/Node.php
parent1844088377bce9feb8d85f605b2078759619084b (diff)
Issue #2474075 by mkalkbrenner, hchonov, plach, catch: Fix Node::preSave() and document that preSave() and postSave() are not working with ContentEntity translations
Diffstat (limited to 'core/modules/node/src/Entity/Node.php')
-rw-r--r--core/modules/node/src/Entity/Node.php11
1 files changed, 8 insertions, 3 deletions
diff --git a/core/modules/node/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php
index b2ea565..191c875 100644
--- a/core/modules/node/src/Entity/Node.php
+++ b/core/modules/node/src/Entity/Node.php
@@ -91,10 +91,15 @@ class Node extends ContentEntityBase implements NodeInterface {
public function preSave(EntityStorageInterface $storage) {
parent::preSave($storage);
- // If no owner has been set explicitly, make the anonymous user the owner.
- if (!$this->getOwner()) {
- $this->setOwnerId(0);
+ foreach (array_keys($this->getTranslationLanguages()) as $langcode) {
+ $translation = $this->getTranslation($langcode);
+
+ // If no owner has been set explicitly, make the anonymous user the owner.
+ if (!$translation->getOwner()) {
+ $translation->setOwnerId(0);
+ }
}
+
// If no revision author has been set explicitly, make the node owner the
// revision author.
if (!$this->getRevisionAuthor()) {