diff -u b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php --- b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -364,6 +364,12 @@ $config = config($prefix . $id); $is_new = $config->isNew(); + if (!$is_new && !isset($entity->original)) { + $this->resetCache(array($id)); + $result = $this->load(array($id)); + $entity->original = reset($result); + } + if ($id !== $entity->id()) { // Renaming a config object needs to cater for: // - Storage controller needs to access the original object. @@ -372,12 +378,6 @@ drupal_container()->get('config.factory')->rename($prefix . $id, $prefix . $entity->id()); } - if (!$is_new && !isset($entity->original)) { - $this->resetCache(array($id)); - $result = $this->load(array($id)); - $entity->original = reset($result); - } - $this->preSave($entity); $this->invokeHook('presave', $entity); only in patch2: unchanged: --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -382,22 +382,6 @@ function image_image_style_update(ImageStyle $style) { } /** - * Implements hook_image_style_delete(). - */ -function image_image_style_delete(ImageStyle $style) { - // Flush cached media for the style. - image_style_flush($style); - // Check whether field instance settings need to be updated. - // In case no replacement style was specified, all image fields that are using - // the deleted style are left in a broken state. - if ($new_id = $style->get('replacementID')) { - // The deleted ID is still set as originalID. - $style->set('name', $new_id); - image_image_style_update($style); - } -} - -/** * Implements hook_field_delete_field(). */ function image_field_delete_field($field) { only in patch2: unchanged: --- a/core/modules/image/lib/Drupal/image/ImageStyleStorageController.php +++ b/core/modules/image/lib/Drupal/image/ImageStyleStorageController.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\Entity\ConfigStorageController; use Drupal\Core\Config\Config; +use Drupal\Core\Entity\EntityInterface; /** * Defines a controller class for image styles. @@ -31,4 +32,31 @@ public function importDelete($name, Config $new_config, Config $old_config) { return image_style_delete($entity); } + /** + * Overrides \Drupal\Core\Config\Entity\ConfigStorageController::postSave(). + */ + protected function postSave(EntityInterface $entity, $update) { + if ($update && !empty($entity->original) && $entity->{$this->idKey} !== $entity->original->{$this->idKey}) { + // The old imagestyle name needs flushing after a rename. + $this->postDelete(array($entity->original)); + } + } + + /** + * Overrides \Drupal\Core\Config\Entity\ConfigStorageController::postDelete(). + */ + protected function postDelete($entities) { + foreach ($entities as $style) { + // Flush cached media for the style. + image_style_flush($style); + // Check whether field instance settings need to be updated. + // In case no replacement style was specified, all image fields that are using + // the deleted style are left in a broken state. + if ($new_id = $style->get('replacementID')) { + // The deleted ID is still set as originalID. + $style->set('name', $new_id); + image_image_style_update($style); + } + } + } }