Problem/Motivation

The acquia_search_preprocess_status_messages() needs refining. Right now it fires on all pages that have messages and throws a large notice when the message structure doesn't match what it's looking for, most notably on all pages for webforms.

Notice: Array to string conversion in acquia_search_preprocess_status_messages() (line 713 of modules/contrib/acquia_connector/acquia_search/acquia_search.module).

The structure for the message on the /admin/config/search/search-api page is @messages[0]->string = "Search API Solr 8.x-1.x support ends 2020-12-31. Ensure to upgrade to 8.x-3.x or newer."

The structure from webform is $message[0][0][#markup]->string = "Unchecking this box will delete ALL aliases you may have created for this form via the path module."

Steps to reproduce

Using Acquia Connector 8.x-1.23 and webform 8.x-5.23 with Drupal 8.9.12. Visit admin/structure/webform/config and see the Notice.

Proposed resolution

This preprocess status message function should be limited to the route /admin/config/search/search-api instead of running on all messages.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

oheller created an issue. See original summary.

oheller’s picture

Issue summary: View changes
oheller’s picture

I suggest adding a path check since this only applies to the search-api admin page:

/**
 * Disable Search API Solr Warning/Error messages regarding EOL.
 * @param $variables
 */
function acquia_search_preprocess_status_messages(&$variables) {
  $current_path = \Drupal::service('path.current')->getPath();
  if (strpos((string)$current_path,"admin/config/search/search-api") == TRUE) {
    if (isset($variables['message_list'])) {
      foreach ($variables['message_list'] as $msg_type => $messages) {
        foreach ($messages as $message_key => $message) {
          if (strpos((string)$message, "Search API Solr 8.x-1.x") !== FALSE) {
            unset($variables['message_list'][$msg_type][$message_key]);
          }
          if (empty($variables['message_list'][$msg_type])) {
            unset($variables['message_list'][$msg_type]);
          }
        }
      }
    }
  }
}
oheller’s picture

kporras07’s picture

Status: Active » Reviewed & tested by the community

I confirm this works as expected. Marking RTBC as the composer error is not related to the provided patch.

japerry’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the report and fix!

  • japerry committed 3805b68 on 8.x-1.x authored by oheller
    Issue #3192623 by oheller: acquia_search_preprocess_status_messages()...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

fadonascimento’s picture

Thanks @oheller to fix that, I confirm this works as expected.
Hey @japerry Any plans to release a minor version to include this fix? I appreciate if you could do it.