Update to Drupal 8.0.5. For more information, see https://www.drupal.org/node/2679347

This commit is contained in:
Pantheon Automation 2016-03-02 12:40:24 -08:00 committed by Greg Anderson
parent 2a9f1f148d
commit fd3b12cf27
251 changed files with 5439 additions and 957 deletions

View file

@ -302,7 +302,7 @@ class ConfigManager implements ConfigManagerInterface {
$dependency_manager = $this->getConfigDependencyManager();
$dependents = $this->findConfigEntityDependentsAsEntities($type, $names, $dependency_manager);
$original_dependencies = $dependents;
$update_uuids = [];
$delete_uuids = $update_uuids = [];
$return = [
'update' => [],
@ -311,26 +311,35 @@ class ConfigManager implements ConfigManagerInterface {
];
// Try to fix any dependencies and find out what will happen to the
// dependency graph.
foreach ($dependents as $dependent) {
// dependency graph. Entities are processed in the order of most dependent
// first. For example, this ensures that fields are removed before
// field storages.
while ($dependent = array_pop($dependents)) {
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $dependent */
if ($dry_run) {
// Clone the entity so any changes do not change any static caches.
$dependent = clone $dependent;
}
$fixed = FALSE;
if ($this->callOnDependencyRemoval($dependent, $original_dependencies, $type, $names)) {
// Recalculate dependencies and update the dependency graph data.
$dependent->calculateDependencies();
$dependency_manager->updateData($dependent->getConfigDependencyName(), $dependent->getDependencies());
// Based on the updated data rebuild the list of dependents.
// Based on the updated data rebuild the list of dependents. This will
// remove entities that are no longer dependent after the recalculation.
$dependents = $this->findConfigEntityDependentsAsEntities($type, $names, $dependency_manager);
// Remove any entities that we've already marked for deletion.
$dependents = array_filter($dependents, function ($dependent) use ($delete_uuids) {
return !in_array($dependent->uuid(), $delete_uuids);
});
// Ensure that the dependency has actually been fixed. It is possible
// that the dependent has multiple dependencies that cause it to be in
// the dependency chain.
$fixed = TRUE;
foreach ($dependents as $entity) {
foreach ($dependents as $key => $entity) {
if ($entity->uuid() == $dependent->uuid()) {
$fixed = FALSE;
unset($dependents[$key]);
break;
}
}
@ -339,15 +348,12 @@ class ConfigManager implements ConfigManagerInterface {
$update_uuids[] = $dependent->uuid();
}
}
// If the entity cannot be fixed then it has to be deleted.
if (!$fixed) {
$delete_uuids[] = $dependent->uuid();
$return['delete'][] = $dependent;
}
}
// Now that we've fixed all the possible dependencies the remaining need to
// be deleted. Reverse the deletes so that entities are removed in the
// correct order of dependence. For example, this ensures that fields are
// removed before field storages.
$return['delete'] = array_reverse($dependents);
$delete_uuids = array_map(function($dependent) {
return $dependent->uuid();
}, $return['delete']);
// Use the lists of UUIDs to filter the original list to work out which
// configuration entities are unchanged.
$return['unchanged'] = array_filter($original_dependencies, function ($dependent) use ($delete_uuids, $update_uuids) {

View file

@ -352,6 +352,32 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
}
}
/**
* {@inheritdoc}
*/
public function __sleep() {
$keys_to_unset = [];
if ($this instanceof EntityWithPluginCollectionInterface) {
$vars = get_object_vars($this);
foreach ($this->getPluginCollections() as $plugin_config_key => $plugin_collection) {
// Save any changes to the plugin configuration to the entity.
$this->set($plugin_config_key, $plugin_collection->getConfiguration());
// If the plugin collections are stored as properties on the entity,
// mark them to be unset.
$keys_to_unset += array_filter($vars, function ($value) use ($plugin_collection) {
return $plugin_collection === $value;
});
}
}
$vars = parent::__sleep();
if (!empty($keys_to_unset)) {
$vars = array_diff($vars, array_keys($keys_to_unset));
}
return $vars;
}
/**
* {@inheritdoc}
*/

View file

@ -207,8 +207,9 @@ class FileStorage implements StorageInterface {
$files = scandir($dir);
$names = array();
$pattern = '/^' . preg_quote($prefix, '/') . '.*' . preg_quote($extension, '/') . '$/';
foreach ($files as $file) {
if ($file[0] !== '.' && fnmatch($prefix . '*' . $extension, $file)) {
if ($file[0] !== '.' && preg_match($pattern, $file)) {
$names[] = basename($file, $extension);
}
}
@ -290,6 +291,7 @@ class FileStorage implements StorageInterface {
*/
protected function getAllCollectionNamesHelper($directory) {
$collections = array();
$pattern = '/\.' . preg_quote($this->getFileExtension(), '/') . '$/';
foreach (new \DirectoryIterator($directory) as $fileinfo) {
if ($fileinfo->isDir() && !$fileinfo->isDot()) {
$collection = $fileinfo->getFilename();
@ -309,7 +311,7 @@ class FileStorage implements StorageInterface {
// collection.
// @see \Drupal\Core\Config\FileStorage::listAll()
foreach (scandir($directory . '/' . $collection) as $file) {
if ($file[0] !== '.' && fnmatch('*.' . $this->getFileExtension(), $file)) {
if ($file[0] !== '.' && preg_match($pattern, $file)) {
$collections[] = $collection;
break;
}

View file

@ -190,6 +190,7 @@ class InstallStorage extends FileStorage {
*/
public function getComponentNames(array $list) {
$extension = '.' . $this->getFileExtension();
$pattern = '/' . preg_quote($extension, '/') . '$/';
$folders = array();
foreach ($list as $extension_object) {
// We don't have to use ExtensionDiscovery here because our list of
@ -203,7 +204,7 @@ class InstallStorage extends FileStorage {
$files = scandir($directory);
foreach ($files as $file) {
if ($file[0] !== '.' && fnmatch('*' . $extension, $file)) {
if ($file[0] !== '.' && preg_match($pattern, $file)) {
$folders[basename($file, $extension)] = $directory;
}
}
@ -220,6 +221,7 @@ class InstallStorage extends FileStorage {
*/
public function getCoreNames() {
$extension = '.' . $this->getFileExtension();
$pattern = '/' . preg_quote($extension, '/') . '$/';
$folders = array();
$directory = $this->getCoreFolder();
if (is_dir($directory)) {
@ -230,7 +232,7 @@ class InstallStorage extends FileStorage {
$files = scandir($directory);
foreach ($files as $file) {
if ($file[0] !== '.' && fnmatch('*' . $extension, $file)) {
if ($file[0] !== '.' && preg_match($pattern, $file)) {
$folders[basename($file, $extension)] = $directory;
}
}