Upgrading from 8.6.4 to 8.6.6
Drush 8.1.18
PHP 7.2
Running drush up produces the following error:
The external command could not be executed due to an application error. [error]
The command could not be executed successfully (returned: PHP Fatal error: Uncaught TYPO3\PharStreamWrapper\Exception: [error]
Unexpected file extension in "phar:///usr/local/bin/drush/includes/.." in
/var/www/drupal/core/lib/Drupal/Core/Security/PharExtensionInterceptor.php:39
Stack trace:
#0 /var/www/drupal/vendor/typo3/phar-stream-wrapper/src/Behavior.php(72):
Drupal\Core\Security\PharExtensionInterceptor->assert('phar:///usr/loc...', 'url_stat')
#1 /var/www/drupal/vendor/typo3/phar-stream-wrapper/src/Manager.php(83):
TYPO3\PharStreamWrapper\Behavior->assert('phar:///usr/loc...', 'url_stat')
#2 /var/www/drupal/vendor/typo3/phar-stream-wrapper/src/PharStreamWrapper.php(412):
TYPO3\PharStreamWrapper\Manager->assert('phar:///usr/loc...', 'url_stat')
#3 /var/www/drupal/vendor/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 in
/var/www/drupal/core/lib/Drupal/Core/Security/PharExtensionInterceptor.php on line 39
, code: 255)
pm-updatestatus failed.
Note that the update goes through. However, any subsequent commands made with drush display the error above and exit.
Comments
Comment #2
ecvandenberg commentedSame here on a Drupal 7.61 > 7.62 update with Drush 8.1.15 on PHP 5.6.39.
Site seems OK.
Comment #3
xjmThanks for the report!
Comment #4
xjmComment #5
kferencz91 commentedExperiencing the same issue. Drush 8.1.16. Running drush pm-update drupal as the command. Site appears to update and displays 7.62 as the version. However, subsequent drush update commands return errors and do not execute.
Comment #6
ttnt commentedUsing drush 8.1.15, drush up drupal throws the same error for me both when updating 7.6 to 7.62 and 8.6.2 to 8.6.6.
The update seems to go through fine and the version seems updated.
Comment #7
littlepixiez commentedRan into the same issue with 3 Drupal 7 sites. Drush version: 8.1.16. PHP version 7.2. All update fine regardless - core shows 7.62 as expected and files match the tar.
Drush is still happy with some commands, unless I run "drush up" again (I ran drush up --security-only) and I can no longer update any other modules pending updates.
Comment #8
nickgee commentedhaving the same issue but with manual update :|
Comment #9
gregglesAdjusting title based on #8.
Comment #10
cilefen commentedComment #11
emerham commentedMy sites running in Acquia Cloud, (PHP 7.1, Drush 8.1.17, Drupal 7.62) are not having these issues reported from the TYP03 Library. I am able to flush caches, run database updates as well as jump into the SQL terminal with drush. I do not download modules with drush in Acquia so I am unable to test that functionality.
Comment #12
tim_djI've updated two Drupal 7 sites in different vagrant instances. The one running PHP 7.2.10 gives this error. One old vagrant instance running PHP 7.0.32 doesn't.
Comment #13
xjm@tim_dj Those two PHP versions should not behave differently WRT the error for that reason alone. Are there other differences (like the version of Drush in use or how Drush was installed)?
Comment #14
greg.1.anderson commentedI'm aware of this issue and will be looking at it shortly.
Comment #15
alexpottA potential work around here is rename your drush CLI command back to drush.phar and use that to execute commands. Can someone try that and let people know if that works. I'm trying to re-create the problem locally for me.
Comment #16
tim_dj@xjm Just trying to figure out differences. Will try to update drush to see if that changes anything
PHP 7.2.10 + Drush 8.1.10 = Error
PHP 7.0.32 + Drush 8.2-dev = No error
Comment #17
benjifisherIf the errors are from running update functions (or post-update functions) then a work-around should be (please test!) upgrading to Drupal 8.6.5 (or 8.5.7), running the (post) update functions, and then upgrading to 8.6.6.
I do not see any (post) update functions added between 8.6.5 and 8.6.6.
Anyone care to test?
Comment #18
floown commentedI have the same fatal error on a Drupal 7 latest. The drush8 updatedb is ok, et drush8 cc all && drush8 hss node works too, but display at end of the process the same error. The site seems to be ok, I can navigate on it.
Drush 8.1.17 and php7.2
Comment #19
dsnopekHere's a Drupal 8 patch that works for me.
The underlying problem is that we're expecting the last frame from `debug_backtrace()` to go all the way up to the drush script, but in some situations it doesn't. I don't totally understand why it doesn't, but this patch will work so long as the last frame with a file is coming out of the Drush phar. I suppose there could be situations where that isn't true either?
Comment #20
samuel.mortensonSmall tweak to prevent infinite loops.
EDIT: Interdiff is backwards, oops!
Comment #21
dsnopekHere's a D7 version of the patch from #20 for manual testing.
Comment #22
alexpottThe reason it doesn't is because the execution is taking place in shutdown function... so the top caller is drush_shutdown but registered shutdown functions seem to be pseudo-anonymous and have no 'file' property in the backtrace.
Using Helper::determineBaseFile() here is smart. Nice one.
I've managed to reproduce this locally and it works for me and the code looks good. I think we should have a code comment that says why we're looping.
Something like
// Find the last entry in the backtrace containing a 'file' key as sometimes the last caller is executed outside the scope of a file. For example, this occurs with shutdown functions.Comment #23
ydahi#21 works for me. Drupal 7.62 Drush 8.1.18. Applied manually.
Comment #24
kferencz91 commentedD7 patch in #21 works for me. Drush commands now run as expected with this patch applied.
Comment #25
littlepixiez commented#21 removes the "drush up" error for me on Drupal 7.62, Drush 8.1.16. Thank you! Worth mentioning this is only an issue for me whilst using Docksal in my local environment.
Comment #26
samuel.mortensonAdded comment from #22 and fixed PHPCS errors.
Comment #27
alexpottI've tested this locally and we have confirmation from others that this works so +1 for rtbc.
The need for tests has been discussed with @xjm and @samuel.mortenson in slack. I think that tests we be tricky as either we have to somehow invoke a phar with a shutdown function and test that or we have to pull the class apart and back it so we can inject a fake backtrace. So will file a follow-up to add tests.
Comment #28
alexpottMeant to rtbc this.
Comment #29
ydahi#26 also working fine. Drupal 8.6.6 Drush 8.1.18.
+1 rtbc
Thanks for the quick patch core devs!
Comment #30
moshe weitzman commentedPatch looks sane to me.
Comment #31
alexpottAdded the test follow-up #3026414: Add tests for PharExtensionInterceptor for invocation from a CLI command
Comment #32
dsnopekHere's a new D7 patch that matches the code from #26
Comment #33
cms_macgyver commented#26 works fine for me. Drupal 8.6.6 & Drush 8.1.12.
+1 rtbc
Comment #34
skin#26 is fine for me.
Drupal 8.6.6
Drush 8.1.18
PHP 7.2.10-0ubuntu0.18.04.1
Comment #35
xjmI'll be committing this once our automated test suite has finished on both D8 and D7 (I manually queued a D7 test). Once that's done, I'll create hotfix releases for all three branches that contain the fix.
Comment #36
xjm(I typed the wrong 8.5.x version number in the issue title.)
Comment #37
xjmAdding issue credit for sec team members who also helped with the Slack discussion with site owners affected.
Comment #38
floown commentedWhen I try to apply the patch #26 in my Drupal 7 root, I have this message:
What's wrong? ^^
Thanks
Comment #39
BryanGullan commentedHey @floown,
You’ve missed the - before the p1 argument, so it’s trying to patch a file called p1.
When using p1, it’s “patch -p1”
Comment #40
jlockhartThis doesn't appear to be limited to Drush. While it fixed one of my sites I'm still seeing the error on 2 others. In those cases its with the geoip module.
Warning: Uncaught TYPO3\PharStreamWrapper\Exception: Unexpected file extension in "phar://geoip2.phar/vendor/autoload.php"I've applied the patch from #32 for a Drupal 7, PHP 7.1
Comment #41
ydahi@floown check your command, should be:
patch -p1 < drupal-3026386-30-D7-do-not-test.patchRefer to the Applying Patches documentation for more info. Or wait for the hotfix.
Comment #42
emerham commentedI've Applied the patch and running drush cc all against my drupal 7 site I still get the error
Now I have my drush.phar renamed as drush, if I use the suggestion from above about renaming it back to drush.phar then created a symlink drush -> drush.phar then everything works as expected.
Drush 8.1.18
Drupal 7.62
PHP 7.2
Comment #43
xjmComment #44
samuel.mortenson@jlockhart We may need to open a new issue about this, but where is
geoip2.pharlocated in your codebase and how is it being included? This error is likely becausegeoip2.pharcan't be found - either because it's being included in a relative path (which means we need to update the patch or do a follow up), or it actually doesn't exist on those sites.Comment #45
fabianx commentedIn theory this is only compatible with PHP 5.3.6 - so the extension will only work without a notice with 5.3.6 not 5.3.0.
Just a quick note -- as I saw this just now:
5.3.3 will give back:
"Notice: Use of undefined constant DEBUG_BACKTRACE_IGNORE_ARGS - assumed 'DEBUG_BACKTRACE_IGNORE_ARGS'"
it will then use TRUE as parameter, which will provide all objects.
In theory it should all still work - I think the worst that can happen is that it runs out of memory.
This looks good to me.
This is official sign-off from me as Drupal 7 maintainer on this.
Comment #46
fabianx commentedUhm, the D7 test failed? How is that possible?
Comment #47
xjmIt failed because it's failing in HEAD. We're still trying to figure out why since it passed in all private test runs before release. But separate issue from this one (although ideally we should figure out what's going on with that before we commit this).
Comment #48
fabianx commentedHere is an idea for either fixing this here or for a normal follow-up:
- I think this only happens because we do not cache whitelisted paths to phar files that we already encountered
I think currently we run debug_backtrace() again and again, which might even be a slight performance regression for using drush with many includes from phar.
What is strange about the geoip issue is that it clearly has a .phar file extension so we should allow it -- unless I misunderstand something.
Comment #49
pbirk commented#32 resolves the error on my system:
drush 8.1.7 (global install)
Drupal 7.62
I'm also able to reproduce the error from #42 if I rename drush to drush.phar and run
drush.phar cc all. The error output is:Comment #50
samuel.mortenson@jlockhart I just installed a recent copy of D7, GeoIP, and configured GeoIP to use the phar copy of the library (by putting it in sites/all/libraries/GeoIP2-phar/geoip2.phar). Even without the newer patches, I'm not getting any errors, so I'm not sure what's up.
Comment #51
xjm(It could be a relative path thing? I.e., is Drupal symlinked, installed in a subdirectory, etc.)
I think we'll go ahead and release this without the geoip issue being addressed; we'll add it to the list of known issues for the release, but move it to a separate issue report from this one.
Comment #52
fabianx commentedRTBC for this issue:
We need three follow-ups:
- a) Fix the notice for PHP 5.3.0 - 5.3.5, likely move supported version for Wrapper to 5.3.6 [D7]
- b) Whitelist encountered paths to avoid re-running debug_backtrace() again and again [D8 + backport D7]
- c) Ensure that a phar:/// URL without a phar file in there is somehow supported (See comment: #49) [Library issue?]
Comment #53
samuel.mortensonFiled #3026443: \Drupal\Core\Security\PharExtensionInterceptor is incompatible with GeoIP and other libraries that use phar aliases or Phar::mapPhar() for GeoIP.
Comment #54
fabianx commentedFiled #3026444: [PP-1] Whitelist phar files encountered to avoid too frequent debug_backtrace() and #3026445: [D7] PHP 5.3.0-5.3.5 gives notice for debug_backtrace() call in PharWrapper as follow-ups
No idea yet for #49, but someone should file a bug with steps to reproduce (exact drush version download and renames)
Comment #55
cnelsonakgov commentedI'm seeing the same or similar problem. Upgrading from '8.6.5' to '8.6.6'. My upgrade method is to just checkout the '8.6.6' tag with git and then run the 'upgrade.php' script.
Error:
The only .phar file I'm aware of is:
./drupal-git/core/modules/simpletest/files/phar-1.pharCan't run the upgrade as the site throws a 500.
PHP Version: PHP 5.6.39-0+deb8u1
Comment #56
samuel.mortenson@cnelsonakgov If you're not using the Drupal tarballs and are just checking out new tags, you'll need to also run "composer install" to get the new TYPO3 library.
Comment #57
pandaski commentedCan we do something same as in the error utility class for easing the performance regression?
Comment #58
cnelsonakgov commented@samuel.mortenson Thanks for pointing me to that -- I had not used composer before. I see it in the INSTALL.txt file now but it doesn't look like it was a dependency for my installation until this release.
[Update]
Running composer to install the missing dependencies fixed it. Thank you!
Comment #59
xjmFor #57, I suggest discussing that in #3026444: [PP-1] Whitelist phar files encountered to avoid too frequent debug_backtrace(). Separate issue from the one in the title here that was introduced by the SA itself.
Updating issue credit.
Comment #60
alexpott#3026414: Add tests for PharExtensionInterceptor for invocation from a CLI command now has a test that covers this.
Comment #63
xjmThis was committed and released in 8.6.7, 8.5.10, and 7.63. Thanks everyone!
If you run into further issues with this, try the steps documented in the release notes or look at the known issues listed for your version. If you run into further problems not covered by the followup issues above, file a new issue. (You can add a comment here with any new issue links so that others can find it too.)
Comment #64
ressaI was also getting the
PHP Fatal error: Uncaught TYPO3 ...error after updating to Drupal 7.62 withdrush up. Updating to Drupal 7.63 withdrush up drupalhas fixed it. Big thanks to everyone for finding a solution, and rolling it out so quickly.Comment #65
generalredneckUpgraded 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...
Comment #66
generalredneckso, just for some extra stuff... 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
scldrush looks like
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?
Comment #67
xjmThanks @generalredneck, this sounds similar to the report from another user. Let's create a new issue to look into that further.
Retroactively promoting this to critical; not sure why I only set it to major before.
Comment #68
xjmNot an intentional status change.
Comment #69
HitbyHi,
I have updated to 7.63 on a couple of installs and I am still getting the exception 'TYPO3\PharStreamWrapper\Exception' with message 'Method stream_select() cannot be used' error.
I've renamed drush to drush.phar and ln -s drush.phar drush but I still get the error and can't use Drush. What have I missed please?
Comment #70
Alex Monaghan commentedAs #69 I'm seeing the same, server 1 updated fine, server 2 gives the same issues. Have pulled Drush 8.1.18 and still get the same issue, sites appear to be working OK though.
Comment #71
generalredneckCreated new issue as instructed.
https://www.drupal.org/project/drupal/issues/3026560
Comment #72
ydahiI think an issue people might be coming to this page with is upgrading from:
Drupal 7.62 -> 7.63
Drupal 8.6.6 -> 8.6.7
If you updated to 7.62 or 8.6.6 and want to update to the hotfix (7.63 and 8.6.7), you will run into the issues above (when using drush to update).
I had updated my sites to 7.62 and 8.6.6 shortly after the SA. The problem is that when I try to update to 7.63 and 8.6.7 using drush, I get the errors mentioned above and drush exits without updating.
My solution is to apply the patches provided above, then run `drush up` to bring in 7.63 and 8.6.7 like so:
Drupal 7
Drupal 8
Comment #73
generalredneckFor the record, I upgraded from 7.61 to 7.63 by the time I got to this client... the fix was already out.
Additionally your solution assumes we are upgrading using
drush up, where as with a git workflow or the like, the upgraded code is already on the server.Good catch though
Comment #74
HitbyI'm running in to the errors going straight up to 7.63 from other versions - 7.60 for instance.
Comment #75
Alex Monaghan commentedAs with the others, I went from 7.61 to 7.63 (or at least that's what Drush told me it was doing)
If it helps, I upgraded another site on this server to 6.49 and this also gives the same Drush error message, I don't have any D8 sites on this server.
Comment #76
ydahihave you tried patching with the above patches? also, silly question: can you confirm that d7.63 is in fact installed.
Comment #77
Hitby7.63 is installed, database updates and cache cleared through the browser but Drush is fubar'd. I went through the patches and the changes are all there (in 7.63)
Comment #78
Alex Monaghan commentedThe Status Report page shows 7.63, Drush st fails with undefined function cache_get() message
Comment #79
Alex Monaghan commentedRunning the patch advises previously applied, quick glance at the source seems to confirm it is correct version.
Comment #80
piridium commentedI fail to update Drupal with Composer. Current Drupal version 8.6.5.
composer update drupal/core --with-dependenciesInstalls Drupal Core 8.6.7 and typo3/phar-stream-wrapper (v2.0.1).
Drush seems to work fine, but the website reports:
The website was not originally installed with Composer, but recently converted with https://github.com/grasmash/composerize-drupal for Composer. The update to 8.6.5 went without problems afterwards.
Any advice?
Comment #81
gregglesHi 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!
Comment #82
alexpott@piridium that looks like missing code as it is not finding the class file. Perhaps you using very aggressive autoload caching and perhaps restarting the webserver will fix it? If that's not it then place to start is to check that the code is pushed to production (all webheads if you have mutliple) and also make sure that the autoloader got pushed up too. That's in vendor/composer
Comment #83
xjmCan we also please move the discussion to the followup issue as requested? This issue has already been committed. We need a new issue to explore what's still going on. Please discuss in #3026560: After upgrade to 7.63, 8.5.10, 8.6.7, 9.4.0 get TYPO3 phar error for drush.
Comment #84
damienmckennaComment #85
nchase commentedpatch in 32 and 26 works for me.
Comment #86
asb commentedThe security upgrade to drupal core 7.63 breaks 'drush up' permanently, even after doing the recommended 'drush cc [all]'.
Error message given:
So as it seems, this security update breaks the possibility to install any other security update through drush.
Environment: Debian 8, PHP 5.6.38-0+deb8u1, with "Typo3" never having been installed. Drush version 8.1.17.
Secondly and probably even worse, after running the update and
drush updb,./admin/reports/statusstill reports "Drupal 7.62".However,
./update.phpreports:But
./admin/reports/statuskeeps reporting:After manually downloading drupal core 7.63 from https://www.drupal.org/project/drupal/releases/7.63 and doing a "clear all caches", I get from 'status report':
Now running
./update.phpagain, no database updates are executed ("No pending updates").So as it seems, this security confuses version detection, and/or database schema somehow.
Running a manual check for updates through the web UI and then doing a
drush stfollowed bydrush upat the shell seems to bring things in order again. At least on this one site.Comment #87
alexpott@asb is it possible for you to either upgrade manually to 7.63.
There were no db updates in 7.62 so runningdrush upis only going to clear caches. Does it allow you to run drush pm-updatecode to update the code? Or are you stuck on 7.62? Note that drush up (run database updates) is not the same as drush pm-updatecode (updates core code).Edit: @asb I am sorry I'm wrong I got
upandupdbmixed up. Unfortunately you are going to have to manually update as per the next comment.Comment #88
alexpott@asb I just tested locally. Unfortunately if you are on 7.62 you will not be able to update to 7.63 using the same drush phar file. If you can copy the drush bin and name it drush.phar, make the new drush.phar executable and then run
./drush.phar upcit hopefully will get you to 7.63 where you old drush will start to work again.Comment #89
ydahiI had the same issue as @asb and was able to resolve it by patching with the patches provided in this issue thread. Refer to #72.
Comment #90
xjmAgain, this issue fixed some 90% of reports of problems with drush we had at he time. It has already been committed and released. If you are still experiencing issues with Drush after upgrading to Drupal 7.63, please read this issue and report your findings there: #3026560: After upgrade to 7.63, 8.5.10, 8.6.7, 9.4.0 get TYPO3 phar error for drush.
I'm going to close down comments on this issue now to make sure the discussion isn't fragmented between the hotfix here that was already done and the ongoing attempts to resolve the issues some folks are still having. Again, we welcome your help and feedback over in #3026560: After upgrade to 7.63, 8.5.10, 8.6.7, 9.4.0 get TYPO3 phar error for drush! That will help us solve the issue since many of us aren't able to replicate the problem ourselves.
Comment #91
xjm