Problem/Motivation

I am seeing error messages like this:

Warning: Undefined array key "null" in Drupal\purge\Plugin\Purge\Queue\QueueService->getLabel() (line 370 of /…/purge/src/Plugin/Purge/Queue/QueueService.php).

The error is on this line:

return $this->getPlugins()[current($this->getPluginsEnabled())]['label'];

There is not protection against $this->getPluginsEnabled() returning a key that is not in the array returned by $this->getPlugins(). In my case, current($this->getPluginsEnabled()) gives 'null' (the string, not NULL), which comes from QueueService::FALLBACK_PLUGIN.

Similar code exists in ::getDescription().

Steps to reproduce

I see this every time I load admin/config/development/performance/purge.

Proposed resolution

Provide a fallback to avoid the error or a mechanism to ensure that $this->getPluginsEnabled() does not return empty.

Remaining tasks

Figure out what is wrong. Implement.

User interface changes

None.

API changes

None.

Data model changes

None.

Issue fork purge-3494881

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

Issue summary: View changes

liam morland’s picture

Status: Active » Needs review

The change in the merge request does remove the error messages and provide fallback text. I'm not sure if this is a good solution or not. The string would need to be translated.