Problem/Motivation

  • Error: Call to undefined method Drupal\Core\Form\FormAjaxException::getStatusCode() in google_analytics_page_attachments() (line 73 of /app/web/modules/composer/google_analytics/google_analytics.module)
  • Error: Call to undefined method Drupal\Core\Form\FormAjaxException::getStatusCode() in Drupal\google_analytics\EventSubscriber\PagePath\HttpStatus->onPagePath() (line 60 of /app/web/modules/composer/google_analytics/src/EventSubscriber/PagePath/HttpStatus.php)

Steps to reproduce

  • Enable and configure google_analytics module.
  • Enable and configure the following AI modules - AI CORE, AI SEO, OpenAI .
  • Configure API keys here : Go to: /admin/config/system/keys [using name and openapi key value]
  • Configure the OpenAI provider by selecting the provider name here : /admin/config/ai/providers/openai
  • Now edit any content and click on newly created tab when on node view/edit - Analyze SEO
  • Now click on Analyze button and the error will show up.

Proposed resolution

  • Need to wrap the call to getStatusCode() in a type check before calling getStatusCode() method.
    if ($exception instanceof HttpExceptionInterface) {
      $status = $exception->getStatusCode();
    } else {
      $status = NULL;
    }

Comments

shreyal999 created an issue. See original summary.

shreyal999’s picture

StatusFileSize
new234.28 KB
shreyal999’s picture

Added patch as per the above proposed solution to check if the exception is an HTTPException or not using Symphony's HttpExceptionInterface

shreyal999’s picture

Assigned: shreyal999 » Unassigned
Status: Active » Needs review