Problem/Motivation

When using drush to run database updates after trying to upgrade from search_api_acquia to acquia_search there are errors output to the console.
TypeError: strtr(): Argument #2 ($from) must be of type array, string given in strtr() (line 115 of /var/www/html/docroot/modules/syslog/syslog.module).

I think these stem from the module using an empty string instead of an empty array or a NULL value in the watchdog calls.
e.g.:

// Disable Search API Acquia module.
if (module_exists('search_api_acquia')) {
  module_disable(['search_api_acquia']);
  watchdog('acquia_search', 'Search API Acquia has been disabled. You can safely remove it from your codebase.', '', WATCHDOG_INFO);
}

Steps to reproduce

Have a d7 site with search_api_acquia setup
Download an install acquia_search
Run:
drush updb

Proposed resolution

Fix the watchdog issues
Create a patch
Review the patch
Commit the patch

Remaining tasks

Fix the watchdog issues
Create a patch
Review the patch
Commit the patch

User interface changes

None

API changes

None

Data model changes

None

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

the_g_bomb created an issue. See original summary.

the_g_bomb’s picture

Sorry, not sure what happened, but the the MR connected in #2 is for a different Issue that is unrelated to this one. No idea why it is connected to this.
MR in #3 should be tested

i-trokhanenko’s picture

Status: Active » Needs review
i-trokhanenko’s picture

Status: Needs review » Reviewed & tested by the community

The #39 patch solves the error for me. Thanks!

mglaman’s picture

Status: Reviewed & tested by the community » Needs work

At first I thought we should pass an array.

watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL)
 * @param $variables
 *   Array of variables to replace in the message on display or
 *   NULL if message is already translated or not possible to
 *   translate.

But now I see it allows null and array.

Here is the code from syslog:

'!message'     => strip_tags((string) (!isset($log_entry['variables']) ? $log_entry['message'] : strtr($log_entry['message'], $log_entry['variables']))),

Thanks for the MR!

mglaman’s picture

Status: Needs work » Reviewed & tested by the community

whoops, fixing status

  • mglaman committed db6b36fd on 7.x-4.x authored by the_g_bomb
    Issue #3349846 by the_g_bomb: TypeError: strtr(): Argument #2 ($from)...
mglaman’s picture

Status: Reviewed & tested by the community » Fixed

Thanks! We have a pending release planned that will include this fix.

Status: Fixed » Closed (fixed)

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