Problem/Motivation

There is no need to a separate SchemaStorage class to exist.

Proposed resolution

Refactor base schema types to be read in TypedConfigManager and refactor other functionality into InstallStorage and ExtensionInstallStorage.

The main benefit is we have less code to maintain and more explicit assumptions in the correct place.

Remaining tasks

Review

User interface changes

None

API changes

Remove SchemaStorage

Files: 
CommentFileSizeAuthor
#15 2184387.15.patch10.83 KBalexpott
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,620 pass(es). View
#15 14-15-interdiff.txt1.39 KBalexpott
#14 2184387.14.patch10.83 KBalexpott
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,541 pass(es). View
#14 10-14-interdiff.txt2.72 KBalexpott
#10 interdiff.txt2.54 KBsun
#10 schema.storage.10.patch10.85 KBsun
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,522 pass(es). View
#8 interdiff.txt3.53 KBsun
#8 schema.storage.8.patch8.31 KBsun
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 66,765 pass(es), 1 fail(s), and 0 exception(s). View
#5 drupal8.config-schema-storage-core.do-not-test.patch952 bytessun
#3 2184387.3.patch12.82 KBalexpott
PASSED: [[SimpleTest]]: [MySQL] 63,259 pass(es). View
#3 1-3-interdiff.txt5 KBalexpott
#1 2184387.1.patch9.24 KBalexpott
FAILED: [[SimpleTest]]: [MySQL] 63,251 pass(es), 2 fail(s), and 2 exception(s). View

Comments

alexpott’s picture

Status: Active » Needs review
FileSize
9.24 KB
FAILED: [[SimpleTest]]: [MySQL] 63,251 pass(es), 2 fail(s), and 2 exception(s). View

A patch to review :)

Status: Needs review » Needs work

The last submitted patch, 1: 2184387.1.patch, failed testing.

alexpott’s picture

Status: Needs work » Needs review
FileSize
5 KB
12.82 KB
PASSED: [[SimpleTest]]: [MySQL] 63,259 pass(es). View

Talked with @sun in IRC and he came up with the idea that maybe core should have a config/schema directory.

Also fixed up the strange LocaleConfigManagerTest that was making unnecessary use of InstallStorage

sun’s picture

+++ b/core/lib/Drupal/Core/Config/InstallStorage.php
@@ -137,6 +138,24 @@
+  protected function getCoreComponents() {
+    $extension = '.' . $this->getFileExtension();
+    $folders = array();
+    $directory = DRUPAL_ROOT . '/core/' . $this->folderToScan;
+    $files = new \GlobIterator($directory . '/*' . $extension);
+    foreach ($files as $file) {
+      $folders[$file->getBasename($extension)] = $directory;
+    }
+    return $folders;
+  }

Can a config/schema directory have subdirectories?

Thus far, I assumed we'd only support files in that directory, not further subdirectories?

In other words, I expected this to simply be:

return array(
  'core' => DRUPAL_ROOT . '/core/' . $this->folderToScan;
);

?

sun’s picture

If we'd additionally do the change in attached patch, then we could simply use getComponentNames('core', 'core') as is? :)

sun’s picture

The proposal in #5 is also part of the architectural proposal in the new extension system meta.

sun’s picture

sun’s picture

Parent issue: » #2190723: Add a KeyValueStore\FileStorage to replace e.g. ConfigStorage
FileSize
8.31 KB
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 66,765 pass(es), 1 fail(s), and 0 exception(s). View
3.53 KB

That change has landed, so this patch gets much simpler now :-)

Re-rolled against HEAD, and:

  1. Removed obsolete getCoreComponents() method.
  2. Reverted faulty removal of variable initialization in TypedConfigManager::getDefinitions().
  3. Renamed $folderToScan to $collection → identical change as in #2190723: Add a KeyValueStore\FileStorage to replace e.g. ConfigStorage

Status: Needs review » Needs work

The last submitted patch, 8: schema.storage.8.patch, failed testing.

sun’s picture

Assigned: Unassigned » sun
Status: Needs work » Needs review
FileSize
10.85 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,522 pass(es). View
2.54 KB

Removed obsolete TestSchemaStorage.

sun’s picture

10: schema.storage.10.patch queued for re-testing.

alexpott’s picture

Status: Needs review » Needs work
  1. +++ b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php
    @@ -7,11 +7,11 @@
    + * Storage controller to access configuration and schema in enabled extensions.
    

    Remove the word controller it is confusing with route controllers.

  2. +++ b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php
    @@ -28,16 +28,13 @@ class ExtensionInstallStorage extends InstallStorage {
    +   * @param string $collection
    +   *   The folder to scan in each extension to scan for files. Defaults to
    +   *   'config'.
        */
    -  public function __construct(StorageInterface $config_storage) {
    +  public function __construct(StorageInterface $config_storage, $collection = 'config') {
         $this->configStorage = $config_storage;
    -  }
    -
    -  /**
    -   * Resets the static cache.
    -   */
    -  public function reset() {
    -    $this->folders = NULL;
    +    $this->collection = $collection;
       }
    
    +++ b/core/lib/Drupal/Core/Config/InstallStorage.php
    @@ -30,9 +30,21 @@ class InstallStorage extends FileStorage {
    +  protected $collection;
    ...
    +   * @param string $collection
    +   *   The folder to scan in each extension to scan for files. Defaults to
    +   *   'config'.
    ...
    +  public function __construct($collection = 'config') {
    +    $this->collection = $collection;
    
    @@ -169,7 +188,7 @@ public function getComponentNames($type, array $list) {
    +    return drupal_get_path($type, $name) . '/' . $this->collection;
    

    Can we not just call $collection directory. You might have plans to move this to key value but atm it is the file system.

Berdir’s picture

Looks great, I just found two minor coding style issues. Certainly makes sense, it's a somewhat similar pattern as the language override storage, that also makes storage folder configurable and even allows to change it.

Agree with $collection being a strange name, +1 to directory. As those storages are explicitly about scanning module config directories, they will never be related to key value collections...

Also +1 to to remove controller, we already have a separate issue to remove it everywhere but when we touch it anyway...

  1. +++ b/core/lib/Drupal/Core/Config/InstallStorage.php
    @@ -30,9 +30,21 @@ class InstallStorage extends FileStorage {
        * Overrides Drupal\Core\Config\FileStorage::__construct().
    

    Can we fix the line her as well? Should be something like Constructs a X object, we can't do @inheritdoc if we extend it.

  2. +++ b/core/lib/Drupal/Core/Config/InstallStorage.php
    @@ -65,12 +77,19 @@ public function getFilePath($name) {
    +   * Implements \Drupal\Core\Config\StorageInterface::exists().
    +   */
    +  public function exists($name) {
    +    return array_key_exists($name, $this->getAllFolders());
    +  }
    

    @inheritdoc.

    getAllFolders() is a very confusing method name, assumed that it returns folders, but it returns an array keyed by configuration files with the folder as value.

    Not related to this issue.

  3. +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigManagerTest.php
    @@ -40,18 +40,13 @@ public static function getInfo() {
         $language = new Language(array('id' => 'de'));
    -    $this->assertFalse($locale_config_manager->hasTranslation('locale_test.no_translation', $language), 'There is no translation for locale_test.no_translation configuration.');
    -    $this->assertTrue($locale_config_manager->hasTranslation('locale_test.translation', $language), 'There is a translation for locale_test.translation configuration.');
    +    $result = $locale_config_manager->hasTranslation('locale_test.no_translation', $language);
    +    $this->assertFalse($result, 'There is no translation for locale_test.no_translation configuration.');
    +
    +    $result = $locale_config_manager->hasTranslation('locale_test.translation', $language);
    +    $this->assertTrue($result, 'There is a translation for locale_test.translation configuration.');
    

    Just wondering if there's an actual change on those lines or just making them better readable? Because I don't see a change :)

alexpott’s picture

Status: Needs work » Needs review
FileSize
2.72 KB
10.83 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,541 pass(es). View

Fixed everything from my review.

And for @berdir

  1. Fixed
  2. Fixed and opened #2235701: InstallStorage and ExtensionInstallStorage need update for documentation standards and getFolders() is a bad name to address the getFolders issue.
  3. I guess its more readable.
alexpott’s picture

FileSize
1.39 KB
10.83 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,620 pass(es). View

Using directory consistently...

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, this looks good now I think.

@alexpott and I shortly discussed folder vs directory and it looks like folder is more used as an UI term in windows/osx and the only place where we used folder right now, is the getAllFolders() method and the related $this->folders property, for which @alexpott already opened an issue to rename it to something better.

I assume this will pass, so RTBC.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

  • Commit 48ae970 on 8.x by catch:
    Issue #2184387 by alexpott, sun: Remove SchemaStorage.
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.