Security update for Core, with self-updated composer
[yaffs-website] / web / core / lib / Drupal / Core / Config / StorableConfigBase.php
index 4b227c9efbdce2575527e3ccab85b7f4aa0fc264..bc81ab7cc1709367e514712fecd65aab8daf485d 100644 (file)
@@ -3,6 +3,8 @@
 namespace Drupal\Core\Config;
 
 use Drupal\Core\Config\Schema\Ignore;
+use Drupal\Core\Config\Schema\Sequence;
+use Drupal\Core\Config\Schema\SequenceDataDefinition;
 use Drupal\Core\TypedData\PrimitiveInterface;
 use Drupal\Core\TypedData\Type\FloatInterface;
 use Drupal\Core\TypedData\Type\IntegerInterface;
@@ -129,9 +131,7 @@ abstract class StorableConfigBase extends ConfigBase {
    */
   protected function getSchemaWrapper() {
     if (!isset($this->schemaWrapper)) {
-      $definition = $this->typedConfigManager->getDefinition($this->name);
-      $data_definition = $this->typedConfigManager->buildDataDefinition($definition, $this->data);
-      $this->schemaWrapper = $this->typedConfigManager->create($data_definition, $this->data);
+      $this->schemaWrapper = $this->typedConfigManager->createFromNameAndData($this->name, $this->data);
     }
     return $this->schemaWrapper;
   }
@@ -210,6 +210,29 @@ abstract class StorableConfigBase extends ConfigBase {
       foreach ($value as $nested_value_key => $nested_value) {
         $value[$nested_value_key] = $this->castValue($key . '.' . $nested_value_key, $nested_value);
       }
+
+      if ($element instanceof Sequence) {
+        $data_definition = $element->getDataDefinition();
+        if ($data_definition instanceof SequenceDataDefinition) {
+          // Apply any sorting defined on the schema.
+          switch ($data_definition->getOrderBy()) {
+            case 'key':
+              ksort($value);
+              break;
+
+            case 'value':
+              // The PHP documentation notes that "Be careful when sorting
+              // arrays with mixed types values because sort() can produce
+              // unpredictable results". There is no risk here because
+              // \Drupal\Core\Config\StorableConfigBase::castValue() has
+              // already cast all values to the same type using the
+              // configuration schema.
+              sort($value);
+              break;
+
+          }
+        }
+      }
     }
     return $value;
   }