Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug: BaseConfig issue on registrar #9231

Open
@ChibuezeAgwuDennis

Description

@ChibuezeAgwuDennis

PHP Version

8.2

CodeIgniter4 Version

4.5.5

CodeIgniter4 Installation Method

Manual (zip or tar.gz)

Which operating systems have you tested for this bug?

Windows, Linux

Which server did you use?

apache

Database

MySQL

What happened?

New registrar with the same method with other registrars replaces their contents on array_merge which works on only first level array. I hope array_merge_recursive will be better for modules

Steps to Reproduce

\Codeigniter\Config\BaseConfig

/**    * Provides external libraries a simple way to register one or more    * options into a config file.    *    * @return void    *    * @throws ReflectionException    */protectedfunctionregisterProperties()    {if (!static::$moduleConfig->shouldDiscover('registrars')) {return;        }if (!static::$didDiscovery) {$locator        =service('locator');$registrarsFiles =$locator->search('Config/Registrar.php');foreach ($registrarsFilesas$file) {$className =$locator->findQualifiedNameFromPath($file);if ($className ===false) {continue;                }static::$registrars[] =new$className();            }static::$didDiscovery =true;        }$shortName = (newReflectionClass($this))->getShortName();// Check the registrar class for a method named after this class' shortNameforeach (static::$registrarsas$callable) {// ignore non-applicable registrarsif (!method_exists($callable,$shortName)) {continue;// @codeCoverageIgnore            }$properties =$callable::$shortName();if (!is_array($properties)) {thrownewRuntimeException('Registrars must return an array of properties and their values.');            }foreach ($propertiesas$property =>$value) {if (isset($this->{$property}) &&is_array($this->{$property}) &&is_array($value)) {$this->{$property} =array_merge($this->{$property},$value);                }else {$this->{$property} =$value;                }            }        }    }

Expected Output

Expected merge the old contents array with the new one

Anything else?

Yes i used array_merge_recursive. I discovered the issue to so i extend the base config to child class today fix this but i think the usage of array_merge_recursive is a better option help on this to update the core code

\Codeigniter\Config\BaseConfig

/**    * Provides external libraries a simple way to register one or more    * options into a config file.    *    * @return void    *    * @throws ReflectionException    */protectedfunctionregisterProperties()    {if (!static::$moduleConfig->shouldDiscover('registrars')) {return;        }if (!static::$didDiscovery) {$locator        =service('locator');$registrarsFiles =$locator->search('Config/Registrar.php');foreach ($registrarsFilesas$file) {$className =$locator->findQualifiedNameFromPath($file);if ($className ===false) {continue;                }static::$registrars[] =new$className();            }static::$didDiscovery =true;        }$shortName = (newReflectionClass($this))->getShortName();// Check the registrar class for a method named after this class' shortNameforeach (static::$registrarsas$callable) {// ignore non-applicable registrarsif (!method_exists($callable,$shortName)) {continue;// @codeCoverageIgnore            }$properties =$callable::$shortName();if (!is_array($properties)) {thrownewRuntimeException('Registrars must return an array of properties and their values.');            }foreach ($propertiesas$property =>$value) {if (isset($this->{$property}) &&is_array($this->{$property}) &&is_array($value)) {$this->{$property} =array_merge_recursive($this->{$property},$value);                }else {$this->{$property} =$value;                }            }        }    }

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp