StorageComparerInterface() is missing createChangelist() and docs for StorageComparer::addChangeList(sort_order) are wrong

Created on 1 December 2023, 9 months ago
Updated 26 January 2024, 8 months ago

Problem/Motivation

We forgot to add StorageComparerInterface::createChangelist(). If you don't call this method then the ConfigImporter doesn't make the expected changes. And we also construct both the ConfigIMporter and StorageComparer directly so I dont think there is any harm in adding.

Steps to reproduce

Run PHPStan on StorageComparer at and decent PHPSTan level.

Proposed resolution

Fix the interface.

Remaining tasks

User interface changes

None

API changes

Not really as StorageComparer has the method already.

Data model changes

None

Release notes snippet

N.a

πŸ› Bug report
Status

Fixed

Version

11.0 πŸ”₯

Component
ConfigurationΒ  β†’

Last updated 1 day ago

Created by

πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @alexpott
  • Merge request !5642Improve docs β†’ (Open) created by alexpott
  • Status changed to Needs review 9 months ago
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ
  • Status changed to RTBC 9 months ago
  • πŸ‡§πŸ‡ͺBelgium borisson_ Mechelen, πŸ‡§πŸ‡ͺ

    In #1890784: Refactor configuration import and sync functions β†’ , the patch where the implementation was added, there was this in the interface.

    +  /**
    +   * Add differences between source and target configuration storage to changelist.
    +   *
    +   * @return \Drupal\Core\Config\StorageComparerInterface
    +   *   An object which implements the StorageComparerInterface.
    +   */
    +  public function createChangelist();

    It was then removed in #2030073: Config cannot be imported in order for dependencies β†’ , but I don't see any discussion about why this was removed in that issue; but since this was already public and we have a 1-1 relation between the Interface and the Class, I guess this was already kind of a public api, so we're not really adding any new api surface.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    @borisson_ nice git sleuthing! Very much looks like my mistake ;D

  • πŸ‡ΊπŸ‡ΈUnited States thejimbirch Cape Cod, Massachusetts

    I'm not sure I am doing this right, so going to talk through the steps and not change the status.

    I applied the patch from this MR to a local site.

    I ran vendor/bin/phpstan analyse web/core/lib/Drupal/Core/Config/StorageComparer.php with my default at level 5 and it passed.

    If I run it at level 9, I get 21 errors:

    ❯ vendor/bin/phpstan analyse -l 9 web/core/lib/Drupal/Core/Config/StorageComparer.php
    Note: Using configuration file /Users/username/Projects/project-name/phpstan.neon.
     1/1 [β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“] 100%
    
     ------ -------------------------------------------------------------------------------------------------------------------------------------------
      Line   StorageComparer.php
     ------ -------------------------------------------------------------------------------------------------------------------------------------------
      50     Property Drupal\Core\Config\StorageComparer::$changelist type has no value type specified in iterable type array.
             πŸ’‘ See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type
      59     Property Drupal\Core\Config\StorageComparer::$sourceNames type has no value type specified in iterable type array.
             πŸ’‘ See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type
      68     Property Drupal\Core\Config\StorageComparer::$targetNames type has no value type specified in iterable type array.
             πŸ’‘ See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type
      148    Method Drupal\Core\Config\StorageComparer::getEmptyChangelist() return type has no value type specified in iterable type array.
             πŸ’‘ See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type
      160    Method Drupal\Core\Config\StorageComparer::getChangelist() return type has no value type specified in iterable type array.
             πŸ’‘ See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type
      180    Method Drupal\Core\Config\StorageComparer::addChangeList() has no return type specified.
      180    Method Drupal\Core\Config\StorageComparer::addChangeList() has parameter $changes with no value type specified in iterable type array.
             πŸ’‘ See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type
      180    Method Drupal\Core\Config\StorageComparer::addChangeList() has parameter $sort_order with no value type specified in iterable type array.
             πŸ’‘ See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type
      223    Method Drupal\Core\Config\StorageComparer::addChangelistDelete() has no return type specified.
      238    Method Drupal\Core\Config\StorageComparer::addChangelistCreate() has no return type specified.
      253    Method Drupal\Core\Config\StorageComparer::addChangelistUpdate() has no return type specified.
      259    Cannot access offset 'uuid' on array|bool.
      290    Method Drupal\Core\Config\StorageComparer::addChangelistRename() has no return type specified.
      344    Method Drupal\Core\Config\StorageComparer::removeFromChangelist() has no return type specified.
      354    Method Drupal\Core\Config\StorageComparer::moveRenameToUpdate() has no return type specified.
      394    Cannot access offset 'uuid' on non-empty-array|true.
      394    Cannot access offset 'uuid' on non-empty-array|true.
      400    Method Drupal\Core\Config\StorageComparer::getAndSortConfigData() has no return type specified.
      400    Method Drupal\Core\Config\StorageComparer::getAndSortConfigData() has parameter $collection with no type specified.
      442    Method Drupal\Core\Config\StorageComparer::extractRenameNames() return type has no value type specified in iterable type array.
             πŸ’‘ See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type
      453    Method Drupal\Core\Config\StorageComparer::getAllCollectionNames() return type has no value type specified in iterable type array.
             πŸ’‘ See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type
     ------ -------------------------------------------------------------------------------------------------------------------------------------------
    
    
    
     [ERROR] Found 21 errors
    
    
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    @thejimbirch core is only doing level 1 scans - and they are done as part of the CI run. Addressing level 9 issues is not in scope for this issue.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    @thejimbirch also none of those are particularly easy to address - for example, we're not adding return types everywhere yet.

  • πŸ‡ΊπŸ‡ΈUnited States thejimbirch Cape Cod, Massachusetts

    Understood. Didn't know the "decent level" from the steps to reproduce. This passed as level 5 with no errors, so indeed much higher than core's normal level 1. +1 for RTBC.

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Quite the find! πŸ˜„

  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    I'm triaging RTBC issues β†’ . I read the IS and the comments. I didn't find any unanswered questions or other work to do. I updated credit.

    Leaving at RTBC.

  • πŸ‡¬πŸ‡§United Kingdom longwave UK

    As this is adding to an interface, although this is very internal stuff and nobody is likely using it outside of core, committing to 11.x only just in case.

    Committed 0439701 and pushed to 11.x. Thanks!

  • Status changed to Fixed 8 months ago
    • longwave β†’ committed 0439701d on 11.x
      Issue #3405574 by alexpott, borisson_: StorageComparerInterface() is...
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024