PHP error displayed if historical batch process fails

Created on 3 July 2022, over 2 years ago
Updated 5 November 2023, about 1 year ago

Problem/Motivation

When generating a historical report, and if there is an error (for example server timeout), then a PHP error about "htmlspecialchars() expects parameter 1 to be string, array given" is displayed.

Error message
Close
Warning: htmlspecialchars() expects parameter 1 to be string, array given in Drupal\Component\Utility\Html::escape() (line 424 of core/lib/Drupal/Component/Utility/Html.php).
Drupal\Component\Utility\Html::escape(Array) (Line: 262)
Drupal\Component\Render\FormattableMarkup::placeholderEscape(Array) (Line: 208)
Drupal\Component\Render\FormattableMarkup::placeholderFormat('An error occurred while processing @operation with arguments : @args', Array) (Line: 195)
Drupal\Core\StringTranslation\TranslatableMarkup->render() (Line: 15)
Drupal\Core\StringTranslation\TranslatableMarkup->__toString() (Line: 54)
Drupal\Core\Messenger\Messenger->addMessage(Object, 'error', ) (Line: 46)
Drupal\Core\Messenger\Messenger->addError(Object) (Line: 208)
Drupal\accessibility_scanner\Controller\AxeCoreCliAggregateBatchController::batchFinished(, Array, Array, Object) (Line: 456)
_batch_finished() (Line: 98)
_batch_page(Object) (Line: 55)
Drupal\system\Controller\BatchController->batchPage(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
An error occurred while processing with arguments : Array ( [0] => Drupal\accessibility_scanner\Controller\AxeCoreCliAggregateBatchController [1] => batchProcess )

It is unrelated to the underlying error causing the batch process to fail, but isn't handling the error cleanly.

Steps to reproduce

On the run history page for a given web page archive (e.g. admin/config/system/web-page-archive/jobs/[job-name]), click on the 'View Historical Report' button top right.
Assuming you can trigger the batch process to fail, the attached error is displayed.

Proposed resolution

The $operations parameter passed into batchFinished() is not as expected and is an array of arrays. This needs to be handled differently as per the attached patch.

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇮🇪Ireland stella

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024