Skip to content

implode() appears to have received backwards-incompatible changes in 11.43.0 #54689

@DeanWunder

Description

@DeanWunder

Laravel Version

11.43.0

PHP Version

8.2.27

Database Driver & Version

MySQL
mysql Ver 8.0.41-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))

Description

When using implode() with 2 arguments, the output has changed. The object gets serialised as json as a result.

> User::take(1)->get()->implode('name', ','); = "{"id":1,"status":"active","stage":"approve","first_name":"first","last_name":"last", (remaining serialization redacted) 

In 11.42.1 this is the output:

> User::take(1)->get()->implode('name', ','); [!] Aliasing 'User' to 'App\Models\User' for this Tinker session. = "first last" 

I believe the offending commit is 9626c3d

Upon removing the added \ at Collection.php:631 in that commit, the issue was resolved.

Steps To Reproduce

  1. Create a new laravel application: https://laravel.com/docs/11.x/installation#creating-a-laravel-project

  2. In tinker, run the following

> User::create(['name' => 'Firstname Last', 'email' => 'first@last.com', 'password' => Hash::make('password')]); = App\Models\User {#6194 name: "Firstname Last", email: "first@last.com", #password: "...", updated_at: "2025-02-19 01:41:00", created_at: "2025-02-19 01:41:00", id: 1, } > User::take(1)->get()->implode('name', ', '); = "{"id":1,"name":"Firstname Last","email":"first@last.com","email_verified_at":null,"created_at":"2025-02-19T01:41:00.000000Z","updated_at":"2025-02-19T01:41:00.000000Z"}" 
  1. Observe the JSON encoded output in v11.43.0. This does not occur in v11.42.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions