Commit f6d79475 authored by git's avatar git Committed by bojanz

Issue #3020240 by pavlo.dovhan, caseylau, bojanz: Site crash when create/save...

Issue #3020240 by pavlo.dovhan, caseylau, bojanz: Site crash when create/save a store if leave owner be empty
parent 245839ba
......@@ -8,6 +8,7 @@ use Drupal\address\AddressInterface;
use Drupal\commerce_price\Entity\CurrencyInterface;
use Drupal\user\UserInterface;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
......@@ -201,6 +202,22 @@ class Store extends ContentEntityBase implements StoreInterface {
return $this;
}
/**
* {@inheritdoc}
*/
public function preSave(EntityStorageInterface $storage) {
parent::preSave($storage);
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);
}
}
}
/**
* {@inheritdoc}
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment