Skip to content

Bug: lang function does not resolve third level dot notation #10187

@MatuzMark

Description

@MatuzMark

PHP Version

8.5

CodeIgniter4 Version

4.7.2

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

apache

Environment

development

Database

No response

What happened?

I've just updated from v4.6.4 to v4.7.2 CI version, and the lang function does not return the same when the value uses 3 (or more) level dot notation syntax.

Steps to Reproduce

In app/Language/en/Home.php file:

'first' => [
    'title' => 'This is the first level of nesting',
    'second' => [
        'title' => 'This is the second level of nesting',
        'third' => [
            'title' => 'This is the third level of nesting',
        ],
    ]
],

Check it in any controller:

$lang1 = lang('Home.first');
$lang2 = lang('Home.first.second');
$lang3 = lang('Home.first.second.third');
dd($lang1, $lang2, $lang3);

And the dd result is:

Image

Expected Output

As before v4.6.4, the output should be an array just like this:

Image

Anything else?

I think this behavior is not noticed in any upgrade guide or changelog.

This commit changed the way it resolve the dot notation: 61ed3ac#diff-5f660f5efe67f7fa7bd427b02680dd69991ec836344b9b8338fb2d6f2cc9e6ffL148

Fortunately I can refactor my code in this case, but wanted to report it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions