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

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 #1735

Open
obriat opened this issue Apr 28, 2024 · 3 comments

Comments

@obriat
Copy link

obriat commented Apr 28, 2024

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 obriat added the bug Something isn't working label Apr 28, 2024
@github-actions github-actions bot changed the title acli app:new:from:drupal7 crashes with "stream_get_contents(): Argument #1 ($stream) must be of type resource, bool given" CLI-1332: acli app:new:from:drupal7 crashes with "stream_get_contents(): Argument #1 ($stream) must be of type resource, bool given" Apr 28, 2024
@wimleers
Copy link
Member

wimleers commented Apr 29, 2024

  1. Your command is using the default recommendations.
  2. The crash is happening at
    $json = stream_get_contents($resource);

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.)

@obriat
Copy link
Author

obriat commented Apr 30, 2024

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.

@wimleers wimleers added enhancement and removed bug Something isn't working labels Apr 30, 2024
@wimleers wimleers changed the title CLI-1332: acli app:new:from:drupal7 crashes with "stream_get_contents(): Argument #1 ($stream) must be of type resource, bool given" 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 Apr 30, 2024
@wimleers
Copy link
Member

although a more details message would be great.

That's fair! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants