Problem/Motivation

There seem to be some ongoing issues as a result of this release and it would be really helpful to have a stronger sense of why they are happening. So far it's just "seems to happen for some people, but not others."

Drupal 8.6.6/8.5.9/7.62 sites still trying to update to 8.6.7/8.5.10/7.63

If you updated to 7.62, 8.5.9., or 8.6.6 using Drush, received errors, and then ran into difficulty getting the site updated to the hotfix releases (which some users have reported), try using the manual update instructions to get your site onto a version of Drupal that better supports Drush: 8.6.7, 8.5.10, or 7.63

Sites updated to 8.6.7, 8.5.10, or 7.63

If you have upgraded to 8.6.7, 8.5.10, or 7.63 and are still affected by the Fatal error: Uncaught TYPO3\PharStreamWrapper\Exception when running Drush commands, can you do a few things. First:

  1. Ensure the site has been fully updated to the hotfix release by running update.php and then checking the version on the stats report. If you installed the security releases first, you may see the errors when updating to the newer releases, but it might be fixed afterward.
  2. Test Drush again after you've verified the site is on one of 8.6.7, 8.5.10, or 7.63.
  3. If you get errors mentioning cache_get(), double-check that the new libraries at http://cgit.drupalcode.org/drupal/tree/misc/typo3?h=7.x were correctly deployed to your server.

Then, try some of the following:

  1. Try upgrading Drush to the most recent version of Drush 8. Drush 8.1.18 reportedly has a fix that helps resolve the issue.
  2. Try renaming the drush CLI command file back to drush.phar and create a symlink for drush to that file, i.e.:
    mv drush drush.phar ; ln -s drush.phar drush
  3. Attempt your calls using drush.phar instead of drush.
  4. Run drush cc drush outside of a drupal site root after your code is upgraded. Links to drush paths are found in drush cache.
  5. If you can, install Drush with Composer/upgrade Drush to version 9. (This is more involved as some Drush commands have changed and some have been removed, but it's also likely to completely fix the problem).
  6. Try replicating the problem with the same codebase/database in different environments - e.g. does it work locally but fail on your hosting provider? Or vice-versa?
  7. Try replicating the problem with a brand new codebase/database install in the same environment. Does that still cause the problem?
  8. Take note of the directory paths where Drush and Drupal are installed. Are there symlinks? Is Drupal installed in a subdirectory? Etc.

If you can report with details of where you were before/after and what worked/didn't - that will all be enormously helpful.

Proposed resolution

TBD; we need to determine the exact source of the problem.

Remaining tasks

Needs further triage.

User interface changes

N/A

API changes

TBD

Data model changes

N/A

Release notes snippet

TBD

Original report

Porting from https://www.drupal.org/project/drupal/issues/3026386#comment-12929709

Upgraded to drupal 7.63 and still have this issue. Note in the uploaded screeny I tried drush up drupal for kicks but I already had 7.63 in the repository... Doesn't happen on all my sites on this server using the same drush setup... just this one...

Screenshot

the drush command on this server is an alias to a script that calls the drush.phar. Adding a symlink and calling that via the script does nothing for us. example

which drush

alias drush='sudo -u apache /usr/local/bin/scldrush'
    /bin/sudo

scldrush looks like

#!/bin/bash
. /opt/rh/rh-php56/enable
/usr/local/bin/drush "$@"

Where /usr/local/bin/drush is the phar version of drush....

Even following step 3 didn't seem to work here...

What did work was pulling out a composer version of drush... but now I got to get the server admins to get that out there so that cron and the like is using it.

I'm concerned that the way we are looking through the backtrace isn't fool proof. We may want to explore to see if this also allows other phars to slip under the radar is they are good enough to imploy the work around using symlinks?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

generalredneck created an issue. See original summary.

generalredneck’s picture

Issue summary: View changes
bartvig’s picture

Did you do an actual symlink to a file called drush.phar?

When I do the following (when standing in the folder where drush is installed):
mv drush drush.phar ; ln -s drush.phar drush

then it works.

From your code above it doesn't look like your drush command is actually called drush.phar

Hitby’s picture

Not the OP but I did exactly that

mv drush drush.phar ; ln -s drush.phar drush

and it's broken for me still.

exception 'TYPO3\PharStreamWrapper\Exception' with message 'Method stream_select() cannot be used' in /home/user/public_html/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php:146                                                                                                                                                    [error]
Stack trace:
#0 phar:///usr/local/bin/drush.phar/includes/drush.inc(83): TYPO3\PharStreamWrapper\PharStreamWrapper->stream_cast(0)
#1 phar:///usr/local/bin/drush.phar/includes/drush.inc(83): drush_include()
#2 phar:///usr/local/bin/drush.phar/includes/engines.inc(520): drush_include('phar:///usr/loc...', 'cache')
#3 phar:///usr/local/bin/drush.phar/commands/core/cache.drush.inc(233): drush_include_engine('drupal', 'cache')
#4 phar:///usr/local/bin/drush.phar/commands/core/cache.drush.inc(101): drush_cache_clear_types(false)
#5 [internal function]: drush_cache_clear_pre_validate('all')
#6 phar:///usr/local/bin/drush.phar/includes/command.inc(366): call_user_func_array('drush_cache_cle...', Array)
#7 phar:///usr/local/bin/drush.phar/includes/command.inc(217): _drush_invoke_hooks(Array, Array)
#8 [internal function]: drush_command('all')
#9 phar:///usr/local/bin/drush.phar/includes/command.inc(185): call_user_func_array('drush_command', Array)
#10 phar:///usr/local/bin/drush.phar/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#11 phar:///usr/local/bin/drush.phar/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#12 phar:///usr/local/bin/drush.phar/includes/startup.inc(321): drush_main()
#13 phar:///usr/local/bin/drush.phar/drush(114): drush_startup(Array)
#14 /usr/local/bin/drush.phar(10): require('phar:///usr/loc...')
#15 {main}
generalredneck’s picture

Yeah we did... just didnt take a screenshot of it.

cilefen’s picture

Title: After upgrade to 7.63 still get TYPO3 pharma error for drush » After upgrade to 7.63 still get TYPO3 phar error for drush
generalredneck’s picture

Totally ripping off @greggles

Hi folks!

There seem to be some ongoing issues as a result of this release and it would be really helpful to have a stronger sense of why they are happening. So far it's just "seem to happen for some people, but not others."

If you have upgraded and are still affected by the Fatal error: Uncaught TYPO3\PharStreamWrapper\Exception, can you do a few things:

* try upgrading drush to the most recent version of version 8
* if you can, upgrade drush to version 9 (this is more involved as commands have changed and some have been removed, but it's also likely to completely fix the problem)
* try replicating the problem with the same codebase/database in different environments - e.g. does it work locally but fail on your hosting provider. Or vice-versa?
* try replicating the problem with a brand new codebase/database install in the same environment. Does that still cause the problem?

If you can report with details of where you were before/after and what worked/didn't - that will all be enormously helpful.

Thanks to everyone for providing descriptions and details of problems so far!

👆 Will see what I can do but adding for others.

DamienMcKenna’s picture

Hitby’s picture

I have drush installed via composer on my local machine, that updated a duplicate of a site on the test server fine with no errors. The drush on the server is in /usr/local/bin/drush and is version 8.0.3 - I don't have permission to update it but I've put in a request to have it removed and replaced with a global composer version.

I've no idea how long that will take though.

hth

Dan

xjm’s picture

Issue summary: View changes

Updating the IS with @greggles' instructions plus some other debugging questions.

xjm’s picture

Issue summary: View changes
Alex Monaghan’s picture

Some background, hope this helps

Updated from 7.6.1
I have 2 servers, both cPanel on CentOS running Apache with PHP 5.6 & 7.2, seems to be 5.6 on command line.
Server 1 ran OK
Server 2 gave drush error on both a Drupal 6.49 LTS update and a 7.6.3 update
simply used "drush rf" followed by "drush up" as I've done for years

Was an older drush on server2 so updated to 8.1.18, but no change. Server 1 was 8.1.16

Have linked /usr/local/bin/drush to drush.phar as suggested but no change.

alexpott’s picture

I've filed an upstream PR that should fix this... https://github.com/TYPO3/phar-stream-wrapper/pull/8

alexpott’s picture

If someone could test it somehow and let me know because I don't know how to recreate the bug but the current phar security stream wrapper implementation just doesn't support stream_select() when as far as I know there's no reason it can't.

xjm’s picture

It'd probably be helpful for folks' testing to provide a patch they can test against the codebase (especially for D7).

alexpott’s picture

Status: Active » Needs review
FileSize
706 bytes

Good idea. Here's a D7 patch.

Hitby’s picture

I've used the patch in #16 and it installed cleanly. All drush commands now just give the message

Segmentation fault

Thanks,

Alex Monaghan’s picture

Patch gives "Bus error"
PHP 5.6.39

kevinquillen’s picture

Patch had no effect for me.

My error stems from this exception thrown here:


  public function assert($path, $command) {
    if ($this->baseFileContainsPharExtension($path)) {
      return TRUE;
    }
    throw new Exception(
      sprintf(
        'Unexpected file extension in "%s"',
        $path
      ),
      1535198703
    );
  }

The drush on this server was installed in an older way, wget the drush phar file, mv drush.phar to drush....

If I dump the path here in this method, this is the output:

/app/docroot/misc/typo3/drupal-security/PharExtensionInterceptor.php:38:
string(48) "phar:///usr/local/bin/drush/commands/core/drupal"

PHP info:

php --version
PHP 7.1.26 (cli) (built: Jan 11 2019 03:14:11) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.26, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans

Running on a Lando stack.

alexpott’s picture

Sorry - trying things in the dark here as I can't reproduce the error locally. Been looking at other stream wrapper implementations #16 was based on one in core. Here's an idea from looking at other ones on packagist.

Hitby’s picture

Reversed patch from #16 and ran

patch < 3026560-d7-20.patch

patching file PharStreamWrapper.php

drush cc all gave me

WD php: TYPO3\PharStreamWrapper\Exception: Unexpected file extension in "phar:///usr/local/bin/drush/includes/../commands//core/locale.d8.drush.inc" in Drupal\Core\Security\PharExtensionInterceptor->assert() (line 38 of   [error]
/home/user/public_html/misc/typo3/drupal-security/PharExtensionInterceptor.php).
TYPO3\PharStreamWrapper\Exception: Unexpected file extension in "phar:///usr/local/bin/drush/includes/../commands//core/locale.d8.drush.inc" in Drupal\Core\Security\PharExtensionInterceptor->assert() (line 38 of /home/user/public_html/misc/typo3/drupal-security/PharExtensionInterceptor.php).
Drush command terminated abnormally due to an unrecoverable error.

Appreciate your help with this Alex

kevinquillen’s picture

Same error as #21.

doostinharrell’s picture

Upgrading to the latest version of Drush 8 for a clients Drupal 7 website resolved the issue for me.

xjm’s picture

Issue summary: View changes

Cleaning up the IS a bit.

xjm’s picture

Issue summary: View changes
generalredneck’s picture

Ok I'm going out on a limb here and want to ask (and this may be another issue), but we are not allowing ANY phars to run in the drupal codebase?

Just had a client using pmp-php-sdk with a version of guzzle as a phar and they are receiving

Warning: Uncaught TYPO3\PharStreamWrapper\Exception: Unexpected file extension in "phar://guzzle.phar/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php" in /app/web/misc/typo3/drupal-security/PharExtensionInterceptor.php:38 Stack trace: 
#0 /app/web/misc/typo3/phar-stream-wrapper/src/Behavior.php(72): Drupal\Core\Security\PharExtensionInterceptor->assert('phar://guzzle.p...', 'stream_open') 
#1 /app/web/misc/typo3/phar-stream-wrapper/src/Manager.php(83): TYPO3\PharStreamWrapper\Behavior->assert('phar://guzzle.p...', 'stream_open') 
#2 /app/web/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php(412): TYPO3\PharStreamWrapper\Manager->assert('phar://guzzle.p...', 'stream_open') 
#3 /app/web/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php(247): TYPO3\PharStreamWrapper\PharStreamWrapper->assert('phar://guzzle.p...', 'stream_open') 
#4 /app/web/sites/all/modules/custom/pmpapi/phpsdk/lib/guzzle.phar(5): TYPO3\PharStreamWrapper\PharStreamWrapper->stream_open('phar://guzzle.p...', 'rb in /app/web/misc/typo3/drupal-security/PharExtensionInterceptor.php on line 38 Call Stack: 0.0000 379480 1. {main}() /app/web/index.php:0 0.0205 6451960 2. menu_execute_active_handler() /app/web/index.php:21 0.0209 6453584 3. drupal_get_form() /app/web/includes/menu.inc:527 0.0209 6454760 4. drupal_build_form() /app/web/includes/form.inc:131 0.0209 6455080 5. drupal_retrieve_form() /app/web/includes/form.inc:351 0.0210 6455856 6. pmpapi_config_form() /app/web/includes/form.inc:844 0.0210 6455856 7. pmpapi_ping() /app/web/sites/all/modules/custom/pmpapi/pmpapi.admin.inc:18 0.0214 6531256 8. PMPAPIDrupal->pull() /app/web/sites/all/modules/custom/pmpapi/pmpapi.module:129 0.0214 6531256 9. PMPAPIDrupal->sdkInclude() /app/web/sites/all/modules/custom/pmpapi/classes/PMPAPIDrupal.php:128 0.0214 6531320 10. module_load_include() /app/web/sites/all/modules/custom/pmpapi/classes/PMPAPIDrupal.php:358 0.0214 6533408 11. require_once('/app/web/sites/all/modules/custom/pmpapi/phpsdk/lib/Pmp/Sdk/CollectionDocJson.php') /app/web/includes/module.inc:341 0.0214 6534296 12. require_once('/app/web/sites/all/modules/custom/pmpapi/phpsdk/lib/Pmp/Sdk/CollectionDocJsonLinks.php') /app/web/sites/all/modules/custom/pmpapi/phpsdk/lib/Pmp/Sdk/CollectionDocJson.php:5 0.0214 6535200 13. require_once('/app/web/sites/all/modules/custom/pmpapi/phpsdk/lib/Pmp/Sdk/CollectionDocJsonLink.php') /app/web/sites/all/modules/custom/pmpapi/phpsdk/lib/Pmp/Sdk/CollectionDocJsonLinks.php:5 0.0214 6535640 14. require_once('/app/web/sites/all/modules/custom/pmpapi/phpsdk/lib/guzzle.phar') /app/web/sites/all/modules/custom/pmpapi/phpsdk/lib/Pmp/Sdk/CollectionDocJsonLink.php:7 Fatal error: main(): Failed opening required 'phar://guzzle.phar/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php' (include_path='.:/usr/local/lib/php') in /app/web/sites/all/modules/custom/pmpapi/phpsdk/lib/guzzle.phar on line 5 Call Stack: 0.0000 379480 1. {main}() /app/web/index.php:0 0.0205 6451960 2. menu_execute_active_handler() /app/web/index.php:21 0.0209 6453584 3. drupal_get_form() /app/web/includes/menu.inc:527 0.0209 6454760 4. drupal_build_form() /app/web/includes/form.inc:131 0.0209 6455080 5. drupal_retrieve_form() /app/web/includes/form.inc:351 0.0210 6455856 6. pmpapi_config_form() /app/web/includes/form.inc:844 0.0210 6455856 7. pmpapi_ping() /app/web/sites/all/modules/custom/pmpapi/pmpapi.admin.inc:18 0.0214 6531256 8. PMPAPIDrupal->pull() /app/web/sites/all/modules/custom/pmpapi/pmpapi.module:129 0.0214 6531256 9. PMPAPIDrupal->sdkInclude() /app/web/sites/all/modules/custom/pmpapi/classes/PMPAPIDrupal.php:128 0.0214 6531320 10. module_load_include() /app/web/sites/all/modules/custom/pmpapi/classes/PMPAPIDrupal.php:358 0.0214 6533408 11. require_once('/app/web/sites/all/modules/custom/pmpapi/phpsdk/lib/Pmp/Sdk/CollectionDocJson.php') /app/web/includes/module.inc:341 0.0214 6534296 12. require_once('/app/web/sites/all/modules/custom/pmpapi/phpsdk/lib/Pmp/Sdk/CollectionDocJsonLinks.php') /app/web/sites/all/modules/custom/pmpapi/phpsdk/lib/Pmp/Sdk/CollectionDocJson.php:5 0.0214 6535200 13. require_once('/app/web/sites/all/modules/custom/pmpapi/phpsdk/lib/Pmp/Sdk/CollectionDocJsonLink.php') /app/web/sites/all/modules/custom/pmpapi/phpsdk/lib/Pmp/Sdk/CollectionDocJsonLinks.php:5 0.0214 6535640 14. require_once('/app/web/sites/all/modules/custom/pmpapi/phpsdk/lib/guzzle.phar') /app/web/sites/all/modules/custom/pmpapi/phpsdk/lib/Pmp/Sdk/CollectionDocJsonLink.php:7

Thoughts? This is after upgrading to 7.63 versus 7.62

alexpott’s picture

As far as I can see the only time stream_select() is used in drush 8 is when invoking some thing on a remote server. Here's a list of things that would be handy to know in order to reproduce the problem.

Full drush command being run:
Local Drupal version:
Local Drush version:
Local PHP version:
(if a remote is being used)
Remote Drupal version:
Remote Drush version:
Remote PHP version:
Anything special in your drush configuration:

For me I've tried the following but it work successfully.
Full drush command being run: ./drush8 @example.drops-7-on-72.dev cc all
Local Drupal version: 7.64-dev
Local Drush version: 8.0.2
Local PHP version: 7.0.33
(if a remote is being used)
Remote Drupal version: 7.61
Remote Drush version: 8.1.18
Remote PHP version: 7.2.14
Anything special in your drush configuration: ./drush8 is a renamed drush phar file.

kevinquillen’s picture

For now I had to:

public function assert($path, $command) {
  return TRUE;
}

in docroot/misc/typo3/drupal-security/PharExtensionInterceptor.php. Then I was able to use drush (have a client project and needed to update core and about 55 contrib modules). Other than that, nothing I have done was working for Drush (even upgraded to latest 8.x stable release as someone else mentioned working).

After getting everything updated I reverted PharExtensionInterceptor.php back.

alexpott’s picture

@generalredneck we are but from the look of that stacktrace the guzzle phar is using aliases or box - that issue is being tracked in #3026443: \Drupal\Core\Security\PharExtensionInterceptor is incompatible with GeoIP and other libraries that use phar aliases or Phar::mapPhar()

generalredneck’s picture

@alexpott, Thanks tons, I'll send that their way... I'm getting some time to work with yall on this now that all the fires have calmed down... I'll give some hopefully useful info soon on reproduction.

Hitby’s picture

Kevin, That fixes drush for me to but presumably removes the phar protection.

For what it's worth my versions are

Remote Drupal version: 7.63
Remote Drush version: 8.0.3
Remote PHP version: 5.6.39

kevinquillen’s picture

Did a little debugging after the fact.

    $fileExtension = pathinfo($baseFile, PATHINFO_EXTENSION);
    return strtolower($fileExtension) === 'phar';

Dumping $fileExtension here on a drush call produces an empty string. $baseFile is /usr/local/bin/drush and $path is phar:///usr/local/bin/drush/commands/core/drupal

alexpott’s picture

@kevinquillen thanks for the info. I thought that 7.63 would have fixed this. Can you confirm you have applied http://cgit.drupalcode.org/drupal/commit/?h=7.x&id=7f1f3b8be02f6f3af5934... - also if you can it would great to know the value of $caller['file'] - just before it does return strtolower($fileExtension) === 'phar';

kevinquillen’s picture

$caller['file'] produces docroot/includes/bootstrap.inc. I do have the linked patch, just as a straight upgrade from 7.60 to 7.63 via drush up drupal.

#31 yep, I did this to unblock me to get the work through the pipeline. I reverted the file back.

kevinquillen’s picture

Output of the last `updb` command:

No database updates required           [success]



PHP Fatal error:  Uncaught TYPO3\PharStreamWrapper\Exception: Unexpected file extension in "phar:///usr/local/bin/drush/commands/core/drupal" in /app/docroot/misc/typo3/drupal-security/PharExtensionInterceptor.php:38
Stack trace:
#0 /app/docroot/misc/typo3/phar-stream-wrapper/src/Behavior.php(72): Drupal\Core\Security\PharExtensionInterceptor->assert('phar:///usr/loc...', 'url_stat')
#1 /app/docroot/misc/typo3/phar-stream-wrapper/src/Manager.php(83): TYPO3\PharStreamWrapper\Behavior->assert('phar:///usr/loc...', 'url_stat')
#2 /app/docroot/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php(412): TYPO3\PharStreamWrapper\Manager->assert('phar:///usr/loc...', 'url_stat')
#3 /app/docroot/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php(401): TYPO3\PharStreamWrapper\PharStreamWrapper->assert('phar:///usr/loc...', 'url_stat')
#4 [internal function]: TYPO3\PharStreamWrapper\PharStreamWrapper->url_stat('phar:///usr/loc...', 2)
#5 phar:///usr/local/bin/drush/includes/engines.inc(87): file_exists('phar:///usr/loc...')
#6 p in /app/docroot/misc/typo3/drupal-security/PharExtensionInterceptor.php on line 38
PHP Stack trace:
PHP   1. {main}() /usr/local/bin/drush:0
PHP   2. require() /usr/local/bin/drush:10
PHP   3. drush_startup() phar:///usr/local/bin/drush/drush:114
PHP   4. drush_run_main() phar:///usr/local/bin/drush/includes/startup.inc:369

Fatal error: Uncaught TYPO3\PharStreamWrapper\Exception: Unexpected file extension in "phar:///usr/local/bin/drush/commands/core/drupal" in /app/docroot/misc/typo3/drupal-security/PharExtensionInterceptor.php on line 38

Call Stack:
    0.0016     352944   1. {main}() /usr/local/bin/drush:0
    0.0130     776776   2. require('phar:///usr/local/bin/drush/drush') /usr/local/bin/drush:10
    0.0134     827832   3. drush_startup() phar:///usr/local/bin/drush/drush:114
    0.0156     828480   4. drush_run_main() phar:///usr/local/bin/drush/includes/startup.inc:369

TYPO3\PharStreamWrapper\Exception: Unexpected file extension in "phar:///usr/local/bin/drush/commands/core/drupal" in /app/docroot/misc/typo3/drupal-security/PharExtensionInterceptor.php on line 38

Call Stack:
    0.0016     352944   1. {main}() /usr/local/bin/drush:0
    0.0130     776776   2. require('phar:///usr/local/bin/drush/drush') /usr/local/bin/drush:10
    0.0134     827832   3. drush_startup() phar:///usr/local/bin/drush/drush:114
    0.0156     828480   4. drush_run_main() phar:///usr/local/bin/drush/includes/startup.inc:369
   11.2499   81170440   5. watchdog() /app/docroot/includes/bootstrap.inc:0
   11.2510   81171640   6. module_invoke() /app/docroot/includes/bootstrap.inc:2025
   11.2510   81172016   7. system_watchdog() /app/docroot/includes/module.inc:934
   11.2510   81172016   8. drush_include_engine() phar:///usr/local/bin/drush/includes/drupal.inc:85
   11.2510   81172016   9. drush_get_engines() phar:///usr/local/bin/drush/includes/engines.inc:511
   11.2526   81176144  10. file_exists() phar:///usr/local/bin/drush/includes/engines.inc:87
   11.2526   81176344  11. TYPO3\PharStreamWrapper\PharStreamWrapper->url_stat() phar:///usr/local/bin/drush/includes/engines.inc:87
   11.2526   81176344  12. TYPO3\PharStreamWrapper\PharStreamWrapper->assert() /app/docroot/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php:401
   11.2526   81176344  13. TYPO3\PharStreamWrapper\Manager->assert() /app/docroot/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php:412
   11.2526   81176344  14. TYPO3\PharStreamWrapper\Behavior->assert() /app/docroot/misc/typo3/phar-stream-wrapper/src/Manager.php:83
   11.2527   81176344  15. Drupal\Core\Security\PharExtensionInterceptor->assert() /app/docroot/misc/typo3/phar-stream-wrapper/src/Behavior.php:72
littlepixiez’s picture

Not sure if this is helpful, but on my shared hosting, if I switch PHP version down and run "drush cc all" I get:

exception 'TYPO3\PharStreamWrapper\Exception' with message 'Method stream_select() cannot be used' in                                  [error]
/home/playingw/public_html/drupal/htdocs/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php:146
Stack trace:
#0 phar:///usr/local/bin/drush/includes/drush.inc(83): TYPO3\PharStreamWrapper\PharStreamWrapper->stream_cast(0)
#1 phar:///usr/local/bin/drush/includes/drush.inc(83): drush_include()
#2 phar:///usr/local/bin/drush/includes/engines.inc(520): drush_include('phar:///usr/loc...', 'cache')
#3 phar:///usr/local/bin/drush/commands/core/cache.drush.inc(233): drush_include_engine('drupal', 'cache')
#4 phar:///usr/local/bin/drush/commands/core/cache.drush.inc(101): drush_cache_clear_types(false)
#5 [internal function]: drush_cache_clear_pre_validate('all')
#6 phar:///usr/local/bin/drush/includes/command.inc(373): call_user_func_array('drush_cache_cle...', Array)
#7 phar:///usr/local/bin/drush/includes/command.inc(224): _drush_invoke_hooks(Array, Array)
#8 [internal function]: drush_command('all')
#9 phar:///usr/local/bin/drush/includes/command.inc(192): call_user_func_array('drush_command', Array)
#10 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#11 phar:///usr/local/bin/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#12 phar:///usr/local/bin/drush/includes/startup.inc(325): drush_main()
#13 phar:///usr/local/bin/drush/drush(114): drush_startup(Array)
#14 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#15 {main}

Locally it's all fine using Docksal:
Drupal version: 7.63
Drush version: 8.1.16
PHP version: 7.1.18

Errors in this environment:
Remote Drupal version: 7.63
Remote Drush version: 8.1.3
Remote PHP version: PHP 5.6.39

But if I switch the PHP version to 7.0.33 or above on shared hosting it resolves the issue. Cannot reproduce locally.

Update: Just to confirm the same happens for a blank install.

pbirk’s picture

FileSize
12.91 KB

Not sure if this is helpful. I'm able to work around this issue on my environment, but I was able to reproduce the error yesterday.

I started with a fresh Drupal installation on my dev environment:
Drupal 7.63
drush 8.1.7 (global install at /usr/local/bin)
PHP 7.0.32-0ubuntu0.16.04.1

I used a drush symbolic link to drush.phar like others have described:

lrwxrwxrwx  1 root root      10 Jan 17 15:53 drush -> drush.phar
-rwxr-xr-x  1 root root 4690805 Nov 21 17:24 drush.phar

I ran drush cc all to generate the error. Then I used the patch from #20, ran drush cc all again with the same results.

Next, I upgraded to drush 8.1.18 and installed it in the same manner. I ran drush cc all without error. I reverted the patch, ran drush cc all again without error.

Now it gets weird. I reverted back to drush 8.1.7 and attempted drush cc all again. No error.

I attached a log of the relevant shell output.

pbirk’s picture

I took a closer look and realized I accidentally converted the symbolic link to a file with my copy command to restore drush 8.1.7. I removed /usr/local/bin/drush then recreated the link with ln -s drush.phar drush and now reproduce the error as expected.

generalredneck’s picture

This may be helpful in my instance...
Looks like however the drush script was created was using https://github.com/box-project/box2-lib which is why the work around here wouldn't work.
screemshot

alexpott’s picture

generalredneck’s picture

Adding a bit of information...
so /usr/local/bin/drush IS a symlink to /usr/local/bin/drush.phar above... It just so happens that it's not the same far that's distributed over at github...
See below

[jenkins@dagapp1dr]$ ls -al /usr/local/bin/drush*
lrwxrwxrwx 1 root root      25 Jan 17 17:48 /usr/local/bin/drush -> /usr/local/bin/drush.phar
-rwxr-xr-x 1 root root 6135132 Jan 16 20:10 /usr/local/bin/drush.phar

and to get some idea of the variables in memory when this fails for me currently it's just what's below in the assert function on line 38 in misc/typo3/drupal-security/PharExtensionInterceptor.php

array(2) {
  ["path"]=>
  string(61) "phar:///usr/local/bin/drush/commands/core/locale.d8.drush.inc"
  ["command"]=>
  string(8) "url_stat"
}
alexpott’s picture

@generalredneck I think it is the same phar - drush 8 was built using box too - its a common tool for building phars. But something in that setup means it doesn't work. Have you tried running /usr/local/bin/drush.phar directly instead?

generalredneck’s picture

@alexpott,
Interesting... so here are my findings... First I want to preface this with we have to run compiled version of PHP 5.6 because this version of RH has 5.4 as default... so here's what I did based on the information I sent you before

[jenkins@dagapp1dr]$ /opt/rh/rh-php56/root/bin/php /usr/local/bin/drush.phar status
PHP Warning:  Module 'uploadprogress' already loaded in Unknown on line 0
 Drupal version                  :  7.63                                                                 
 Site URI                        :  http://default                                                       
 Database driver                 :  mysql                                                                
 Database hostname               :  dagdb1dr                                              
 Database username               :  user                                                             
 Database name                   :  db                                                      
 Database                        :  Connected                                                            
 Drupal bootstrap                :  Successful                                                           
 Drupal user                     :                                                                       
 Default theme                   :  wdm                                                                  
 Administration theme            :  adminimal                                                            
 PHP configuration               :  /etc/opt/rh/rh-php56/php.ini                                         
 PHP OS                          :  Linux                                                                
 Drush script                    :  /usr/local/bin/drush.phar                                            
 Drush version                   :  8.1.9                                                                
 Drush temp directory            :  /tmp                                                                 
 Drush configuration             :  /var/www/html/sites/all/drush/drushrc.php       
 Drush alias files               :  /var/www/html/sites/all/drush/ag-distro.aliases 
                                    .drushrc.php                                                         
                                    /var/www/html/sites/all/drush/wdm.aliases.drush 
                                    rc.php                                                               
 Install profile                 :  meredith_ag                                                          
 Drupal root                     :  /var/www/html                               
 Drupal Settings File            :  sites/default/settings.php                                           
 Site path                       :  sites/default                                                        
 File directory path             :  sites/default/files                                                  
 Private file directory path     :  sites/default/files/private                                          
 Temporary file directory path   :  /tmp                                                                 

[jenkins@dagapp1dr ]$ /opt/rh/rh-php56/root/bin/php /usr/local/bin/drush.phar cc all
PHP Warning:  Module 'uploadprogress' already loaded in Unknown on line 0
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
'all' cache was cleared.                                                                      [success]
WD memcache: Spent 23.31 ms splitting 1.29 MB object into 2 pieces, cid =                     [warning]
cache_views-views_data%3Aen

Ok so far so good... I rename the thing to "drush" so that I can use it via the alias that the server admins use so that file permissions happen correctly... keep in mind that the file I'm moving is the phar.

[jenkins@dagapp1dr ]$ which drush
alias drush='sudo -u apache /usr/local/bin/scldrush'
	/bin/sudo
[jenkins@dagapp1dr ]$ cat /usr/local/bin/scldrush 
#!/bin/bash
. /opt/rh/rh-php56/enable
/usr/local/bin/drush "$@"

[jenkins@dagapp1dr ]$ sudo rm -rf /usr/local/bin/drush
[jenkins@dagapp1dr ]$ sudo mf /usr/local/bin/drush.phar /usr/local/bin/drush
sudo: mf: command not found
[jenkins@dagapp1dr ]$ sudo mv /usr/local/bin/drush.phar /usr/local/bin/drush
[jenkins@dagapp1dr ]$ drush status
PHP Warning:  Module 'uploadprogress' already loaded in Unknown on line 0
 Drupal version                  :  7.63                                                                 
 Site URI                        :  http://default                                                       
 Database driver                 :  mysql                                                                
 Database hostname               :  dagdb1dr                                            
 Database username               :  user                                                             
 Database name                   : db                                                      
 Database                        :  Connected                                                            
 Drupal bootstrap                :  Successful                                                           
 Drupal user                     :                                                                       
 Default theme                   :  wdm                                                                  
 Administration theme            :  adminimal                                                            
 PHP configuration               :  /etc/opt/rh/rh-php56/php.ini                                         
 PHP OS                          :  Linux                                                                
 Drush script                    :  /usr/local/bin/drush                                                 
 Drush version                   :  8.1.9                                                                
 Drush temp directory            :  /tmp                                                                 
 Drush configuration             :  /var/www/html/sites/all/drush/drushrc.php       
 Drush alias files               :  /var/www/html/sites/all/drush/ag-distro.aliases 
                                    .drushrc.php                                                         
                                    /var/www/htm/sites/all/drush/wdm.aliases.drush 
                                    rc.php                                                               
 Install profile                 :  meredith_ag                                                          
 Drupal root                     :  /var/www/html                                
 Drupal Settings File            :  sites/default/settings.php                                           
 Site path                       :  sites/default                                                        
 File directory path             :  sites/default/files                                                  
 Private file directory path     :  sites/default/files/private                                          
 Temporary file directory path   :  /tmp                                              

Ok so far so good... I got drush status going again... but then I'm stuck back with this only happening in drush cc all. Note I have a var_dump(get_defined_vars()); @ line 38 in misc/typo3/drupal-security/PharExtensionInterceptor.php

[jenkins@dagapp1dr www.woodmagazine.com]$ drush cc all
PHP Warning:  Module 'uploadprogress' already loaded in Unknown on line 0
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
Illegal string offset 'mapping_type' PictureMapping.php:183                                   [warning]
'all' cache was cleared.                                                                      [success]
array(2) {
  ["path"]=>
  string(48) "phar:///usr/local/bin/drush/commands/core/drupal"
  ["command"]=>
  string(8) "url_stat"
}
PHP Fatal error:  Uncaught exception 'TYPO3\PharStreamWrapper\Exception' with message 'Unexpected file extension in "phar:///usr/local/bin/drush/commands/core/drupal"' in /var/www/html/misc/typo3/drupal-security/PharExtensionInterceptor.php:39
Stack trace:
#0 /var/www/html/misc/typo3/phar-stream-wrapper/src/Behavior.php(72): Drupal\Core\Security\PharExtensionInterceptor->assert('phar:///usr/loc...', 'url_stat')
#1 /var/www/htm/misc/typo3/phar-stream-wrapper/src/Manager.php(83): TYPO3\PharStreamWrapper\Behavior->assert('phar:///usr/loc...', 'url_stat')
#2 /var/www/html/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php(412): TYPO3\PharStreamWrapper\Manager->assert('phar:///usr/loc...', 'url_stat')
#3 /var/www/html/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php(401): TYPO3\PharStreamWrapper\PharStreamWrapper->assert('phar:///usr/loc...', 'url_stat')
#4 [internal function]: TYPO3\PharStreamWrapper\PharStreamWr in /var/www/htm/misc/typo3/drupal-security/PharExtensionInterceptor.php on line 39
[jenkins@dagapp1dr ]$ /opt/rh/rh-php56/root/bin/php /usr/local/bin/drush.phar cc all
PHP Warning:  Module 'uploadprogress' already loaded in Unknown on line 0
Could not open input file: /usr/local/bin/drush.phar
[jenkins@dagapp1dr ]$ /opt/rh/rh-php56/root/bin/php /usr/local/bin/drush cc all
PHP Warning:  Module 'uploadprogress' already loaded in Unknown on line 0
array(2) {
  ["path"]=>
  string(66) "phar:///usr/local/bin/drush.phar/commands/core/locale.d8.drush.inc"
  ["command"]=>
  string(8) "url_stat"
}
array(2) {
  ["path"]=>
  string(48) "phar:///usr/local/bin/drush/commands/core/drupal"
  ["command"]=>
  string(8) "url_stat"
}
Drush command terminated abnormally due to an unrecoverable error.                            [error]

It sounds like to me if we change the alias to call drush.phar and rename drush to drush.phar we will be in business... I just don't understand "why"

alexpott’s picture

@generalredneck Well the logic of the PharInterceptor is such that if a file ends in .phar it thinks it is safe - it that works for you then great!

generalredneck’s picture

Nope... No bueno

[jenkins@dagapp1dr ]$ which drush
alias drush='sudo -u apache /usr/local/bin/scldrush'
	/bin/sudo
[jenkins@dagapp1dr ]$ cat /usr/local/bin/scldrush
#!/bin/bash
. /opt/rh/rh-php56/enable
/usr/local/bin/drush.phar "$@"
[jenkins@dagapp1dr ]$ ls -al /usr/local/bin/drush*
-rwxr-xr-x 1 root root 6135132 Jan 16 20:10 /usr/local/bin/drush.phar
[jenkins@dagapp1dr ]$ drush cc all
PHP Warning:  Module 'uploadprogress' already loaded in Unknown on line 0
array(2) {
  ["path"]=>
  string(61) "phar:///usr/local/bin/drush/commands/core/locale.d8.drush.inc"
  ["command"]=>
  string(8) "url_stat"
}
WD php: TYPO3\PharStreamWrapper\Exception: Unexpected file extension in                                                     [error]
"phar:///usr/local/bin/drush/commands/core/locale.d8.drush.inc" in Drupal\Core\Security\PharExtensionInterceptor->assert()
(line 39 of /var/www/html/misc/typo3/drupal-security/PharExtensionInterceptor.php).
Cannot modify header information - headers already sent by (output started at                                               [warning]
/var/www/html/misc/typo3/drupal-security/PharExtensionInterceptor.php:38) bootstrap.inc:1515
TYPO3\PharStreamWrapper\Exception: Unexpected file extension in "phar:///usr/local/bin/drush/commands/core/locale.d8.drush.inc" in Drupal\Core\Security\PharExtensionInterceptor->assert() (line 39 of /var/www/html/misc/typo3/drupal-security/PharExtensionInterceptor.php).
Drush command terminated abnormally due to an unrecoverable error.

What I don't understand is where it's getting /usr/local/bin/drush as a path, as /usr/local/bin/drush doesn't exist.

generalredneck’s picture

Ok... so... making the changes above actually DID work... I had to switch out of the site directory... run drush cc drush and THEN come back in and do a drush cc all. I suspect a drush @none cc drush probably would have worked too.

b.khouy’s picture

This issue has been produced on remote server for me with the following infos:

  • Drupal version: 7
  • Drush version: 8.1.3
  • Php version: 5.6.39

The problem was fixed by downgrading Drush to 7.1.0

Update:
No patch has been applied

Hitby’s picture

Having updated drush to 8.1.18 I now get the following error on sites I've updated to 7.63 for all commands

Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                                                                                                                                                                       [error]
Error: Call to undefined function cache_get() in /home/user/public_html/includes/module.inc, line 762

debug_backtrace below

drush cc all
#0  module_implements(system_theme_info) called at [/home/adoptingindoncas/public_html/includes/module.inc:967]
#1  module_invoke_all(system_theme_info) called at [/home/adoptingindoncas/public_html/modules/system/system.module:2511]
#2  _system_rebuild_theme_data() called at [/home/adoptingindoncas/public_html/includes/theme.inc:798]
#3  list_themes() called at [/home/adoptingindoncas/public_html/includes/theme.maintenance.inc:57]
#4  _drupal_maintenance_theme() called at [/home/adoptingindoncas/public_html/includes/bootstrap.inc:2894]
#5  drupal_maintenance_theme() called at [/home/adoptingindoncas/public_html/includes/errors.inc:179]
#6  _drupal_log_error(Array ([%type] => TYPO3\PharStreamWrapper\Exception,[!message] => Method stream_select() cannot be used,[%function] => TYPO3\PharStreamWrapper\PharStreamWrapper->stream_cast(),[%file] => /home/adoptingindoncas/public_html/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php,[%line] => 146,[severity_level] => 3), 1) called at [/home/adoptingindoncas/public_html/includes/bootstrap.inc:2622]
#7  _drupal_exception_handler(TYPO3\PharStreamWrapper\Exception Object ([] => Method stream_select() cannot be used,[] => ,[] => 1530103999,[] => /home/adoptingindoncas/public_html/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php,[] => 146,[] => Array ([0] => Array ([file] => phar:///usr/local/bin/drush/vendor/composer/ClassLoader.php,[line] => 444,[function] => stream_cast,[class] => TYPO3\PharStreamWrapper\PharStreamWrapper,[type] => ->,[args] => Array ([0] => 0)),[1] => Array ([file] => phar:///usr/local/bin/drush/vendor/composer/ClassLoader.php,[line] => 444,[function] => Composer\Autoload\includeFile),[2] => Array ([file] => phar:///usr/local/bin/drush/vendor/composer/ClassLoader.php,[line] => 322,[function] => Composer\Autoload\includeFile,[args] => Array ([0] => phar:///usr/local/bin/drush/vendor/composer/../../lib/Drush/Command/DrushInputAdapter.php)),[3] => Array ([function] => loadClass,[class] => Composer\Autoload\ClassLoader,[type] => ->,[args] => Array ([0] => Drush\Command\DrushInputAdapter)),[4] => Array ([file] => phar:///usr/local/bin/drush/includes/command.inc,[line] => 353,[function] => spl_autoload_call,[args] => Array ([0] => Drush\Command\DrushInputAdapter)),[5] => Array ([file] => phar:///usr/local/bin/drush/includes/command.inc,[line] => 231,[function] => _drush_invoke_hooks,[args] => Array ([0] => Array ([bootstrap] => -2,[description] => Clear a specific cache, or all drupal caches.,[arguments] => Array ([0] => all),[callback] => drush_command,[aliases] => Array ([0] => cc),[command] => cache-clear,[command-hook] => cache-clear,[invoke hooks] => 1,[callback arguments] => Array (),[commandfile] => cache,[path] => phar:///usr/local/bin/drush/commands/core,[engines] => Array (),[primary function] => drush_cache_command_clear,[sections] => Array ([examples] => Examples,[arguments] => Arguments,[options] => Options),[required-arguments] => ,[options] => Array (),[sub-options] => Array (),[allow-additional-options] => ,[global-options] => Array (),[examples] => Array (),[core] => Array (),[scope] => site,[drush dependencies] => Array (),[handle-remote-commands] => ,[remote-tty] => ,[strict-option-handling] => ,[tilde-expansion] => 1,[bootstrap_errors] => Array (),[topics] => Array (),[hidden] => ,[category] => cache,[add-options-to-arguments] => ,[consolidation-output-formatters] => ,[annotated-command-callback] => ,[annotations] => Consolidation\AnnotatedCommand\AnnotationData Object ([command] => cache-clear),[drupal dependencies] => Array (),[is_alias] => 1,[argument-description] => Array ([type] => The particular cache to clear. Omit this argument to choose from available caches.)),[1] => Array ([0] => all))),[6] => Array ([function] => drush_command,[args] => Array ([0] => all)),[7] => Array ([file] => phar:///usr/local/bin/drush/includes/command.inc,[line] => 199,[function] => call_user_func_array,[args] => Array ([0] => drush_command,[1] => Array ([0] => all))),[8] => Array ([file] => phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php,[line] => 67,[function] => drush_dispatch,[args] => Array ([0] => Array ([bootstrap] => -2,[description] => Clear a specific cache, or all drupal caches.,[arguments] => Array ([0] => all),[callback] => drush_command,[aliases] => Array ([0] => cc),[command] => cache-clear,[command-hook] => cache-clear,[invoke hooks] => 1,[callback arguments] => Array (),[commandfile] => cache,[path] => phar:///usr/local/bin/drush/commands/core,[engines] => Array (),[primary function] => drush_cache_command_clear,[sections] => Array ([examples] => Examples,[arguments] => Arguments,[options] => Options),[required-arguments] => ,[options] => Array (),[sub-options] => Array (),[allow-additional-options] => ,[global-options] => Array (),[examples] => Array (),[core] => Array (),[scope] => site,[drush dependencies] => Array (),[handle-remote-commands] => ,[remote-tty] => ,[strict-option-handling] => ,[tilde-expansion] => 1,[bootstrap_errors] => Array (),[topics] => Array (),[hidden] => ,[category] => cache,[add-options-to-arguments] => ,[consolidation-output-formatters] => ,[annotated-command-callback] => ,[annotations] => Consolidation\AnnotatedCommand\AnnotationData Object ([command] => cache-clear),[drupal dependencies] => Array (),[is_alias] => 1,[argument-description] => Array ([type] => The particular cache to clear. Omit this argument to choose from available caches.)))),[9] => Array ([file] => phar:///usr/local/bin/drush/includes/preflight.inc,[line] => 66,[function] => bootstrap_and_dispatch,[class] => Drush\Boot\BaseBoot,[type] => ->,[args] => Array ()),[10] => Array ([file] => phar:///usr/local/bin/drush/includes/startup.inc,[line] => 465,[function] => drush_main,[args] => Array ()),[11] => Array ([file] => phar:///usr/local/bin/drush/includes/startup.inc,[line] => 369,[function] => drush_run_main,[args] => Array ([0] => ,[1] => /,[2] => Phar detected. Proceeding to drush_main().)),[12] => Array ([file] => phar:///usr/local/bin/drush/drush,[line] => 114,[function] => drush_startup,[args] => Array ([0] => Array ([0] => /usr/local/bin/drush,[1] => cc,[2] => all))),[13] => Array ([file] => /usr/local/bin/drush,[line] => 10,[args] => Array ([0] => phar:///usr/local/bin/drush/drush),[function] => require)),[] => ))
Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                                                                                                                                                                       [error]
Error: Call to undefined function cache_get() in /home/adoptingindoncas/public_html/includes/module.inc, line 765

edit: on updating an older D8 site using drush - 8.6.2 - 8.6.7

Project drupal was updated successfully. Installed version is now 8.6.7.
Backups were saved into the directory /home/user/drush-backups/site/20190118110517/drupal.                                           [ok]

exception 'TYPO3\PharStreamWrapper\Exception' with message 'Method stream_select() cannot be used' in /home/bluehippo/public_html/vendor/typo3/phar-stream-wrapper/src/PharStreamWrapper.php:146                                                                                                                                                         [error]
Stack trace:
#0 phar:///usr/local/bin/drush/includes/drush.inc(83): TYPO3\PharStreamWrapper\PharStreamWrapper->stream_cast(0)
#1 phar:///usr/local/bin/drush/includes/drush.inc(83): drush_include()
#2 phar:///usr/local/bin/drush/includes/engines.inc(520): drush_include('phar:///usr/loc...', 'environment')
#3 phar:///usr/local/bin/drush/lib/Drush/Boot/DrupalBoot.php(530): drush_include_engine('drupal', 'environment')
#4 phar:///usr/local/bin/drush/lib/Drush/Boot/DrupalBoot8.php(153): Drush\Boot\DrupalBoot->bootstrap_drupal_full()
#5 phar:///usr/local/bin/drush/includes/bootstrap.inc(354): Drush\Boot\DrupalBoot8->bootstrap_drupal_full()
#6 phar:///usr/local/bin/drush/includes/bootstrap.inc(473): drush_bootstrap(5, 5)
#7 phar:///usr/local/bin/drush/commands/core/drupal/update.inc(131): drush_bootstrap_to_phase(5)
#8 phar:///usr/local/bin/drush/commands/core/core.drush.inc(463): update_main()
#9 [internal function]: drush_core_updatedb()
#10 phar:///usr/local/bin/drush/includes/command.inc(422): call_user_func_array('drush_core_upda...', Array)
#11 phar:///usr/local/bin/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#12 [internal function]: drush_command()
#13 phar:///usr/local/bin/drush/includes/command.inc(199): call_user_func_array('drush_command', Array)
#14 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#15 phar:///usr/local/bin/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#16 phar:///usr/local/bin/drush/includes/startup.inc(465): drush_main()
#17 phar:///usr/local/bin/drush/includes/startup.inc(369): drush_run_main(false, '/', 'Phar detected. ...')
#18 phar:///usr/local/bin/drush/drush(114): drush_startup(Array)
#19 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#20 {main}

[~/www]# drush cc drush
TYPO3\PharStreamWrapper\Exception: Method stream_select() cannot be used in TYPO3\PharStreamWrapper\PharStreamWrapper->stream_cast() (line 146 of /home/bluehippo/public_html/vendor/typo3/phar-stream-wrapper/src/PharStreamWrapper.php).
Drush command terminated abnormally due to an unrecoverable error.
generalredneck’s picture

Issue summary: View changes

Added 2 steps to attempt help people work around this.

Everyone has to make sure they are calling drush.phar... either specifically or via a symlink.

Then you must clear your drush cache after your code has been upgraded to 7.63 or 8.6.7 while NOT in the site directory or removing the ~/.drush/cache folder.

The problem is for some reason the calls to the old filename of "drush" and not "drush.phar" are hanging around.

We need to look into if APC or alternative site caching backend like memcache or reddits may cause a similar issue.

Hitby’s picture

Unfortunately it makes no difference to me

root@ [/usr/local/bin]# mv drush drush.phar
root@ [/usr/local/bin]# ln -s drush.phar drush
root@ [/usr/local/bin]# drush cc drush

re-clear the drush cache in ~/
cd www
drush cc all

Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                                                                                                                                                                       [error]
Error: Call to undefined function cache_get() in /home/adoptingindoncas/public_html/includes/module.inc, line 762

backtrace

drush cc all

#0  module_implements(system_theme_info) called at [/home/adoptingindoncas/public_html/includes/module.inc:965]
#1  module_invoke_all(system_theme_info) called at [/home/adoptingindoncas/public_html/modules/system/system.module:2511]
#2  _system_rebuild_theme_data() called at [/home/adoptingindoncas/public_html/includes/theme.inc:798]
#3  list_themes() called at [/home/adoptingindoncas/public_html/includes/theme.maintenance.inc:57]
#4  _drupal_maintenance_theme() called at [/home/adoptingindoncas/public_html/includes/bootstrap.inc:2894]
#5  drupal_maintenance_theme() called at [/home/adoptingindoncas/public_html/includes/errors.inc:179]
#6  _drupal_log_error(Array ([%type] => TYPO3\PharStreamWrapper\Exception,[!message] => Method stream_select() cannot be used,[%function] => TYPO3\PharStreamWrapper\PharStreamWrapper->stream_cast(),[%file] => /home/adoptingindoncas/public_html/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php,[%line] => 146,[severity_level] => 3), 1) called at [/home/adoptingindoncas/public_html/includes/bootstrap.inc:2622]
#7  _drupal_exception_handler(TYPO3\PharStreamWrapper\Exception Object ([] => Method stream_select() cannot be used,[] => ,[] => 1530103999,[] => /home/adoptingindoncas/public_html/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php,[] => 146,[] => Array ([0] => Array ([file] => phar:///usr/local/bin/drush/vendor/composer/ClassLoader.php,[line] => 444,[function] => stream_cast,[class] => TYPO3\PharStreamWrapper\PharStreamWrapper,[type] => ->,[args] => Array ([0] => 0)),[1] => Array ([file] => phar:///usr/local/bin/drush/vendor/composer/ClassLoader.php,[line] => 444,[function] => Composer\Autoload\includeFile),[2] => Array ([file] => phar:///usr/local/bin/drush/vendor/composer/ClassLoader.php,[line] => 322,[function] => Composer\Autoload\includeFile,[args] => Array ([0] => phar:///usr/local/bin/drush/vendor/composer/../../lib/Drush/Command/DrushInputAdapter.php)),[3] => Array ([function] => loadClass,[class] => Composer\Autoload\ClassLoader,[type] => ->,[args] => Array ([0] => Drush\Command\DrushInputAdapter)),[4] => Array ([file] => phar:///usr/local/bin/drush/includes/command.inc,[line] => 353,[function] => spl_autoload_call,[args] => Array ([0] => Drush\Command\DrushInputAdapter)),[5] => Array ([file] => phar:///usr/local/bin/drush/includes/command.inc,[line] => 231,[function] => _drush_invoke_hooks,[args] => Array ([0] => Array ([bootstrap] => -2,[description] => Clear a specific cache, or all drupal caches.,[arguments] => Array ([0] => all),[callback] => drush_command,[aliases] => Array ([0] => cc),[command] => cache-clear,[command-hook] => cache-clear,[invoke hooks] => 1,[callback arguments] => Array (),[commandfile] => cache,[path] => phar:///usr/local/bin/drush/commands/core,[engines] => Array (),[primary function] => drush_cache_command_clear,[sections] => Array ([examples] => Examples,[arguments] => Arguments,[options] => Options),[required-arguments] => ,[options] => Array (),[sub-options] => Array (),[allow-additional-options] => ,[global-options] => Array (),[examples] => Array (),[core] => Array (),[scope] => site,[drush dependencies] => Array (),[handle-remote-commands] => ,[remote-tty] => ,[strict-option-handling] => ,[tilde-expansion] => 1,[bootstrap_errors] => Array (),[topics] => Array (),[hidden] => ,[category] => cache,[add-options-to-arguments] => ,[consolidation-output-formatters] => ,[annotated-command-callback] => ,[annotations] => Consolidation\AnnotatedCommand\AnnotationData Object ([command] => cache-clear),[drupal dependencies] => Array (),[is_alias] => 1,[argument-description] => Array ([type] => The particular cache to clear. Omit this argument to choose from available caches.)),[1] => Array ([0] => all))),[6] => Array ([function] => drush_command,[args] => Array ([0] => all)),[7] => Array ([file] => phar:///usr/local/bin/drush/includes/command.inc,[line] => 199,[function] => call_user_func_array,[args] => Array ([0] => drush_command,[1] => Array ([0] => all))),[8] => Array ([file] => phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php,[line] => 67,[function] => drush_dispatch,[args] => Array ([0] => Array ([bootstrap] => -2,[description] => Clear a specific cache, or all drupal caches.,[arguments] => Array ([0] => all),[callback] => drush_command,[aliases] => Array ([0] => cc),[command] => cache-clear,[command-hook] => cache-clear,[invoke hooks] => 1,[callback arguments] => Array (),[commandfile] => cache,[path] => phar:///usr/local/bin/drush/commands/core,[engines] => Array (),[primary function] => drush_cache_command_clear,[sections] => Array ([examples] => Examples,[arguments] => Arguments,[options] => Options),[required-arguments] => ,[options] => Array (),[sub-options] => Array (),[allow-additional-options] => ,[global-options] => Array (),[examples] => Array (),[core] => Array (),[scope] => site,[drush dependencies] => Array (),[handle-remote-commands] => ,[remote-tty] => ,[strict-option-handling] => ,[tilde-expansion] => 1,[bootstrap_errors] => Array (),[topics] => Array (),[hidden] => ,[category] => cache,[add-options-to-arguments] => ,[consolidation-output-formatters] => ,[annotated-command-callback] => ,[annotations] => Consolidation\AnnotatedCommand\AnnotationData Object ([command] => cache-clear),[drupal dependencies] => Array (),[is_alias] => 1,[argument-description] => Array ([type] => The particular cache to clear. Omit this argument to choose from available caches.)))),[9] => Array ([file] => phar:///usr/local/bin/drush/includes/preflight.inc,[line] => 66,[function] => bootstrap_and_dispatch,[class] => Drush\Boot\BaseBoot,[type] => ->,[args] => Array ()),[10] => Array ([file] => phar:///usr/local/bin/drush/includes/startup.inc,[line] => 465,[function] => drush_main,[args] => Array ()),[11] => Array ([file] => phar:///usr/local/bin/drush/includes/startup.inc,[line] => 369,[function] => drush_run_main,[args] => Array ([0] => ,[1] => /,[2] => Phar detected. Proceeding to drush_main().)),[12] => Array ([file] => phar:///usr/local/bin/drush/drush,[line] => 114,[function] => drush_startup,[args] => Array ([0] => Array ([0] => /usr/local/bin/drush,[1] => cc,[2] => all))),[13] => Array ([file] => /usr/local/bin/drush,[line] => 10,[args] => Array ([0] => phar:///usr/local/bin/drush/drush),[function] => require)),[] => ))
Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                                                                                                                                                                       [error]
Error: Call to undefined function cache_get() in /home/adoptingindoncas/public_html/includes/module.inc, line 765
generalredneck’s picture

Question...
Is there any reason we dont check to see if the file actually exists in https://cgit.drupalcode.org/drupal/tree/misc/typo3/drupal-security/PharE...
May be a stupid one... or maybe the filename needs to be expanded before checked?

in the cache issue with drush... if your server doesnt have php set up to follow symlinks... this may be an issue?

generalredneck’s picture

@hitby
Try calling drush.phar instead of the symlink and doing the steps. I notice in your stack its calling phar:///usr/local/bin/drush which is setting it off because drush doesn't have the .phar extension.

If that doesnt work I suspect the call is cached elsewhere like the database or memcache so we may have to resort to clearing that cache manually before we get the effect. Also... you ARE getting a slightly different error from some of us. So we need to explore a bit.

Hitby’s picture

Thanks for your help on this. renaming drush to drush.phar, clearing caches and repeating a cc all

drush.phar cc all
#0  module_implements(system_theme_info) called at [/home/adoptingindoncas/public_html/includes/module.inc:965]
#1  module_invoke_all(system_theme_info) called at [/home/adoptingindoncas/public_html/modules/system/system.module:2511]
#2  _system_rebuild_theme_data() called at [/home/adoptingindoncas/public_html/includes/theme.inc:798]
#3  list_themes() called at [/home/adoptingindoncas/public_html/includes/theme.maintenance.inc:57]
#4  _drupal_maintenance_theme() called at [/home/adoptingindoncas/public_html/includes/bootstrap.inc:2894]
#5  drupal_maintenance_theme() called at [/home/adoptingindoncas/public_html/includes/errors.inc:179]
#6  _drupal_log_error(Array ([%type] => TYPO3\PharStreamWrapper\Exception,[!message] => Method stream_select() cannot be used,[%function] => TYPO3\PharStreamWrapper\PharStreamWrapper->stream_cast(),[%file] => /home/adoptingindoncas/public_html/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php,[%line] => 146,[severity_level] => 3), 1) called at [/home/adoptingindoncas/public_html/includes/bootstrap.inc:2622]
#7  _drupal_exception_handler(TYPO3\PharStreamWrapper\Exception Object ([] => Method stream_select() cannot be used,[] => ,[] => 1530103999,[] => /home/adoptingindoncas/public_html/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php,[] => 146,[] => Array ([0] => Array ([file] => phar:///usr/local/bin/drush.phar/vendor/composer/ClassLoader.php,[line] => 444,[function] => stream_cast,[class] => TYPO3\PharStreamWrapper\PharStreamWrapper,[type] => ->,[args] => Array ([0] => 0)),[1] => Array ([file] => phar:///usr/local/bin/drush.phar/vendor/composer/ClassLoader.php,[line] => 444,[function] => Composer\Autoload\includeFile),[2] => Array ([file] => phar:///usr/local/bin/drush.phar/vendor/composer/ClassLoader.php,[line] => 322,[function] => Composer\Autoload\includeFile,[args] => Array ([0] => phar:///usr/local/bin/drush.phar/vendor/composer/../../lib/Drush/Command/DrushInputAdapter.php)),[3] => Array ([function] => loadClass,[class] => Composer\Autoload\ClassLoader,[type] => ->,[args] => Array ([0] => Drush\Command\DrushInputAdapter)),[4] => Array ([file] => phar:///usr/local/bin/drush.phar/includes/command.inc,[line] => 353,[function] => spl_autoload_call,[args] => Array ([0] => Drush\Command\DrushInputAdapter)),[5] => Array ([file] => phar:///usr/local/bin/drush.phar/includes/command.inc,[line] => 231,[function] => _drush_invoke_hooks,[args] => Array ([0] => Array ([bootstrap] => -2,[description] => Clear a specific cache, or all drupal caches.,[arguments] => Array ([0] => all),[callback] => drush_command,[aliases] => Array ([0] => cc),[command] => cache-clear,[command-hook] => cache-clear,[invoke hooks] => 1,[callback arguments] => Array (),[commandfile] => cache,[path] => phar:///usr/local/bin/drush.phar/commands/core,[engines] => Array (),[primary function] => drush_cache_command_clear,[sections] => Array ([examples] => Examples,[arguments] => Arguments,[options] => Options),[required-arguments] => ,[options] => Array (),[sub-options] => Array (),[allow-additional-options] => ,[global-options] => Array (),[examples] => Array (),[core] => Array (),[scope] => site,[drush dependencies] => Array (),[handle-remote-commands] => ,[remote-tty] => ,[strict-option-handling] => ,[tilde-expansion] => 1,[bootstrap_errors] => Array (),[topics] => Array (),[hidden] => ,[category] => cache,[add-options-to-arguments] => ,[consolidation-output-formatters] => ,[annotated-command-callback] => ,[annotations] => Consolidation\AnnotatedCommand\AnnotationData Object ([command] => cache-clear),[drupal dependencies] => Array (),[is_alias] => 1,[argument-description] => Array ([type] => The particular cache to clear. Omit this argument to choose from available caches.)),[1] => Array ([0] => all))),[6] => Array ([function] => drush_command,[args] => Array ([0] => all)),[7] => Array ([file] => phar:///usr/local/bin/drush.phar/includes/command.inc,[line] => 199,[function] => call_user_func_array,[args] => Array ([0] => drush_command,[1] => Array ([0] => all))),[8] => Array ([file] => phar:///usr/local/bin/drush.phar/lib/Drush/Boot/BaseBoot.php,[line] => 67,[function] => drush_dispatch,[args] => Array ([0] => Array ([bootstrap] => -2,[description] => Clear a specific cache, or all drupal caches.,[arguments] => Array ([0] => all),[callback] => drush_command,[aliases] => Array ([0] => cc),[command] => cache-clear,[command-hook] => cache-clear,[invoke hooks] => 1,[callback arguments] => Array (),[commandfile] => cache,[path] => phar:///usr/local/bin/drush.phar/commands/core,[engines] => Array (),[primary function] => drush_cache_command_clear,[sections] => Array ([examples] => Examples,[arguments] => Arguments,[options] => Options),[required-arguments] => ,[options] => Array (),[sub-options] => Array (),[allow-additional-options] => ,[global-options] => Array (),[examples] => Array (),[core] => Array (),[scope] => site,[drush dependencies] => Array (),[handle-remote-commands] => ,[remote-tty] => ,[strict-option-handling] => ,[tilde-expansion] => 1,[bootstrap_errors] => Array (),[topics] => Array (),[hidden] => ,[category] => cache,[add-options-to-arguments] => ,[consolidation-output-formatters] => ,[annotated-command-callback] => ,[annotations] => Consolidation\AnnotatedCommand\AnnotationData Object ([command] => cache-clear),[drupal dependencies] => Array (),[is_alias] => 1,[argument-description] => Array ([type] => The particular cache to clear. Omit this argument to choose from available caches.)))),[9] => Array ([file] => phar:///usr/local/bin/drush.phar/includes/preflight.inc,[line] => 66,[function] => bootstrap_and_dispatch,[class] => Drush\Boot\BaseBoot,[type] => ->,[args] => Array ()),[10] => Array ([file] => phar:///usr/local/bin/drush.phar/includes/startup.inc,[line] => 465,[function] => drush_main,[args] => Array ()),[11] => Array ([file] => phar:///usr/local/bin/drush.phar/includes/startup.inc,[line] => 369,[function] => drush_run_main,[args] => Array ([0] => ,[1] => /,[2] => Phar detected. Proceeding to drush_main().)),[12] => Array ([file] => phar:///usr/local/bin/drush.phar/drush,[line] => 114,[function] => drush_startup,[args] => Array ([0] => Array ([0] => /usr/local/bin/drush.phar,[1] => cc,[2] => all))),[13] => Array ([file] => /usr/local/bin/drush.phar,[line] => 10,[args] => Array ([0] => phar:///usr/local/bin/drush.phar/drush),[function] => require)),[] => ))
Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                                                                                                                                                                       [error]
Error: Call to undefined function cache_get() in /home/adoptingindoncas/public_html/includes/module.inc, line 765
generalredneck’s picture

@hitby,
Does this go away when you downgrade back to 7.61 or do you still get an error in cache_get. the cache_get error can ALSO be caused by a syntax error in your any of your settings.php files.

Try running php -l on each of your settings files. Example

php -l ./workspace/mysite/build/sites/default/settings.php 
No syntax errors detected in ./workspace/mysite/build/sites/default/settings.php

You will have to do this one at a time as I don't THINK -l allows wildcards. You might be able to do something fancy like

$ find ./build/sites/default  -iname "*settings*.php" -exec php -l {} \;
No syntax errors detected in ../build/sites/default/settings.php
No syntax errors detected in ../build/sites/default/settings.redirects.php
No syntax errors detected in ../build/sites/default/default.settings.local.php
No syntax errors detected in ../build/sites/default/settings.local.php
No syntax errors detected in ../build/sites/default/default.settings.php
No syntax errors detected in ../build/sites/default/settings.secret.php
No syntax errors detected in ../build/sites/default/default.settings.secret.php
No syntax errors detected in ../build/sites/default/settings.custom.php
Hitby’s picture

Thanks,
Will an issue in a settings file from a separate Drupal install affect all?

fwiw, drush works fine on any D7.X before 7.63
as soon as I update a codebase to 7.63 drush fails.

php -l on the ones I have already updated say no syntax errors detected. I'll need to file a support request to have drush downgraded although I have one pending already for a composer version.

Cheers

generalredneck’s picture

Will an issue in a settings file from a separate Drupal install affect all?

naw, just on the site you are running the command on. You would notice when you try running the site too cause you would get the same cache_get error.

fwiw, drush works fine on any D7.X before 7.63
as soon as I update a codebase to 7.63 drush fails.

Ok cool, so we know for a fact that it only happens with 7.63... that's what I wanted to verify... The only other thing I would say that we haven't tried yet is clearing your site's cache manually (without drush). if we could for a fact clear all the caches (including memcache, database cache, redis, opcache and APC depending on the version of php you are on) and then go through our process above... I would feel a bunch better.

I don't suppose you have tried to run cache_clear using the website itself have you? like using the button on admin -> config -> development and seeing if it has a similar issue? I want to see if this is limited to using drush.

After that I don't know where to go and someone else may have to get a fresh set of eyes on your site's symptoms.

Alex Monaghan’s picture

Most odd, given the mention of cache, I went back to my failed sites and 2 D7 and the D6 site ran drush up OK, the 3rd D7 ran it OK after doing a drush cc drush.

I changed PHP from 5 to 7 (overdue anyway!) yesterday evening but that didn't fix the drush issue.

kevinquillen’s picture

My problem is gone. Here is what I did after getting some rest.

Docker container:

cd /usr/local/bin
mv drush drush.phar
ln -s drush.phar drush
rm -rf ~/.drush/cache
cd /app/docroot
drush @none cache-clear drush
exit;

Host machine:

lando drush @mysite.local updb

No error. Also no subsequent error on uli, cc all, up (project). I still have the patch from #16 applied.

I suppose the rename of drush to drush.phar and forcibly removing the cache folder was key. Although, how would this address other packages like GeoIP or Guzzle that have been reported?

I will reiterate that this is an older project that does not have or use Composer, and Drush (8.x) is installed globally in the Docker container and not to the project.

generalredneck’s picture

Yeah I had the TYPO3 error just hit me on a lando machine... After running drush @none cc drush from inside the machine... all was well...

Hitby’s picture

A little further information after working through it with @alexpott

A drush cc all --debug gives

Phar detected. Proceeding to drush_main().
Cache HIT cid: 8.1.18-commandfiles-0-c43a32d9b11cfaf357f5c6329c8dc30e [0.02 sec, 3.52 MB]                                                                                                                                                                                                                                                                    [debug]
Bootstrap to phase 0. [0.17 sec, 9.64 MB]                                                                                                                                                                                                                                                                                                                [bootstrap]
Trying to bootstrap as far as we can. [0.18 sec, 9.64 MB]                                                                                                                                                                                                                                                                                                    [debug]
Drush bootstrap phase : bootstrap_drupal_root() [0.18 sec, 10.02 MB]                                                                                                                                                                                                                                                                                     [bootstrap]
Initialized Drupal 7.63 root directory at /home/user/public_html [0.19 sec, 10.02 MB]                                                                                                                                                                                                                                                        [bootstrap]
Find command files for phase 1 (max=7) [0.19 sec, 7.62 MB]                                                                                                                                                                                                                                                                                                   [debug]
Cache HIT cid: 8.1.18-commandfiles-1-08d7742648251c88a2e0b2817fc7da71 [0.19 sec, 7.62 MB]                                                                                                                                                                                                                                                                    [debug]
Cache HIT cid: 8.1.18-annotationfiles-1-37b6388894bef3c65fc89d35f648c4e1 [0.19 sec, 7.63 MB]                                                                                                                                                                                                                                                                 [debug]
Drush bootstrap phase : bootstrap_drupal_site() [0.24 sec, 7.65 MB]                                                                                                                                                                                                                                                                                      [bootstrap]
Initialized Drupal site default at sites/default [0.24 sec, 7.65 MB]                                                                                                                                                                                                                                                                                     [bootstrap]
Find command files for phase 2 (max=7) [0.25 sec, 7.65 MB]                                                                                                                                                                                                                                                                                                   [debug]
Drush bootstrap phase : bootstrap_drupal_configuration() [0.25 sec, 7.65 MB]                                                                                                                                                                                                                                                                             [bootstrap]
Find command files for phase 3 (max=7) [0.25 sec, 7.85 MB]                                                                                                                                                                                                                                                                                                   [debug]
Checking DB credentials yielded error: Method stream_select() cannot be used [0.25 sec, 7.88 MB]                                                                                                                                                                                                                                                             [debug]
Bootstrap phase bootstrap_drupal_database() failed to validate; continuing at bootstrap_drupal_configuration(). [0.25 sec, 7.85 MB]                                                                                                                                                                                                                          [debug]
Found command: cache-clear (commandfile=cache) [0.25 sec, 7.85 MB]                                                                                                                                                                                                                                                                                       [bootstrap]
Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                                                                                                                                                                       [error]
Error: Call to undefined function cache_get() in /home/adoptingindoncas/public_html/includes/module.inc, line 762 [0.34 sec, 13.25 MB]
kevinquillen’s picture

After the change, putting the debugging back in place from #32, $fileExtension now has 'phar'.

Hitby’s picture

I've replaced drush with a composer installed version which is working as expected.

cilefen’s picture

Title: After upgrade to 7.63 still get TYPO3 phar error for drush » After upgrade still get TYPO3 phar error for drush
luf’s picture

This same error occurred on a site running 7.62 with no Drush in the environment, upgraded to 7.63 at this time to see if it makes a difference, however it may be good to note.

[edit] After updating to 7.63 within 24 hours the same error occurred. Again, this installation and server does not have Drush in the environment at all.

generalredneck’s picture

Title: After upgrade still get TYPO3 phar error for drush » After upgrade to 7.63, 8.6.7, or 8.5.10 still get TYPO3 phar error for drush

Being more specific on what we upgraded to since 7.63 was removed from the title earlier. THis way that people that are just pulling in the security fix will know to upgrade to the newer hotfixed version.

possiBri’s picture

Switching to Drush 8.1.18 (using Lando, updated .lando.yml and then rebuilt site) and then following the steps to clear Drush (I used the @none method) in #46 has worked for me as well. I can now drush cc all without error. Thanks!

xjm’s picture

Issue summary: View changes

Adding help text to the IS for site users who are struggling to get updated to 7.63 et. al

xjm’s picture

Issue summary: View changes

Adding more about the Drush update, since this seems to be solving the problem for a lot of sites.

xjm’s picture

@Hitby, I saw earlier that some folks with a cache_get() error when the new TYPO3 library folder hadn't been completely deployed to the server. Can you check that all the files are there in http://cgit.drupalcode.org/drupal/tree/misc/typo3?h=7.x ?

Edit: I see you are having success now with a Composer install. I'll add the example to the IS.

xjm’s picture

Issue summary: View changes
xjm’s picture

Issue summary: View changes
xjm’s picture

Issue summary: View changes
generalredneck’s picture

so something that has been consistant with every deploy so far in my clients is making sure are using drush.phar (either a symlink TO it, or drush.phar itself) and the need to clear out drush's cache using drush @none cc drush... Something is being cached over in ~/.drush/cache that is contributing to this.

Hitby’s picture

@xjm, yep, all the files had deployed correctly. emptying ~/.drush/cache didn't help me unfortunately.

generalredneck’s picture

FileSize
8.39 KB

So @greg.1.anderson, @alexpott and myself got together and worked through some stuff. This doesn't highlight @Hitby's case, but it does highlight my usecase. We will have to investigate to see if we can find the cause for Hitby's case.

As for my error, here's how you reproduce it. I'm using lando because it was easy for me... but you can use any site setup to do this

# 1. Create a site using 7.61 (i'm using a composer build)
composer create-project drupal-composer/drupal-project:7.x-dev some-dir --stability dev --no-interaction
cd some-dir
echo "name: some-dir
recipe: drupal7
config:
  webroot: web
  php: '5.6'" > .lando.yml
lando start
lando composer require drupal/drupal:7.61

#2. download drush.phar (I used version 8.1.9 cause that's where it happened for me before) and name it `drush` (it can be anywhere)
wget -O drush https://github.com/drush-ops/drush/releases/download/8.1.9/drush.phar
chmod +x drush
lando ssh

#3. use drush from the webroot of your site to install the site
cd /app/web
/app/drush si

#4. use drush from the webroot to download and enable ctools and views
/app/drush dl ctools -y
/app/drush dl views -y
/app/drush en views -y

#5. Upgrade your code to 7.63 (I did a composer update after changing composer.json)
cd ..
composer require drupal/drupal:7.63

#6. move drush to drush.phar and make a symlink called "drush"
mv /app/drush /app/drush.phar
ln -s /app/drush.phar /app/drush

#7. Call drush using the full path to the symlink in the web directory to clear cache
cd web
/app/drush cc all

The output I get here is

www-data@079e3c18304a:/app/web$ /app/drush cc all
WD php: TYPO3\PharStreamWrapper\Exception: Unexpected file extension in "phar:///app/drush/commands/core/locale.d8.drush.inc" in Drupal\Core\Security\PharExtensionInterceptor->assert() (line 38 of                                                 [error]
/app/web/misc/typo3/drupal-security/PharExtensionInterceptor.php).
TYPO3\PharStreamWrapper\Exception: Unexpected file extension in "phar:///app/drush/commands/core/locale.d8.drush.inc" in Drupal\Core\Security\PharExtensionInterceptor->assert() (line 38 of /app/web/misc/typo3/drupal-security/PharExtensionInterceptor.php).
Drush command terminated abnormally due to an unrecoverable error.   

A copy of the debug data is attached as output.txt

This led me to find the cache file that contains references to the phar which looks like this in ~/.drush/cache/default/ 8.1.9-commandfiles-5-d097766d5aa5d9522510e16a657204b9.cache

{
    "cid": "8.1.9-commandfiles-5-d097766d5aa5d9522510e16a657204b9",
    "data": {
        "locale.d8": "phar:\/\/\/app\/drush\/commands\/core\/locale.d8.drush.inc",
        "views.d8": "phar:\/\/\/app\/drush\/commands\/core\/views.d8.drush.inc"
    },
    "created": 1547851989,
    "expire": 0
}

2 things I can think of in reguards to this...

  1. drush cc drush is an acceptable fix to this, case closed after work arounds.
  2. We need to get the extention detection to somehow give us the full rendered path and cut out the symlinks that are involved so that phar:\/\/\/app\/drush becomes phar:\/\/\/app\/drush.phar

Hope this helps.

xjm’s picture

Great research! Thanks so much for documenting all those steps.

(Updating issue credit.)

blairwigley’s picture

I was getting this issue with a wget installed version of Drush 8.1.17. Removing it and installing Drush 8.1.18 via composer solved the issue for me.

sridarm’s picture

I tried "composer update update drupal/core --with-dependencies" which solved the issues for me in d8

luf’s picture

Issue persists: PHP Fatal Error TYPO3\PharStreamWrapper\Manager not found file.phar.inc on line 27

Drupal 7.63 with no Drush or Composer installed in the environment. This may require its own issue as none of the fixes here will resolve for this system.

generalredneck’s picture

@luf

That's a new one... Sounds like something different. Do you by chance have a full stack trace or steps on how to reproduce?

luf’s picture

@generalredneck

I do not, have been looking through logs to try and find what is causing this issue and cannot find any requests or errors that could trigger this event. Environment is IIS 8.5, PHP 5.6.4 (non thread safe).

'Class 'TYPO3\PharStreamWrapper\Manager' not found' suggests it is unable to use the assigned variable: 'use TYPO3\PharStreamWrapper\Manager as PharStreamWrapperManager;' on line 4 or is somehow ignoring the assignment.

generalredneck’s picture

Interesting... that actually sounds like you may be missing some files. You might check that the following files in https://www.drupal.org/commitlog/commit/2/3d3ff82cee9d80ef5fc1647fbd2096... are there... use doesn't assign variables, but it does tell the script to "use" a fully qualified class name as an aliase... so in this case TYPO3\PharStreamWrapper\Manager is aliased as PharStreamWrapperManager. Since all of the TYPO3 stuff declares a namespace this works. All the files within the TYPO3 folder are also included in includes/file.phar.inc as you can see here https://cgit.drupalcode.org/drupal/commit/?id=a4455a1628111df7127c73e0a2...

So given that... that should be found...

An easy way to test would be to redownload 7.63 again and drop at least the misc and include directories over what you have installed.

luf’s picture

Appreciate the fast response, all of the files did show up and I have updated to 7.63 again to see if this resolves the issue. Will update again if it continues to occur.

sokru’s picture

I got the same error message with Drush 9.4.0 + 8.6.7, using DDEV. Visiting update.php revealed that I had accidentally removed one contrib module (realistic_dummy_content) from local file system, putting back the contrib module fixed the issue.

romanow’s picture

Manual Upgrade from 8.6.4 to 8.6.7. Only copy the zip content as I've always done, and I get the error "The website encountered an unexpected error. Please try again later."

I couldn't execute update.php, it showed the same error "The website encountered an unexpected error. Please try again later."

I'm sorry about my English.

DrPal43’s picture

I updated from 8.6.2 to 8.6.7 and got this error. It was fixed after this git commands.

composer update drupal/core --with-dependencies
git add --all
git commit -m "Drupal core 8.6.7"
git push

Some of the files are not being added to the commit and you need to use git add --all.

Hopefully this helps out some people.

cilefen’s picture

@romanow Something will be logged by the web server. You must look there.

loopy1492’s picture

I'm not sure if this helps, but on our Drupal 8 site, this is what kept me from simply running Composer Update at first"

Could not scan for classes inside "/var/www/docroot/vendor/phayes/geophp/geoPHP.inc" which does not appear to be a file nor a folder

So I deleted composer.lock and vendor folders, then ran composer install and that's what has led me down this path.

generalredneck’s picture

loopy1492’s picture

That's the error, @generalredneck but composer install seemed to quiet the issue.

So, after updating to 8.6.7, I am no longer getting a phar error, but now I'm getting the following when I load up the site:

The website encountered an unexpected error. Please try again later.
Error: Unsupported operand types in Drupal\bootstrap\Plugin\Provider\JsDelivr->processDefinition() (line 108 of themes/contrib/bootstrap/src/Plugin/Provider/JsDelivr.php).

Drush runs fine, but the site doesn't render due to the above error. I'll try to see if there's a separate issue for it.

loopy1492’s picture

Okay. I rebased my repo back to before the update. Then, I changed the drupal version from 8.6.3 to 8.6.7. Our vendor had bootstrap set to "^3.16". I changed it to just "3.16" because I think there's a stable dev version out there that might have been downloaded.

Neither error occurs now and the site works fine. Thanks for all your work on this issue.

jonhattan’s picture

Issue summary: View changes
generalredneck’s picture

Issue summary: View changes
generalredneck’s picture

Issue summary: View changes
zlatev’s picture

I just found out an interesting dependancy. We have multiple projects running on both 7 and 8 and even after all tips here one of the 7.63 projects still fired up the error. We had a memcache service up and running - after taking out the memcache of the equation everything is fine so my guess is that something goes wrong there. I hope to be able to make a deeper research soon. I tested locally and even with "fresh" cache the problem is still reproducible.

tormi’s picture

Re: #96

I confirm that the problem was resolved after removing memcached from my local Lando environment.

  # Add Lando Memcache service.
  # cache:
  #   type: memcached
  #   mem: 512
  #   portforward: 11211
kiddynomite’s picture

I upgraded Drupal to 7.6.3 using Drush 8.1.15 locally and it worked fine (drush up). It works great on my local copy (MAMP) but when I deploy it to AWS every page returns 'Not Found' with this error in the httpd logs:

[Thu Jan 24 16:50:38.766397 2019] [:error] [pid 25388] [client 46.229.168.138:40278]

PHP Fatal error:

Class 'TYPO3\\PharStreamWrapper\\Behavior' not found in /var/www/html/mysite.com/includes/file.phar.inc on line 26

Not certain if it's related, but thought I'd pass it along. I haven't found a fix yet either.

ykarthikvarma’s picture

@kiddynomite Try updating the PHP libraries "vendor" using composer which fixed a similar issue for me.

composer update drupal/core --with-dependencies

effulgentsia’s picture

#99 is a good tip for Drupal 8, but #98's report is for Drupal 7.

WillGFP’s picture

I had this error with 7.62, tried a few things but only a manual update to 7.63 fixed things.

generalredneck’s picture

awoodley’s picture

I have several 7.6.3 Drupal installs and I found if you commit the "misc/type3" with 7.6.3 is works fine. The problem is to do with the phar-stream-wrapper/ missing. - From my point of view. cheers

xjm’s picture

Issue summary: View changes

It sounds like several folks are running into trouble with the library not being included/found due to issues with deployment or a stale cache of some sort (memcached, opcode, etc.). Adding a note about that to the suggestions in the IS.

kevinquillen’s picture

Update here - I just updated a project from 7.60 to 7.63 that was in Docker Compose setup (but NOT a Lando project) that worked fine and did not have the same issue I had earlier in the thread.

chowdah’s picture

Issue summary: View changes

I stumbled across this thread after trying an upgrade from 7.61-7.63 and getting the same type of error. I was running Drush 8.1.11. I restored from backup then tried upgrade from 7.61 to 7.62 - got the same error, then fupgraded to 7.63 and still same error, although the upgrades were 'successful' drush was broken - see below. So I restored the site from a backup to 7.61 and updated Drush to 8.1.18. After making sure that Drush was running properly, I ran the site upgrade again from 7.61-7.63. The site upgraded successfully then threw this error:

exception 'TYPO3\PharStreamWrapper\Exception' with message 'Method   [error]
stream_select() cannot be used' in
/home/nskid/public_html/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php:146
Stack trace:
#0 phar:///usr/local/bin/drush/includes/drush.inc(78):
TYPO3\PharStreamWrapper\PharStreamWrapper->stream_cast(0)
#1 phar:///usr/local/bin/drush/includes/drush.inc(78):
drush_include()
#2 phar:///usr/local/bin/drush/includes/engines.inc(520):
drush_include('phar:///usr/loc...', 'environment')
#3 phar:///usr/local/bin/drush/lib/Drush/Boot/DrupalBoot.php(530):
drush_include_engine('drupal', 'environment')
#4 phar:///usr/local/bin/drush/lib/Drush/Boot/DrupalBoot7.php(96):
Drush\Boot\DrupalBoot->bootstrap_drupal_full()
#5 phar:///usr/local/bin/drush/includes/bootstrap.inc(354):
Drush\Boot\DrupalBoot7->bootstrap_drupal_full()
#6
phar:///usr/local/bin/drush/commands/core/drupal/update_7.inc(204):
drush_bootstrap(5)
#7
phar:///usr/local/bin/drush/commands/core/drupal/update_7.inc(225):
update_main_prepare()
#8 phar:///usr/local/bin/drush/commands/core/core.drush.inc(463):
update_main()
#9 [internal function]: drush_core_updatedb()
#10 phar:///usr/local/bin/drush/includes/command.inc(422):
call_user_func_array('drush_core_upda...', Array)
#11 phar:///usr/local/bin/drush/includes/command.inc(231):
_drush_invoke_hooks(Array, Array)
#12 [internal function]: drush_command()
#13 phar:///usr/local/bin/drush/includes/command.inc(199):
call_user_func_array('drush_command', Array)
#14 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67):
drush_dispatch(Array)
#15 phar:///usr/local/bin/drush/includes/preflight.inc(66):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#16 phar:///usr/local/bin/drush/includes/startup.inc(465):
drush_main()
#17 phar:///usr/local/bin/drush/includes/startup.inc(369):
drush_run_main(false, '/', 'Phar detected. ...')
#18 phar:///usr/local/bin/drush/drush(114): drush_startup(Array)
#19 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#20 {main}

The error is similar to the same errors that were thrown in my previous attempts.
If I run a Drush command (drush status) from the Drupal root, I get this error:

Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: Call to undefined function cache_get() in
/home/*****/public_html/includes/module.inc, line 762

Same error for every drush command. When I look for a function declaration of cache_get() in module.inc, i see 5 references to the function but no declaration.
If I run Drush commands outside Drupal root, no errors are thrown.

generalredneck’s picture

@chowdah,
Even after running drush cc drush you still get these issues? There is also a whole portion of the thread (and another issue) that is dedicated to working around cache_get issues.

chowdah’s picture

Thanks so much for even caring @generalredneck! I saw the other issue at Fatal error: Call to undefined function cache_get(). So I was getting both errors - cache_get() and phar: The setup was Drush 8.1.18, php5.6 and drupal 7.63. The server is a dedicated box with some shared hosts, but I'm the only person who accesses it, and the global Drush install works for me.

Drush followed by any command would throw the cache-get() error - so I couldn't use cc all, even if I used Drush outside doc root with the site alias. I could clear drush cache outside doc root using drush cc drush though. I had issues using the ui to clear the cache, but it resolved itself I after I discovered some permission issues on the cache folder.

Even after using the ui to clear the cache, the same errors still existed in Drush. If I issued Drush alone without any additional commands, I would get phar: errors.

My next steps were changing the drush to drush.phar and linking it to drush, which failed. Drush was manually installed globally on my server without composer, so I avoided the composer route to avoid screwing up the drush install any further. The server is a dedicated box with some shared hosts, but I'm the only person who accesses it, and the global Drush install works for me.

My last step was to upgrade php on the site. I chose to upgrade to PHP 7.1, the minimum version for Drupal 7.63 according to the Drupal 7 Documentation*, and was expecting some major errors to come my way due to the major version change from 5.6, but was pleasantly surprise to only have to increase the memory limit in php.ini to get the site back to working order. When I opened SSH, and ran drush I bummed because the same errors persisted. I ran drush status outside document root, and it told me

 PHP configuration      :  /opt/cpanel/ea-php56/root/etc/php.ini

After seeing drush was still running under 5.6, I upgraded the entire server's php to 7.1 and suddenly everything worked as expected.

Lastly, I wanted to mention that I double check all the files that were added to the 7.63 distribution - includes/file.phar.inc and all the files in misc/typo3/ and its sub-directories and found extra lines at the end of almost all of the files:

  • includes/file.phar.inc
  • misc/typo3/drupal-security/PharExtensionInterceptor.php
  • misc/typo3/phar-stream-wrapper/composer.json
  • misc/typo3/phar-stream-wrapper/src/Assertable.php
  • misc/typo3/phar-stream-wrapper/src/Behavior.php
  • misc/typo3/phar-stream-wrapper/src/Exception.php
  • misc/typo3/phar-stream-wrapper/src/Manager.php
  • misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php
  • misc/typo3/phar-stream-wrapper/src/Interceptor/PharExtensionInterceptor.php

This may not have made a difference, but I have read that blank lines at the end of files sometimes cause parsing errors, so I removed the blank lines.

Thanks for working so hard on this! I hope any info I gave is useful.

*This may be the reason for my issue in the first place. I had no idea that 7.1 was the minimum recommended PHP for Drupal 7.63, until I found it in the documentation. Had I known, I would have started with the PHP upgrade before applying the 7.63 to the Drupal install. I see the PHP requirement as a major dependency change for this particular upgrade, so this fact should be shouting in your face prior to upgrade, even when using Drush to do so. I kept using 5.6 for so long because it worked very well for me until recently. I was unaware of the EOL date just recently passed for 5.6. Now that I have a stable environment with newer versions, I'll tweak my way through minor php versions, and then work through a migration to 8, which should be interesting as this particular site has matured through Drupal 6 previously, and I have over 10,000 nodes presently.

generalredneck’s picture

Thank you for the kind words and from what I read, looks like you are going.

I had no idea that 7.1 was the minimum recommended PHP for Drupal 7.63, until I found it in the documentation

The reasoning behind this was because 5.6 end of lifed 31 Dec 2018. It's still supported as in, Drupal 7 will continue to maintain all the way down to PHP 5.2.4 per INSTALL.TXT, but highly recommend you maintain a version of PHP that at least is getting security upgrades. That's why the Documentation recommends 7.1, however, the CMS will function on 5.2.4. I might also add insecurely... particularly with this last security upgrade which will only secure your site if you are running 5.3.3 or above.

Drush followed by any command would throw the cache-get() error - so I couldn't use cc all, even if I used Drush outside doc root with the site alias. I could clear drush cache outside doc root using drush cc drush though. I had issues using the ui to clear the cache, but it resolved itself I after I discovered some permission issues on the cache folder.

Quick question on this... Are you sure that the permissions you set up are read/writable by both the user using drush AND your webserver? That may be a place to look

After seeing drush was still running under 5.6, I upgraded the entire server's php to 7.1 and suddenly everything worked as expected.

This is totally starting to sound like APC cache to me... I wonder if a simple restart after your permission changes wouldn't have also handled this, but "would of, could of, should of" at this point right? I urge anyone else reading this to try clearing APC cache if you have it installed.

druel’s picture

If you are using Git, or some other form of version control, and you push to a remote repo, make sure to add all the files introduced by Drupal 7.63. To resolve the Typo3 drush error, you would need to add and commit /includes/file.phar.inc and /misc/typo3/* before pushing the update to a remote repo. Otherwise your local site would be working fine, but the remote would give you Drush errors because of the missing files.

chowdah’s picture

Quick question on this... Are you sure that the permissions you set up are read/writable by both the user using drush AND your webserver? That may be a place to look

Actually it was the other way around. I use Boost that creates a folder called 'normal' inside /cache. Sometimes when I clear the cache with Drush, it leaves empty folders in the normal folder. I usually clear the 'normal' folder by

cd cache/normal
rm -rf *

Somehow I deleted the whole 'normal' folder accidentally, so I recreated it not realizing I was logged in as root instead of the user. Using ui to clear cache was resulting in 403 errors because of this, but all was good on the ui end after I changed permissions/ownership to the correct settings.

This is totally starting to sound like APC cache to me... I wonder if a simple restart after your permission changes wouldn't have also handled this, but "would of, could of, should of" at this point right? I urge anyone else reading this to try clearing APC cache if you have it installed.

I had considered that to be a problem, but I was using opcache after abandoning APC when I upgraded the site from D6 to D7. I made a file called opcache_flush.php, and inserted the following code:

<?php
if (opcache_reset()){echo "opcache flushed!";}else{echo "opcache_reset FAIL!";}
?>

To flush the cache I just call the page in a browser. I did this step early on when I was getting errors.

sajiniantony’s picture

Upgraded to 8.6.7 successfully in dev environment. But after committing files to another instance shows Fatal error: Class 'TYPO3\PharStreamWrapper\Behavior' not found in /opt/web/core/lib/Drupal/Core/DrupalKernel.php on line 484

bgronek’s picture

I just encountered this issue as well. What seems to be happening for me is that I've been using the Intellij / PHPStorm git tools to manage updates. These tools will automatically exclude any new libraries in the vendor directory causing this issue.

This was fixed by running a command line git add --all from the git root ensures that these libraries are added to the repository and make it into the repo.

neuewerte’s picture

We had an old global installed drush version on the dev server (6.7.0), when calling this instead of the local project drush (version 8.1.18) this error does no longer come up. Will check if scripts are working as expected until a final fix is found.

igel’s picture

Upgraded to 8.6.8 successfully in dev environment. But after committing files to another instance shows Fatal error: Error: Class 'TYPO3\PharStreamWrapper\Behavior' not found in {{server_path}}/core/lib/Drupal/Core/DrupalKernel.php on line 484

hkirsman’s picture

As stated above in #96, I got rid of the error also when removing memcached from my Lando configuration.

I have Lando rc1 installed and the configuration disabled is:

services:
  memcached:
    type: memcached
    mem: 256
juankvillegas’s picture

I administer 2 different servers with a lot of production websites each one.

The first one uses memcache and after renaming and creating the symbolink link for drush.phar it allowed me to update all the websites (Drupal 7 and Drupal 8) without problem, and drush still works on all of them after the upgrade.

The second server doesn't have memcache, and even renaming and creating the symbolic link for drush.phar (that fixed the issue in the first server) didn't fix the problem and I had to upgrade all the websites (Drupal 7 and Drupal 8) "manually"... and now I can't use drush to administer any of those websites.

generalredneck’s picture

We probably should revisit this issue and consolidate the reports into the description... Have a reset so to speak.

The problem we are having is there are a bunch of symptoms with fragmented steps to reproduce but no narrowed down "cause". For the drush cache incident I reported having, there is a workaround and I feel that's the "Valid fix"... kill your drush cache...

We then have the Hitby and others have been having which also seem to be drush related as they can fix it using composer based drush.

Then we have cache stored in Memcache that seems to be causing grief, which again, is a problem with caching not being cleared enough.

I'm looking for an "action" to take here, whether it be "lets document the things" or debug to make a code fix.

Anonymous’s picture

Encountered [Tue Feb 05 13:33:02.059828 2019] [php7:notice] [pid 25701] [client 10.197.254.1:40392] Error: Class 'TYPO3\\PharStreamWrapper\\Behavior' not found in /var/www/html/drupal/core/lib/Drupal/Core/DrupalKernel.php on line 484 #0 /var/www/html/drupal/core/lib/Drupal/Core/DrupalKernel.php(692): Drupal\\Core\\DrupalKernel->boot()\n#1 /var/www/html/drupal/index.php(19): Drupal\\Core\\DrupalKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))\n
When updating from 8.6.5 to 8.6.6, 8.6.7 and 8.6.8. Always returned to working 8.6.5 before trying another update.

We use the manual method to apply updates. Do not have drush installed. Site was not created with composer, but composer is used to require modules.

My Resolution:
- Renamed directory /var/www/html/drupal/vendor/typo3
- Ran "sudo composer update –prefer-source vendor/typo3"
- Cleared composer cache
- Cleared Cache in site
- Ran Update.php
- Ran cron
Working

Package "vendor/typo3" listed for update is not installed. Ignoring.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 8 updates, 0 removals
- Installing typo3/phar-stream-wrapper (v2.0.1): Cloning 0469d9fefa
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
- Updating drupal/admin_toolbar (1.24.0 => 1.26.0): Downloading (100%)
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
- Updating drupal/matomo (1.7.0 => 1.9.0): Downloading (100%)
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
- Updating drupal/webform (5.0.0-rc26 => 5.1.0): Downloading (100%)
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
- Updating robrichards/xmlseclibs (3.0.2 => 3.0.3): Downloading (100%)
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
- Updating simplesamlphp/saml2 (v3.2.2 => v3.2.6): Downloading (100%)
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
- Updating twig/extensions (v1.5.2 => v1.5.4): Downloading (100%)
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
- Updating gettext/languages (2.4.0 => 2.5.0): Downloading (100%)
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
- Updating simplesamlphp/simplesamlphp (1.16.2 => 1.16.3): Downloading (100%)
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
Writing lock file
Generating autoload files
> Drupal\Core\Composer\Composer::preAutoloadDump
> Drupal\Core\Composer\Composer::ensureHtaccess

bleen’s picture

The issue description suggests using Drush 9 .... I have tried this but still have the issue. (In the code snippet above I was attempting the rename drush to drush.phar trick, but that didnt work either)

... just upgraded to 8.6.9 locally. This issue only occurs once I pushed the code to prod and tried to run updb

$ drush --version
Drush Commandline Tool 9.3.0
alexross at henrico in ~/sites/ps267.org/web on master
$ mv /home/alexross/.composer/vendor/bin/drush /home/alexross/.composer/vendor/bin/drush.phar
alexross at henrico in ~/sites/ps267.org/web on master
$ /home/alexross/.composer/vendor/bin/drush.phar updb -y
PHP Fatal error:  Class 'TYPO3\PharStreamWrapper\Behavior' not found in /home/alexross/sites/ps267.org/web/core/lib/Drupal/Core/DrupalKernel.php on line 484
 [error]  Drush command terminated abnormally due to an unrecoverable error.
Error: Class 'TYPO3\PharStreamWrapper\Behavior' not found in /home/alexross/sites/ps267.org/web/core/lib/Drupal/Core/DrupalKernel.php, line 484
alexross at henrico in ~/sites/ps267.org/web on master
$ mv /home/alexross/.composer/vendor/bin/drush.phar /home/alexross/.composer/vendor/bin/drush

reverting the code back to its previous state (8.6.3) fixed the issue so the site wasn't broken but Im otherwise stuck on updating to 8.6.9

plach’s picture

FileSize
3.01 KB

I'm able to reproduce this consistently on 7.63 with the following STR:

cd ~/Downloads
wget https://github.com/drush-ops/drush/releases/download/8.1.18/drush.phar
mv drush.phar /path/to/bin/drush-phar
drush-phar ev "drupal_register_shutdown_function(function () { watchdog('foo', 'bar'); })"

I doubt this is exactly the same issue folks are reporting, since I only get the exception with that specific command, but maybe the root cause is the same. In my case the problem is that the first usable backtrace item is a script outside of the drush PHAR, so the check in \Drupal\Core\Security\PharExtensionInterceptor::baseFileContainsPharExtension(), line 72 fails.

So far, the only fix I found was to rename back drush-phar to drush.phar.

d0t101101’s picture

This is what finally fixed it for me, running Drush 8 / Drupal 7.64 / PHP 7.2:

# wget https://github.com/drush-ops/drush/releases/download/8.1.18/drush.phar
# chmod +x drush.phar
# sudo mv drush.phar /usr/local/bin/drush.phar
# ln -s /usr/local/bin/drush.phar /usr/local/bin/drush
# cd ~
# drush cc drush
ayduns’s picture

Stepping through the suggested fixes:
1) was already using 8.1.18
2) & 3) no difference
4) drush cc drush - this worked for me. Subsequent drush cc all then worked but previously had been giving the reported error.

zeezhao’s picture

Following #122 did not work for me. But I am now getting a different error:

drush up --security-only
Command pm-update needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this     [error]
command.
The drush command 'up' could not be executed.  [error]

Fatal error: Call to undefined function cache_get() in ..../includes/module.inc on line 762
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: Call to undefined function cache_get() in ..../includes/module.inc, line 762

I had to manually upgrade from drupal 7.63 to 7.65 by copying files across.
Running php 5.5.30 & mysql 5.6.41. Still gives same error after upgrade.
Mysql is in the PATH so this is not the issue.
Please has anyone got any more suggestions? Thanks.

neilmc’s picture

Was running into the following error when running any drush command.
PHP Fatal error: Uncaught TYPO3\PharStreamWrapper\Exception: Unexpected file extension in "phar:///usr/bin/drush/commands/core/drupal" in /esource/html/misc/typo3/drupal-security/PharExtensionInterceptor.php:38

My setup is:
PHP 7.2.16
Drush 8.2.3
Drupal 7.6.5
Centos 7

I fixed this issue by installing memecached and php-memcached.

Hope this helps!

mikeocana’s picture

Upgrading to Drush version : 8.1.18 works for me.

Hope will help

tormi’s picture

I have memcached service defined and previous temp solution was to disable it.

But seems like upgrading Drush indeed does the trick. I am using Lando where 8.1.18 is the default Drush version, upgraded to latest 8.2.*:

.lando.yml:

config:
  drush: ^8
ultrabob’s picture

With a setup like the original poster where my drush command is aliased to the drush command sudo's as the apache user. I needed to clear the drush cache as the apache user to see the effects of these debugging steps:

1) make sure I'm not in a document root for a drupal site (I don't know if this matters or not)
2) sudo -u www-data /usr/local/bin/drush.phar cc drush

I'll have to wait and see if this clears up the issues I was having with the error showing up on all my cron runs, but it was appearing whenever I ran drush as the apache user, and it doesn't anymore. I hope that helps someone like me who is aliasing drush to another user.

MustangGB’s picture

On D7.67 (coming from pre-D7.63) got the cache_get() error in module.inc, hacked in a cache.inc require, and it spat out a Error: Class 'finfo' not found.

So for me it seems to have stemmed from using a minimal PHP7 install that doesn't include PECL fileinfo by default (Alpine Linux).
Resolved with a sudo apk add php7-fileinfo.

Hopefully that helps someone else out (probably a future me at the very least).

ioannis.cherouvim’s picture

I have require_once 'httpful.phar'; in a custom module (phar is downloaded from http://phphttpclient.com/#install and is local to the module which does the require_once) and simply executing drush status fails with:

> Unexpected file extension in "phar://httpful.phar/Httpful/Bootstrap.php"

It fails because PharExtensionInterceptor#assert is called with $path phar://httpful.phar/Httpful/Bootstrap.php and $this->baseFileContainsPharExtension returns FALSE for that path. And that happens because Helper#determineBaseFile tokenizes the above path to:

  • httpful.phar/Httpful/Bootstrap.php
  • httpful.phar/Httpful
  • httpful.phar

but for all 3 cases @is_file returns FALSE. Shouldn't it return TRUE for the last case since httpful.phar indeed exists on the same file location as my module?

Note that even if I require the absolute path like require_once '/var/www/html/sites/all/modules/custom/example/httpful.phar'; then the resolved path is still phar://httpful.phar/Httpful/Bootstrap.php and not something like phar:///var/www/html/sites/all/modules/custom/example/httpful.phar/Httpful/Bootstrap.php which I think would solve the problem.

zweishar’s picture

The solution provided by @tormi in #127 worked for me as well.

Moving from Drush 8.1.17 -> 8.2.3 has everything work as expected.

Asome’s picture

The solution provided by @MustangGB worked for me, thank you

bserem’s picture

Status: Needs review » Reviewed & tested by the community

The only thing that allowed drush to run, on a shared server I had issues with, was the patch by alexpott in #20.

I will change this to reviewed, only to attract some attention. Feel free to revert the status.

juampynr’s picture

Using Drupal 7.69, I managed to overcome this issue by installing Drush 8 via composer instead of by downloading from the Releases page. Here is a diff from the change that I did at CircleCI:

--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -20,12 +20,17 @@ jobs:
     <<: *defaults
     steps:
       - checkout
+      - run:
+          name: Install Composer
+          command: |
+            wget https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer -O - -q | php -- --quiet
+            mv composer.phar /usr/local/bin/composer
+            composer --version
       - run:
           name: Install Drush
           command: |
-            wget -O drush.phar https://github.com/drush-ops/drush/releases/download/8.1.17/drush.phar
-            chmod +x drush.phar
-            sudo mv drush.phar /usr/local/bin/drush
+            composer --no-ansi global require drush/drush:8.1.17
+            ln -sf ~/.composer/vendor/bin/drush /usr/local/bin/drush
       - run:
           name: Install libraries
           command: |
tyler.frankenstein’s picture

Upgrading drush to 8.3.3 worked for me in D7.

Version: 7.63 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

mikeocana’s picture

I encountered the same issue.

Environment info:
PHP 7.2.25
Drush 8.3.3
Drupal 7.72

Worked for me :

cd /usr/local/bin
mv drush drush.phar
ln -s drush.phar drush
rm -rf ~/.drush/cache
cd /app/docroot
drush @none cache-clear drush

mikeocana’s picture

I encountered this again with the same issue after upgraded to PHP 7.3.18.

Environment info:
PHP 7.3.18
Drush 8.3.3
Drupal 7.72

Worked for me :

cd /usr/local/bin
mv drush drush.phar
ln -s drush.phar drush
rm -rf ~/.drush/cache
cd /app/docroot
drush @none cache-clear drush

Anybody’s picture

Just ran into this problem on a Drupal 7.77 page with latest drush 8 version as drush.phar, PHP 5.4.27 and only #20 was able to fix the problem indeed! How can we proceed?

./drush.phar --version
Drush Version : 8.4.5

Gastonia’s picture

Having the same issue. Here is my situation, which is related to this SO thread

https://stackoverflow.com/questions/67788318/why-despite-drush-being-ins...

Using composer, I was able to install my version of Drush, 8.3.3, everything was working fine. Then, per that thread above, I needed PHP exec() to run a drush migration after a file upload. That script is ran as www-data instead of root. Try as I might, I could not get the composer installed version to be run under the www-data user (since it's technically a dummy account with no /home/ ).

The solution was to download the drush.phar file and install it manually. That's when everything fell apart.

Here is some environment info when I use composer-installed drush

drush status
 Drupal version                  :  7.78                                         
 Site URI                        :  http://default                               
 Database driver                 :  mysql                                        
 Database hostname               :  mysql                                        
 Database port                   :  3306                                         
 Database username               :  redacted                                         
 Database name                   :  redacted                                        
 Database                        :  Connected                                    
 Drupal bootstrap                :  Successful                                   
 Drupal user                     :                                               
 Default theme                   :  redacted                                        
 Administration theme            :  0                                            
 PHP executable                  :  /usr/local/bin/php                           
 PHP configuration               :                                               
 PHP OS                          :  Linux                                        
 Drush script                    :  /root/.composer/vendor/drush/drush/drush.php 
 Drush version                   :  8.1.16                                       
 Drush temp directory            :  /tmp                                         
 Drush configuration             :                                               
 Drush alias files               :                                               
 Install profile                 :  classic                                      
 Drupal root                     :  /var/www/html                                
 Drupal Settings File            :  sites/default/settings.php                   
 Site path                       :  sites/default                                
 File directory path             :  sites/default/files                          
 Private file directory path     :  ../private                                   
 Temporary file directory path   :  /tmp                                         


root@80e89038d742:/var/www/html# which php
/usr/local/bin/php
root@80e89038d742:/var/www/html# php -v
PHP 7.4.19 (cli) (built: May 12 2021 13:15:41) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.19, Copyright (c), by Zend Technologies

Here is the same when I use the drush.phar file. Note, it does NOT matter what drush 8.x version, even the one mentioned above with the supposed fix, 8.1.18:

drush status
 Drupal version                  :  7.78                       
 Site URI                        :  http://default             
 Database driver                 :  mysql                      
 Database hostname               :  mysql                      
 Database port                   :  3306                       
 Database username               :  redacted                       
 Database name                   :  redacted                      
 Database                        :  Connected                  
 Drupal bootstrap                :  Successful                 
 Drupal user                     :                             
 Default theme                   :  redacted                      
 Administration theme            :  0                          
 PHP configuration               :                             
 PHP OS                          :  Linux                      
 Drush script                    :  /usr/local/bin/drush       
 Drush version                   :  8.1.18                     
 Drush temp directory            :  /tmp                       
 Drush configuration             :                             
 Drush alias files               :                             
 Install profile                 :  classic                    
 Drupal root                     :  /var/www/html              
 Drupal Settings File            :  sites/default/settings.php 
 Site path                       :  sites/default              
 File directory path             :  sites/default/files        
 Private file directory path     :  ../private                 
 Temporary file directory path   :  /tmp                       


Fatal error: Uncaught TYPO3\PharStreamWrapper\Exception: Unexpected file extension in "phar:///usr/local/bin/drush/commands/core/drupal" in /var/www/html/misc/typo3/drupal-security/PharExtensionInterceptor.php:38
Stack trace:
#0 /var/www/html/misc/typo3/phar-stream-wrapper/src/Behavior.php(72): Drupal\Core\Security\PharExtensionInterceptor->assert('phar:///usr/loc...', 'url_stat')
#1 /var/www/html/misc/typo3/phar-stream-wrapper/src/Manager.php(115): TYPO3\PharStreamWrapper\Behavior->assert('phar:///usr/loc...', 'url_stat')
#2 /var/www/html/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php(419): TYPO3\PharStreamWrapper\Manager->assert('phar:///usr/loc...', 'url_stat')
#3 /var/www/html/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php(408): TYPO3\PharStreamWrapper\PharStreamWrapper->assert('phar:///usr/loc...', 'url_stat')
#4 [internal function]: TYPO3\PharStreamWrapper\PharStreamWrapper->url_stat('phar:///usr/loc...', 2)

For me, it also does not matter the Drupal 7.x version.

Which version of 9.x doesn't require a drupal site to be composer managed? I can try that version to see if it helps.

Let me know what other info I can provide.

mcdruid’s picture

Status: Reviewed & tested by the community » Needs review

The patch in #20 (which seems to be reversed) was marked as RTBC in #133 but I'm not sure if there's been much discussion / review of the patch since then other than a few +1's.

I've not had time to go through all the comments in detail but it's not clear to me whether #20 should be (reversed and) committed? It looks like perhaps it'd help in some cases but not all.

This issue was added to the list for the next D7 release at the 11th hour, but I'm afraid it's not looking like a "quick win" from the point of view of reviewing and committing.

Back to NR because of that.

mcdruid’s picture

As mentioned it looks like the patch alone may not fix all the issues people have encountered here, but #20 is in (/ from):

https://github.com/TYPO3/phar-stream-wrapper/blob/v3.1.3/src/PharStreamW...

...which is what D9 currently pulls in:

https://git.drupalcode.org/project/drupal/-/blob/9.3.0-beta3/core/compos...

A few people have said the patch did fix the problem for them, so I'm happy to commit it.

mcdruid’s picture

Status: Needs review » Fixed

Marking as fixed because the patch has been committed, and I'm not sure there's anything else D7 core can do.

It sounds like the patch hasn't been the only thing people have done to overcome this error; ensuring drush is up-to-date is likely a good idea.

There are other comments here that others may find helpful (I've added credit for a few of these but I'm afraid it's likely I've missed some), but I don't see any reason to keep the issue open.

  • mcdruid committed 87c12b1 on 7.x
    Issue #3026560 by alexpott, generalredneck, pbirk, plach, xjm, Hitby,...
generalredneck’s picture

Thanks for all the hard work on this one. I know it was elusive and a pain. It always feels good to have closure.

Wim Leers’s picture

This actually caused a regression for me:

PHP Fatal error:  Cannot redeclare TYPO3\PharStreamWrapper\PharStreamWrapper::stream_cast() in <SNIP>/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php on line 162
Fatal error: Cannot redeclare TYPO3\PharStreamWrapper\PharStreamWrapper::stream_cast() in <SNIP>/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php on line 162
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: Cannot redeclare
TYPO3\PharStreamWrapper\PharStreamWrapper::stream_cast() in
<SNIP>/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php,
line 162
Wim Leers’s picture

Status: Fixed » Active

Steps to reproduce:

rm -rf /tmp/d7head-drush8
mkdir /tmp/d7head-drush8
cd /tmp/d7head-drush8
curl -LO https://github.com/drush-ops/drush/releases/download/8.4.8/drush.phar
/usr/local/Cellar/php@7.4/7.4.25/bin/php ./drush.phar dl -y --drupal-project-rename=reproduce drupal-7.x
cd reproduce && php ../drush.phar si \
  -y \
  --sites-subdir=default \
  --db-url=sqlite://sites/default/files/db.sqlite \
  standard \
  install_configure_form.update_status_module='array(FALSE,FALSE)'

(The special PHP 7.4 sauce is just because Drush 8 does not support PHP 8.)

mcdruid’s picture

I'm very glad that @Wim Leers noticed this several days before the next release.

Turns out I have been an idiot and we now have PharStreamWrapper::stream_cast() twice.

It looks like a) this patch had already been committed? and b) we don't have very good test coverage of this class in D7.

First things first, I'll revert the commit.

  • mcdruid committed f94d2a4 on 7.x
    Revert "Issue #3026560 by alexpott, generalredneck, pbirk, plach, xjm,...
cilefen’s picture

mcdruid’s picture

Status: Active » Fixed

Thanks @cilefen and @Wim Leers, and others who reported this snafu.

I filed #3251373: Improve test coverage for TYPO3\PharStreamWrapper in D7 to improve (/ create) test coverage.

mcdruid’s picture

Status: Fixed » Needs review
FileSize
670 bytes

Actually, perhaps tests would have caught this but I didn't run them properly before commit (maybe partly because the patch was reversed?)

Totally my fault either way, but would be good to see if tests would have caught this if I'd actually tested the patch properly.

NR to test the patch (which is what was actually committed).

mcdruid’s picture

...and did I get totally the wrong end of the stick with the patch being reversed? Perhaps it was the removal of the method that was being proposed. That would probably make much more sense.

I'm glad there's time to clean up this mess before the release on 2021-12-01 :)

mcdruid’s picture

Status: Needs review » Fixed

Okay, so yes this was my fault; I think I misunderstood what the patch was doing and didn't test properly before commit.

I'll leave the other issue open to have closer look at what test coverage there is for the class at some point, but #153 shows that the testbot would have warned about this if I'd only asked :)

Thanks for catching my mistake quickly.

MustangGB’s picture

Status: Fixed » Needs review

Where was this fixed?

#20 hasn't been committed, and the stream_cast() function is still in head.

Not saying it needs to be, or should be committed, but fixed isn't the right status for "let's not do anything".

So putting back to "needs review" so someone can decide to either commit or won't fix.

DamienMcKenna’s picture

Following up again.

I ran into this after updating a D7 site from 7.82 to 7.83, and applying #20 did indeed resolve the problem. My Drush v8.4.8 install comes from inside a ddev 1.17.1 container.

stephencamilo’s picture

Status: Needs review » Closed (won't fix)
greggles’s picture

Status: Closed (won't fix) » Needs review
pminf’s picture

Today I got this error on drush locale:update which returned [warning] No configuration objects have been updated. I could workaround by

  1. Using composer provided drush directly via vendor/bin/drush instead of drush launcher.
  2. OR applying patch from the mentioned issue which turns the warning into a notice.

So for me it seems to fail if I'm using drush launcher AND a drush command is returning a warning.

My setup:

  • Drush Launcher Version: 0.10.1
  • Drush Commandline Tool 11.0.9
  • Drupal 9.4.0
solideogloria’s picture

I got this today on update to Drupal 9.4.0 as well. After running drush cim -y I saw this:

drush cim -y
[notice] There are no changes to import.
TYPO3\PharStreamWrapper\Exception: Unexpected file extension in "phar:///usr/local/bin/drush/.box/bin/core/modules/mysql/src/Driver/Database/mysql//Delete.php" in .../web/core/lib/Drupal/Core/Security/PharExtensionInterceptor.php:44
Stack trace:
#0 .../vendor/typo3/phar-stream-wrapper/src/Behavior.php(72): Drupal\Core\Security\PharExtensionInterceptor->assert()
#1 .../vendor/typo3/phar-stream-wrapper/src/Manager.php(110): TYPO3\PharStreamWrapper\Behavior->assert()
#2 .../vendor/typo3/phar-stream-wrapper/src/PharStreamWrapper.php(421): TYPO3\PharStreamWrapper\Manager->assert()
#3 .../vendor/typo3/phar-stream-wrapper/src/PharStreamWrapper.php(410): TYPO3\PharStreamWrapper\PharStreamWrapper->assert()
#4 phar:///usr/local/bin/drush/.box/vendor/composer/ClassLoader.php(571): TYPO3\PharStreamWrapper\PharStreamWrapper->url_stat()
#5 phar:///usr/local/bin/drush/.box/vendor/composer/ClassLoader.php(571): include()
#6 phar:///usr/local/bin/drush/.box/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile()
#7 [internal function]: Composer\Autoload\ClassLoader->loadClass()
#8 [internal function]: spl_autoload_call()
#9 .../web/core/lib/Drupal/Core/Database/Connection.php(1129): class_exists()
#10 .../web/core/lib/Drupal/Core/Database/Connection.php(1353): Drupal\Core\Database\Connection->getDriverClass()
#11 .../web/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php(168): Drupal\Core\Database\Connection->delete()
#12 .../web/core/includes/bootstrap.inc(734): Drupal\Core\Lock\DatabaseLockBackend->releaseAll()
#13 [internal function]: _drupal_shutdown_function()
#14 {main}

Looking at the path phar:///usr/local/bin/drush/.box/bin/core/modules/mysql/src/Driver/Database/mysql//Delete.php, it has the path to Drush (which is not a folder), followed by a path to Delete.php in the mysql module. However, there's an extra / in the path.

Running the drush cim -y command again did not have the error, nor did running other commands.

Drush Commandline Tool 11.0.9
Drupal 9.4.0

pminf’s picture

As it turned out in another deployment, the returned warning from #160 does not cause the error, because Drush failed again after locale:update even though there was only a notice.

PHP Fatal error:  Uncaught TYPO3\PharStreamWrapper\Exception: Unexpected fi  
  le extension in "phar:///usr/local/bin/drush/.box/bin/core/modules/mysql/sr  
  c/Driver/Database/mysql//Delete.php" in /var/www/html/web/cor  
  e/lib/Drupal/Core/Security/PharExtensionInterceptor.php:44  

Unfortunately this does break our deployment and we need to use Drush directly without the launcher :-/

szeidler’s picture

We're running into the same issue after updating to 9.4.0, except the local installation that initially performed the update. The error from above occurs "randomly" in approx. Every second `drush cim` fails with the error. The other ones seem to work fine.

solideogloria’s picture

Title: After upgrade to 7.63, 8.6.7, or 8.5.10 still get TYPO3 phar error for drush » After upgrade to 7.63, 8.5.10, 8.6.7, 9.4.0 get TYPO3 phar error for drush
Status: Needs review » Needs work

After looking at the previous comment, I tried again. I can confirm, I get the error every other time (every 2nd time) when I run drush cim -y. The off times work successfully.

Still, even when the error occurs, it doesn't prevent the command from working as expected, and it doesn't fail my CI/CD pipeline.

solideogloria’s picture

Version: 7.x-dev » 9.4.x-dev
webflo’s picture

This is related to how the autoloader is build. The autoloader should contain an absolute path. Drupal Core uses a relative path. This can be override via settings.php. Here is an example for mysql.

$databases['default']['default']['autoload'] = $app_root . '/core/modules/mysql/src/Driver/Database/mysql/';
webflo’s picture

Status: Needs work » Fixed

I have posted a core patch in #3291830: Fix PSR4 path for database driver

ollie-db’s picture

I had the same issue after updating to 9.4.1 from 9.3.15 and #166 helped.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

poker10’s picture

This was switched to 9.4.x-dev recently, but 7.x-dev part was not fixed at all, see #155, #156 and #157. I do not think this should be marked as fixed.

mcdruid’s picture

Status: Closed (fixed) » Needs review

Yeah what a confusing issue this now is.

We may still want to commit #20 to D7 (without reversing it this time).

Is there anything still outstanding for D9?