Problem/Motivation

When running ui_patterns_update_10203(), I am getting:

[warning] Undefined array key "pattern" ConfigurationConverter.php:614
[error] Drupal\ui_patterns_legacy\RenderableConverter::getNamespacedId(): Argument #1 ($component_id) must be of type string, null given, called in …/ui_patterns/modules/ui_patterns_legacy/src/ConfigurationConverter.php on line 615
[error] Update failed: ui_patterns_update_10203

Proposed resolution

Make the code robust against $legacySettings['pattern'] not being set.

Remaining tasks

Determine if this is the correct fix. Implement.

User interface changes

None.

API changes

None.

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

liam morland created an issue. See original summary.

liam morland’s picture

Status: Active » Needs review

I have created a merge request with a plausible fix. I don't know if this is properly fixing it or just hiding the problem. This change does allow ui_patterns_update_10203() and the following update hooks to run without error.

grimreaper’s picture

Hi,

Thanks for your feedback on the config upgrade.

Can you please share the structure of the UIP1 config being updated?

To understand how this case can happen.

grimreaper’s picture

Hum, I think I know why you got the warning.

Are you upgrading a website from UIP1 to UIP2 or the website was already with UIP2 before the update?

grimreaper’s picture

Assigned: Unassigned » grimreaper

I think of a simple test to add is to ensure conversion is idempotent.

grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

herved’s picture

I'm having a similar issue on a new project already on ui_patterns 2.0.10, it didn't even use ui_patterns 1.
But when applying composer update which gets ui_patterns 2.0.12, I see all the updates and it leaves ui_patterns_legacy enabled which I of course don't need.

$ ddev drush updb
 ------------- ---------------------------------------------- --------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  Module        Update ID                                      Type            Description                                                                                                                                                                                                                        
 ------------- ---------------------------------------------- --------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  ui_patterns   10201                                          hook_update_n   10201 - UI Patterns 2 upgrade, step 1. Before executing the update, convert your UI Patterns 1 patterns into UI Patterns 2 SDC components! @see https://project.pages.drupalcode.org/ui_patterns/2-authors/3-migration-from-UIP1/  
  ui_patterns   10202                                          hook_update_n   10202 - UI Patterns 2 upgrade, step 2. Enable ui_patterns_legacy and ui_patterns_blocks modules.                                                                                                                                   
  ui_patterns   10203                                          hook_update_n   10203 - UI Patterns 2 upgrade, step 3. Update configuration from UIP1 to UIP2.                                                                                                                                                     
  ui_patterns   10204                                          hook_update_n   10204 - UI Patterns 2 upgrade, step 4. Uninstall UI Patterns 1 only modules.                                                                                                                                                       
  ui_patterns   update_layout_builder_override_ui_patterns_2   post-update     Convert layout builder overrides into UI Patterns 2.   @SuppressWarnings("PHPMD.NPathComplexity")  @SuppressWarnings("PHPMD.CyclomaticComplexity")  @SuppressWarnings("PHPMD.ExcessiveMethodLength")                               
 ------------- ---------------------------------------------- --------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 


 ┌ Do you wish to run the specified pending updates? ───────────┐
 │ Yes                                                          │
 └──────────────────────────────────────────────────────────────┘

>  [notice] Update started: ui_patterns_update_10201
>  [notice] Update completed: ui_patterns_update_10201
>  [notice] Update started: ui_patterns_update_10202
>  [notice] Update completed: ui_patterns_update_10202
>  [notice] Update started: ui_patterns_update_10203
>  [warning] Undefined array key "type" ConfigurationConverter.php:413
>  [warning] Undefined array key "type" ConfigurationConverter.php:413
>  [warning] Undefined array key "type" ConfigurationConverter.php:413
>  [warning] Undefined array key "type" ConfigurationConverter.php:413
>  [warning] Undefined array key "type" ConfigurationConverter.php:413
>  [warning] Undefined array key "type" ConfigurationConverter.php:413
>  [warning] Undefined array key "type" ConfigurationConverter.php:413
>  [warning] Undefined array key "type" ConfigurationConverter.php:413
>  [warning] Undefined array key "type" ConfigurationConverter.php:413
>  [warning] Undefined array key "type" ConfigurationConverter.php:413
>  [warning] Undefined array key "type" ConfigurationConverter.php:413
>  [warning] Undefined array key "type" ConfigurationConverter.php:413
>  [warning] Undefined array key "type" ConfigurationConverter.php:413
>  [notice] Update completed: ui_patterns_update_10203
>  [notice] Update started: ui_patterns_update_10204
>  [notice] Update completed: ui_patterns_update_10204
>  [notice] Update started: ui_patterns_post_update_update_layout_builder_override_ui_patterns_2
>  [notice] No entities to update.
>  [notice] Update completed: ui_patterns_post_update_update_layout_builder_override_ui_patterns_2
 [success] Finished performing updates.

I think all this should only run if we are actually coming from ui_patterns 1.x.

just_like_good_vibes’s picture

Hello, thank you for your help in reporting the problem, we will do a new release soon with the fix.
did you try the current dev version? does it fix the issue you described here?
thank you for your help

grimreaper’s picture

Hi,

Yes ui_patterns_legacy remains enabled at the end of the updates in case some code in Twig templates had not been updated because ui_patterns_legacy provides a compatibility layer at execution time too.

I also thought about that.

Either: add a message at the end of the updates
Or: add a settings in settings.php to allow to skip UIP1 config upgrade
Or: skip the updates if we can detect that an UIP2 module or feature is already present
Or: add a "marker" (state) in UIP1 with an update and tell to update from UIP1 from this version

Status: Fixed » Closed (fixed)

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