Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken config files ordering #42

Closed
Spell6inder opened this issue Aug 15, 2019 · 3 comments
Closed

Broken config files ordering #42

Spell6inder opened this issue Aug 15, 2019 · 3 comments

Comments

@Spell6inder
Copy link

What steps will reproduce the problem?

In composer.json

{
    //...
 "extra": {
        "config-plugin": {
            //...
            "common": [
                "common/config/base.php"
            ],
            "backend": [
                "$common",
                "common/config/web.php",
                "backend/config/web.php"
            ],
            "frontend": [
                "$common",
                "common/config/web.php",
                "frontend/config/web.php",
            ]
        }
    },
    //...
}

And looking in /vendor/hiqdev/composer-config-plugin-output/__files.php

What is the expected result?

<?php
//...
return array (
  //...
  'common' => 
  array (
    0 => $baseDir . '/common/config/base.php',
  ),
  'backend' => 
  array (
    0 => $baseDir . '/common/config/base.php',
    1 => $baseDir . '/common/config/web.php',
    2 => $baseDir . '/backend/config/web.php',
  ),
  'frontend' => 
  array (
    0 => $baseDir . '/common/config/base.php',
    1 => $baseDir . '/common/config/web.php',
    2 => $baseDir . '/frontend/config/web.php',
  ),
);

What do you get instead?

<?php
//...
return array (
  //...
  'common' => 
  array (
    0 => $baseDir . '/common/config/base.php',
  ),
  'backend' => 
  array (
    0 => $baseDir . '/common/config/base.php',
    1 => $baseDir . '/common/config/web.php',
    2 => $baseDir . '/backend/config/web.php',
    3 => $baseDir . '/common/config/web.php', // duplicate what rewrite config
  ),
  'frontend' => 
  array (
    0 => $baseDir . '/common/config/base.php',
    1 => $baseDir . '/common/config/web.php',
    2 => $baseDir . '/common/config/web.php', // safe duplicate
    3 => $baseDir . '/frontend/config/web.php',
  ),
);

Additional info

In /vendor/hiqdev/composer-config-plugin/src/Plugin.php:158 property $this->orderedFiles contain

array (
    "common/config/base.php"
    "$common",
    "common/config/web.php",
    "backend/config/web.php"
    "$common",
    "common/config/web.php",
    "frontend/config/web.php",
)
Q A
Version 0.3.0
Composer Version 1.8.4
PHP version 7.2
Operating system Windows 10
@Spell6inder
Copy link
Author

Is realy need to call $this->reorderFiles() in \hiqdev\composer\config\Plugin::onPostAutoloadDump. Judging by code in \hiqdev\composer\config\Plugin::addFile order of $this->orderedFiles is similar to order of $this->files. But $this->files already grouped and don`t create dublicates in result...

//...
        if ('defines' === $name) {
            array_unshift($this->orderedFiles, $path);
            array_unshift($this->files[$name], $path);
        } else {
            array_push($this->orderedFiles, $path);
            array_push($this->files[$name], $path);
        }
//...

@hiqsol
Copy link
Member

hiqsol commented Aug 25, 2019

Looking into it.
Do you have the latest version installed? dev-master?

hiqsol added a commit that referenced this issue Aug 25, 2019
@hiqsol
Copy link
Member

hiqsol commented Aug 25, 2019

Seems like fixed :)

@hiqsol hiqsol closed this as completed Aug 25, 2019
xepozz added a commit to xepozz/hiqdev-fork-composer-config-plugin that referenced this issue May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants