Warning upon workspace publishing in case no assets are published

Created on 30 March 2023, about 2 years ago

Problem/Motivation

On some systems (it's likely related to the PHP version or some PHP setting), there's a warning thrown when the component_library_workspaces module is active and the workspace that gets published doesn't contain any component_library_asset entities. I'm not quite sure which PHP setting is related here but the server that throws the notice is running PHP 8.1.17.

Steps to reproduce

drush si -y ; drush en -y component_library_workspaces
Switch to the staging workspace
Add a basic page content
Publish the workspace

The following warning is displayed:

Warning: foreach() argument must be of type array|object, null given in Drupal\component_library_workspaces\EventSubscriber\WorkspacePublishingSubscriber->onPostPublish() (line 163 of modules/contrib/component_library/modules/component_library_workspaces/src/EventSubscriber/WorkspacePublishingSubscriber.php).

Proposed resolution

Don't execute the code any further if $published_asset_data is empty.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

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

Comments & Activities

Production build 0.71.5 2024