- Issue created by @eliasbrat
- Merge request !1Fix fatal error in SwapcardQueueWorkerRequest due to missing global namespace for Drush function β (Open) created by eliasbrat
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.
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()
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.
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.
None.
None.
None.
Active
1.1
Code