Cotya / magento-composer-installer

Composer installer for Magento modules
211 stars 77 forks source link

2.1.3 infinite loop on install #95

Closed convenient closed 8 years ago

convenient commented 8 years ago

The loop is definitely infinite, I boosted the max nesting level to 2000 and then we started getting out of memory errors like: PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 523800 bytes)

     - Installing magento-hackathon/magento-composer-installer (2.1.3)
       Downloading: Connecting...    Downloading: 100%
   PHP Fatal error:  Maximum function nesting level of '256' reached, aborting! in phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/src/Composer/Package/Package.php on line 155
   PHP Stack trace:
   PHP   1. {main}() /home/travis/.phpenv/versions/5.3.29/bin/composer:0
   PHP   2. require() /home/travis/.phpenv/versions/5.3.29/bin/composer:25
   PHP   3. Composer\Console\Application->run() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/bin/composer:43
   PHP   4. Symfony\Component\Console\Application->run() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/src/Composer/Console/Application.php:99
   PHP   5. Composer\Console\Application->doRun() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/vendor/symfony/console/Application.php:123
   PHP   6. Symfony\Component\Console\Application->doRun() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/src/Composer/Console/Application.php:166
   PHP   7. Symfony\Component\Console\Application->doRunCommand() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/vendor/symfony/console/Application.php:192
   PHP   8. Symfony\Component\Console\Command\Command->run() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/vendor/symfony/console/Application.php:844
   PHP   9. Composer\Command\InstallCommand->execute() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/vendor/symfony/console/Command/Command.php:259
   PHP  10. Composer\Installer->run() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/src/Composer/Command/InstallCommand.php:134
   PHP  11. Composer\Installer->doInstall() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/src/Composer/Installer.php:232
   PHP  12. Composer\Installer\InstallationManager->execute() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/src/Composer/Installer.php:600
   PHP  13. Composer\Installer\InstallationManager->install() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/src/Composer/Installer/InstallationManager.php:139
   PHP  14. MagentoHackathon\Composer\Magento\Installer\CoreInstaller->install() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/src/Composer/Installer/InstallationManager.php:152
   PHP  15. MagentoHackathon\Composer\Magento\Installer\MagentoInstallerAbstract->install() /home/travis/build/Convenient/project/vendor/magento-hackathon/magento-composer-installer/src/MagentoHackathon/Composer/Magento/Installer/CoreInstaller.php:110
   PHP  16. Composer\Installer\LibraryInstaller->install() /home/travis/build/Convenient/project/vendor/magento-hackathon/magento-composer-installer/src/MagentoHackathon/Composer/Magento/Installer/MagentoInstallerAbstract.php:359
   PHP  17. MagentoHackathon\Composer\Magento\Installer\CoreInstaller->getInstallPath() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/src/Composer/Installer/LibraryInstaller.php:84
   PHP  18. Composer\Installer\LibraryInstaller->getPackageBasePath() /home/travis/build/Convenient/project/vendor/magento-hackathon/magento-composer-installer/src/MagentoHackathon/Composer/Magento/Installer/CoreInstaller.php:156
   PHP  19. MagentoHackathon\Composer\Magento\Installer\CoreInstaller->getInstallPath() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/src/Composer/Installer/LibraryInstaller.php:164
   PHP  20. Composer\Installer\LibraryInstaller->getPackageBasePath() /home/travis/build/Convenient/project/vendor/magento-hackathon/magento-composer-installer/src/MagentoHackathon/Composer/Magento/Installer/CoreInstaller.php:156
   PHP  21. MagentoHackathon\Composer\Magento\Installer\CoreInstaller->getInstallPath() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/src/Composer/Installer/LibraryInstaller.php:164
   PHP  22. Composer\Installer\LibraryInstaller->getPackageBasePath() /home/travis/build/Convenient/project/vendor/magento-hackathon/magento-composer-installer/src/MagentoHackathon/Composer/Magento/Installer/CoreInstaller.php:156
   PHP  23. MagentoHackathon\Composer\Magento\Installer\CoreInstaller->getInstallPath() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/src/Composer/Installer/LibraryInstaller.php:164
   PHP  24. Composer\Installer\LibraryInstaller->getPackageBasePath() /home/travis/build/Convenient/project/vendor/magento-hackathon/magento-composer-installer/src/MagentoHackathon/Composer/Magento/Installer/CoreInstaller.php:156
   PHP  25. MagentoHackathon\Composer\Magento\Installer\CoreInstaller->getInstallPath() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/src/Composer/Installer/LibraryInstaller.php:164
   PHP  26. Composer\Installer\LibraryInstaller->getPackageBasePath() /home/travis/build/Convenient/project/vendor/magento-hackathon/magento-composer-installer/src/MagentoHackathon/Composer/Magento/Installer/CoreInstaller.php:156
   PHP  27. MagentoHackathon\Composer\Magento\Installer\CoreInstaller->getInstallPath() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/src/Composer/Installer/LibraryInstaller.php:164
   PHP  28. Composer\Ianstaller\LibraryInstaller->getPackageBasePath() /home/travis/build/Convenient/project/vendor/magento-hackathon/magento-composer-installer/src/MagentoHackathon/Composer/Magento/Installer/CoreInstaller.php:156
   PHP  29. MagentoHackathon\Composer\Magento\Installer\CoreInstaller->getInstallPath() phar:///home/travis/.phpenv/versions/5.3.29/bin/composer/src/Composer/Installer/LibraryInstaller.php:164
   PHP  30. Composer\Installer\LibraryInstaller->getPackageBasePath() /home/travis/build/Convenient/project/vendor/magento-hackathon/magento-composer-installer/src/MagentoHackathon/Composer/Magento/Installer/CoreInstaller.php:156
Flyingmana commented 8 years ago

is it a pure install without existing vendor/ ? does this also happen with 2.1.2?

I see CoreInstaller in the stacktrace, do you make use of it?

convenient commented 8 years ago

Hey.

This problem arose on an internal community module which used your installer to install a copy of Magento on travis to run a series of integration tests against. This magento instance is composer installed into tests/magento/magentomodule. We didn't test 2.1.2 cause it looked like there was no such thing?

We've fixed the suite for now by locking it to 2.1.1.

https://github.com/Cotya/magento-composer-installer/releases/tag/2.1.2

Module structure

I've had to trim this out a bit as it's closed source. But you can see the basis of it.

├── app
│   ├── code
│   │   └── community
│   └── etc
│       └── modules
├── .travis.yml
├── composer.json
├── phpunit.xml.dist
└── tests
    ├── SomeTest.php
    └── magento
        └── magentomodule

composer.json

Again, this has been trimmed down because it is closed source. The module itself requires a separate internal installer to be installed into other projects. The require-dev dependency on your installer is so that we can install a copy of magento to the tests/magento/magentomodulefolder.

{
  "name": "convenient/modulename",
  "type": "closedsource-magento",
  "require": {
    "closedsource/magento-installer": "1.*",
  },
  "repositories": [
    {
      "type": "composer",
      "url": "http://packages.firegento.com"
    }
  ],
  "require-dev": {
    "magento-hackathon/magento-composer-installer": "2.1.3",
    "magento/core": "1.9.1.0",
    "phpunit/phpunit": "^4.8"
  },
  "extra": {
    "magento-root-dir": "./tests/magento/modulename"
  }
}

.travis.yml

language: php
php:
  - 5.3

env:
  - MAGE_INSTALL_PATH="./tests/magento/magentomodule"

before_install:
  - XDEBUG_CONF=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
  - mv "$XDEBUG_CONF" "$XDEBUG_CONF".bak

install:
  # Composer install
  - composer self-update
  - composer install --no-interaction --prefer-dist
  # Install magento 1.9.1.0
  - wget https://raw.githubusercontent.com/netz98/n98-magerun/master/n98-magerun.phar
  - chmod +x n98-magerun.phar
  - ./n98-magerun.phar install --root-dir=. --noDownload --useDefaultConfigParams=yes --dbHost="localhost" --dbUser="root" --dbPass="" --dbName="convenient_magentomodule_tests" --baseUrl="http://example.com/" --installationFolder="${MAGE_INSTALL_PATH}"
  # Prepare 1.9.1.0 Sample Data
  - wget https://raw.githubusercontent.com/Vinai/compressed-magento-sample-data/1.9.1.0/compressed-no-mp3-magento-sample-data-1.9.1.0.tgz
  - tar -zxvf compressed-no-mp3-magento-sample-data-1.9.1.0.tgz
  - rsync -av magento-sample-data-1.9.1.0/ ${MAGE_INSTALL_PATH}
  - mysql -uroot convenient_magentomodule_tests <  ${MAGE_INSTALL_PATH}/magento_sample_data_for_1.9.1.0.sql
  # Install module, for Phpunit we only need the app directory
  - rsync -av app/ ${MAGE_INSTALL_PATH}/app
  - ./n98-magerun.phar --root-dir=${MAGE_INSTALL_PATH} cache:flush
  - ./n98-magerun.phar --root-dir=${MAGE_INSTALL_PATH} sys:setup:run

before_script: mv "$XDEBUG_CONF".bak "$XDEBUG_CONF"

script:
  - vendor/bin/phpunit

cache:
  directories: $HOME/.composer/cache
Flyingmana commented 8 years ago

my fault, there is no version 2.1.2, but good to hear going back to 2.1.1 helped.

And Thank you for all the detailed information. Maybe @AydinHassan or someone else is able to solve this somewhere in the future.

vitalygrigorishin commented 8 years ago

2.1.1 is not working because of composer-plugin-api dependence

convenient commented 8 years ago

Got this distilled even further! The following is all that is required to break it with an infinite loop, or a segfault with 11.

{
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.firegento.com"
        }
    ],
    "require-dev": {
        "magento-hackathon/magento-composer-installer": "2.1.3",
        "magento/core": "1.9.1.0"
    },
    "extra": {
        "magento-deploystrategy": "copy",
        "magento-root-dir": "./"
    }
}
AydinHassan commented 8 years ago

@convenient maybe you should update to a newer version of the installer, 2.1.3 is very old.

convenient commented 8 years ago

Does the 3.x series still do that thing where it tries to chop up the app/Mage.php? I really didn't like that.

https://github.com/Cotya/magento-composer-installer/issues/3

@AydinHassan

AydinHassan commented 8 years ago

@convenient yes but you can disable it with "with-bootstrap-patch": false in composer.json extra.

convenient commented 8 years ago

Thanks @AydinHassan that makes me a lot more comfortable with V3.

Reading the manual I see you've forked off to do some work specifically for installing core magento here: https://github.com/AydinHassan/magento-core-composer-installer

Using that, seems to work 👍

AydinHassan commented 8 years ago

@convenient np, thats a separate project from scratch and yeah it works, we use it on many production sites and has over 30,000 installs 😄

convenient commented 8 years ago

Didn't even realise it wasn't a fork ;) Just needed something that would install core magento so I could spin up travis containers for testing in haha.