Undefined function drush_backend_batch_process()

Created on 6 May 2025, 2 months ago

Problem/Motivation

A PHP fatal error is thrown when processing the SwapcardQueueWorkerRequest queue due to a call to an undefined function:
Error: "Call to undefined function Drupal\swapcard_content\Plugin\QueueWorker\drush_backend_batch_process()"
The issue occurs because the procedural Drush function drush_backend_batch_process() is called without a leading backslash (\), causing PHP to look for it within the current namespace (Drupal\swapcard_content\Plugin\QueueWorker), where it does not exist.

Steps to reproduce

Trigger the SwapcardQueueWorkerRequest queue, for example via cron or manual queue execution.

Ensure that drush_backend_batch_process() is called during execution (e.g., batch operations).

Observe the error in logs:

Call to undefined function Drupal\swapcard_content\Plugin\QueueWorker\drush_backend_batch_process()

Proposed resolution

Prefix the call to drush_backend_batch_process() with a backslash to reference the global function:
\drush_backend_batch_process();
This ensures PHP resolves the function correctly from the global namespace.

Remaining tasks

Update SwapcardQueueWorkerRequest.php to prefix the function call.

Manually test queue processing to confirm no fatal error occurs.

Optionally add a check to ensure Drush is available if running outside a Drush context.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

1.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States eliasbrat

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024