Skip to content

explode() expects parameter 2 to be string, array given #22

@swichers

Description

@swichers

On v1.0.1 and 1.0.2 of the library you can receive this error in certain situations where the SQL being passed to the listener is missing.

Example of data being passed into the listener:

# Debug:{"sql":{},"bindings":[],"time":362.02,"connection":{},"connectionName":"mysql"}

The error that occurs:

   ErrorException

  explode() expects parameter 2 to be string, array given

  at vendor/laravel/framework/src/Illuminate/Support/Str.php:483
    479▕      * @return string
    480▕      */
    481▕     public static function replaceArray($search, array $replace, $subject)
    482▕     {
  ➜ 483▕         $segments = explode($search, $subject);
    484▕
    485▕         $result = array_shift($segments);
    486▕
    487▕         foreach ($segments as $segment) {

As a quick fix, inside of ListenQueries I replaced

$sql = Str::replaceArray('?', $normalizedBindings, $query['sql']);

with

$sql = !empty($query['sql']) ? Str::replaceArray('?', $normalizedBindings, $query['sql']) : null;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions