cli icon indicating copy to clipboard operation
cli copied to clipboard

CLI-1332: acli app:new:from:drupal7 crashes on cPanel environment with "stream_get_contents(): Argument #1 ($stream) must be of type resource, bool given" on

Open obriat opened this issue 10 months ago • 3 comments

Describe the bug I try to migrate a Drupal 7 site with the Acquia Migrate: Accelerate app:new:from:drupal7... , it crashes with the following error message:

TypeError: stream_get_contents(): Argument #1 ($stream) must be of type resource, bool given in stream_get_contents() (line 22 of phar:///home2/ptgptbfr/bin/acli/vendor/composer/../../src/Command/App/From/JsonResourceParserTrait.php).

To Reproduce Follow the Acquia tutorials : https://dev.acquia.com/blog/acquia-migrate-accelerate-now-open-source#steps

Expected behavior The command should not crash or at least give more info about the problem.

Screenshots

$ acli app:new:from:drupal7 --drupal7-directory=/legacy/www --directory=/new/www -vvv

Box Requirements Checker
========================

> Using PHP 8.1.28
> PHP is using the following php.ini file:
  /opt/cpanel/ea-php81/root/etc/php.ini

> Checking Box requirements:
  ✔ The application requires a version matching "^8.1".
  ✔ The application requires the extension "json".
  ✔ The package "guzzlehttp/guzzle" requires the extension "json".
  ✔ The package "league/csv" requires the extension "json".
  ✔ The package "m4tthumphrey/php-gitlab-api" requires the extension "json".
  ✔ The package "ramsey/uuid" requires the extension "json".
  ✔ The package "zumba/amplitude-php" requires the extension "json".
  ✔ The package "composer/ca-bundle" requires the extension "openssl".
  ✔ The package "composer/ca-bundle" requires the extension "pcre".
  ✔ The package "vlucas/phpdotenv" requires the extension "pcre".
  ✔ The package "league/csv" requires the extension "filter".
  ✔ The package "m4tthumphrey/php-gitlab-api" requires the extension "xml".
  ✔ The package "marc-mabe/php-enum" requires the extension "reflection".
  ✔ The package "zumba/amplitude-php" requires the extension "curl".
  ✔ The package "laminas/laminas-servicemanager" conflicts with the extension "psr".
  ✔ The package "symfony/dependency-injection" conflicts with the extension "psr".
  ✔ The package "symfony/service-contracts" conflicts with the extension "psr".


 [OK] Your system is ready to run the application.


Acquia CLI version: 2.25.0
🤖 Scanning Drupal 7 site.
👍 Found Drupal 7 site (7.98 to be precise) at sites/default, with 77 modules enabled!
TypeError: stream_get_contents(): Argument #1 ($stream) must be of type resource, bool given in stream_get_contents() (line 22 of phar:///home2/ptgptbfr/bin/acli/vendor/composer/../../src/Command/App/From/JsonResourceParserTrait.php).

Desktop (please complete the following information):

  • OS: Red Hat 8.2.1-3 / Linux version 4.18.0-513. (cpanle)
  • PHP 8.1.28
    php -m
    [PHP Modules]
    bcmath
    bz2
    calendar
    Core
    ctype
    curl
    date
    dom
    filter
    ftp
    gd
    gettext
    hash
    iconv
    imap
    intl
    json
    libxml
    mbstring
    mysqli
    mysqlnd
    openssl
    pcntl
    pcre
    PDO
    pdo_mysql
    pdo_sqlite
    Phar
    posix
    readline
    Reflection
    session
    SimpleXML
    soap
    SPL
    sqlite3
    standard
    tokenizer
    xml
    xmlreader
    xmlwriter
    xsl
    zip
    zlib
    
  • Composer version 2.6.5
  • jq 1.7.1

obriat avatar Apr 28 '24 17:04 obriat

  1. Your command is using the default recommendations.
  2. The crash is happening at https://github.com/acquia/cli/blob/6ced4f931affdd8ac418bd03e25842651f99d5ff/src/Command/App/From/JsonResourceParserTrait.php#L22

Conclusion

It must be failing to retrieve to fetch the default recommendations URL.

Questions:

  1. What do you see if you run curl -vvv -O https://git.drupalcode.org/project/acquia_migrate/-/raw/recommendations/recommendations.json ?
  2. What is your php.ini setting for allow_url_fopen? (I suspect this is related, especially considering you're on a CPanel-managed server.)

wimleers avatar Apr 29 '24 14:04 wimleers

Curl seems fine (I get the json content).

Your right, the cpanel php config seems a bit weird, php is not always returning the same config or version depending on the folder where it is executed. The allow_url_fopen is "on" for the source folder (--drupal7-directory) but "off" for the target one ( --directory).

Although I set the correct allow_url_fopen value for both folders in the cpanel admin ui.

I finally found a way to fixe it by setting PHPRC: export PHPRC=/new/www/php.ini

I guess it's a local problem, although a more details message would be great.

obriat avatar Apr 30 '24 01:04 obriat

although a more details message would be great.

That's fair! 😊

wimleers avatar Apr 30 '24 15:04 wimleers