Problem/Motivation
I am running Drupal 10.0.9 site and would like to upgrade. However it seems that from version 10.1 anything has changed and once I update site I am getting following error:
The website encountered an unexpected error. Please try again later.
Error: Call to undefined function Drupal\Component\Utility\gzcompress() in Drupal\Component\Utility\UrlHelper::compressQueryParameter() (line 87 of core/lib/Drupal/Component/Utility/UrlHelper.php).
Drupal\Component\Utility\UrlHelper::compressQueryParameter() (Line: 111)
Drupal\Core\Asset\CssCollectionOptimizerLazy->optimize() (Line: 167)
Drupal\Core\Asset\AssetResolver->getCssAssets() (Line: 318)
Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAssetLibraries() (Line: 164)
Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAttachments() (Line: 97)
Drupal\big_pipe\Render\BigPipeResponseAttachmentsProcessor->processAttachments() (Line: 72)
Drupal\Core\Render\BareHtmlPageRenderer->renderBarePage() (Line: 76)
Drupal\Core\ProxyClass\Render\BareHtmlPageRenderer->renderBarePage() (Line: 196)
Drupal\system\Controller\DbUpdateController->handle()
call_user_func_array() (Line: 115)
Drupal\Core\Update\UpdateKernel->handleRaw() (Line: 76)
Drupal\Core\Update\UpdateKernel->handle() (Line: 27)
I have tried to update to latest 10.2.5 with no luck so I tried 10.1.8 and finally I have tried with 10.1.0 and found out it all started with this version.
Anyone can help ? (I did not find anything related to this issue on google) and I also tried with a clean version of Drupal 10.1 with the same result so it is not module related.
My Config:
PHP:8.1.25
Apache/2.4.37
Mysql
Steps to reproduce
Install Drupal > 10.1 without the zlib extension
Proposed resolution
Add ext-zlib to composer require
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3439591
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3439591-11.0.x-zlib
compare
- 3439591-ext-zlib
changes, plain diff MR !7382
Comments
Comment #2
mstrelan commentedSeems your php version does not have the zlib extension installed.
Comment #3
mstrelan commentedActually this is a bug, because we don't explicitly declare a dependency on ext-zlib, but installing the extension should resolve this for you.
Comment #5
mstrelan commentedComment #6
coaston commentedHi mstrelan,
Thank you. However do i need to still install extension for php manually or this patch/merge can resolve the issue?
Comment #7
mstrelan commentedYeah you need to install it. The patch will just prevent people upgrading of they don't have it installed
Comment #8
longwaveAssetDumper has a check for zlib which we could remove if we are adding a dependency:
I guess almost everyone must have this extension installed or we would have had more reports along the lines of this one.
Comment #9
mstrelan commentedI guess if we add this in 10.2.x it will just mean folks without zlib will get stuck on 10.2.5 which will also be broken for them. So possibly we need a runtime check in 10.2.6 (or later) to handle it gracefully.
Comment #10
andypostbtw that's not that easy to build PHP with zlib extension as shared https://github.com/php/php-src/pull/4681
Comment #11
catchI think we can skip compression when zlip isn't available - it'll mean very long asset query strings but can't really be helped. And then open an 11.x issue to require zlib and remove the checks.
Comment #12
catchActually let's make this the 11.x issue, I'll open an 10.3.x one.
edit: Opened #3439647: Skip query string compression if zlib extension isn't available
Comment #13
catchNeeds work for #8.
Comment #15
pradhumanjain2311 commentedRemove zlib as per 8
Comment #16
andypostComment #17
mstrelan commentedThere's an open thread on the MR that I don't know the answer to. Also the build is failing so I obviously didn't follow the correct procedure to update composer.json.
Comment #18
mfbRequiring zlib doesn't seem like too big of an ask. But has me wondering - I guess there was some reason why it's better to pass all the asset data in long URLs, rather than just storing it persistently and looking it up via the asset file name when needed?
Comment #19
catch@mfb see #1014086: Stampedes and cold cache performance issues with css/js aggregation, #956186: Allow AJAX to use GET requests, #2368797: Optimize ajaxPageState to keep Drupal 8 sites fast on high-latency networks, prevent CSS/JS aggregation from taking down sites and use HTTP GET for AJAX requests and #3348789: Compress ajax_page_state for the history of the change (roughly in that order).
Comment #20
mfb@catch the part that confuses me is that asset data is both cached in the cache_data bin, and also sent to the browser in the long query string. I'd have thought one or the other would be sufficient. But, I didn't read thru all the related issues yet, I'm probably missing some basics.
Comment #22
quietone commentedI ran
COMPOSER_ROOT_VERSION=11.x-dev composer update drupal/coreto update the lock file. The command is part of this, https://www.drupal.org/about/core/policies/core-dependency-policies-and-...Comment #23
quietone commentedComment #24
catch@mfb the asset generation routes need to be able to independently and reliably generate an asset based on the information on the URL. It would be possible to store the information in in state or key/value so it can't be e.g. evicted from memcache, then only have the lookup key in the URL, but that then creates the potential for a database stampede after cache clears. There's also not a reliable way to know when any particular aggregate would be stale, so the amount of data stored could grow very large over time. The agrcache module in Drupal 7 did things this way, and I think advagg had something similar-ish, but they both had their own problems. The idea to encode the libraries in the URL was from about ten years ago, it took adding the core libraries API and various further optimisations to get there.
Obviously with the new core solution we've introduced different problems, but IMO they're lesser ones.
Comment #25
mfb@catch thanks for further explanation. It surprised me to see how many cache_data insert queries run on a cold cache: a "js:..." cache item is inserted during the page load, and further "js:..." and "route:..." cache items are inserted during asset load/generation. So that's why I was thinking the data in the URL could simply be persistently stored and queried rather than passed around. But yes, those cache sets would be a lot more lightweight with a non-database cache backend in place.
Comment #26
penyaskitoAFAIK if we remove the check from
AssetDumper,UrlHelper::compressQueryParameterandUrlHelper::uncompressQueryParameterwould need to be updated too.Comment #27
quietone commented@penyaskito, yes that needs to be done to.
I also grepped for zlib and found a few more things to change.
Comment #28
mstrelan commentedI think we need to add the dependency to
core/lib/Drupal/Component/Utility/composer.jsonso that can be used as a standalone library. Might be wrong though, so leaving NR.Comment #29
mfbI would suggest adding zlib to system_requirements() as well, because of various scenarios such as zlib extension could be disabled after the instance was installed, instance could be moved to an environment without zlib extension, etc.
Comment #30
andypost@mfb there's no reason to add it system_requirements because the extension is bundled into PHP and it's someones hacky attempt to build PHP with zlib as shared extension.
So it's a waste of CPU for no reason and slowdown for "not fast" page, even #28 suggestion does not make sense as no common way to get PHP without this extension even to make a test
Comment #31
andypostSee https://www.php.net/manual/en/extensions.membership.php#extensions.membe...
And my comment #10
Comment #32
andypostNo reason to waste time on the non-reproducible bug
Comment #33
mstrelan commentedThe page linked in #31 lists zlib in the same category as gd and PDO yet we explicitly list those in composer.json. Is zlib somehow different or can we drop all those too?
Comment #34
andypostYes, it means the extension must be available in distribution but I also pointed link in #10 that since PHP 8 there's no way to build PHP with zlib extension as shared (means it's a separate file and it can be disabled)
So if someone hacked PHP source for some reason - they probably know what they doing and core must not care about such hacky cases
Comment #35
longwaveI think this change is fine, it is explicit in Composer to try and prevent installs on weird environments and therefore we can remove the runtime checks as well.
Comment #36
catchYeah same here, but #34 is a good reason not to bother with a hook_requirements() entry, which means less to do here.
Comment #37
andypostI'm ++ to removal of useless
extension_loaded('zlib')but as the issue marked bug - it should change title/category or provide steps to reproduceComment #38
longwaveComment #39
mfb@andypost It's not true that the zlib extension is always bundled into PHP. On FreeBSD, for example, it is a separate package which is installed via
pkg install php83-zliband I'm sure some other distributions work in a similar way. I.e. each distro has its own definition of the PHP package and provides packages for the other extensions.Comment #40
andypost@mfb I mean it's supposed to be bundled but distro builders can change it with patches.
Moreover it looks weird what they're doing https://cgit.freebsd.org/ports/tree/archivers/php83-zlib/files/patch-zlib.c
So the same way you should require hash,PDO and other packages for no reason, just slowdown each composer install with dependencies for 0.5% of users
Comment #41
mfbPHP is designed to be configurable at compile time, so patches aren't necessarily needed. You can build with or without various extensions/libraries, whether for running in a memory-constrained environment or any other reason. On the one hand, I'd appreciate if PHP could be guaranteed to be built the same way, but on the other hand I can appreciate it being configurable..
Comment #42
quietone commentedComment #45
longwaveDiscussed with @quietone, in order to get the upcoming betas out today we need to commit these today, so committing from NR. Unfortunately we need different patches for each branch, I solved the issues in 11.x and 11.0.x but marking PTBP to get a 10.3.x and 10.4.x patch ready.
Committed 0a4f122 and pushed to 11.x. Thanks!
Committed b3a8376 and pushed to 11.0.x. Thanks!
Comment #46
longwaveComment #47
longwave@quietone reminded me this is major version only. #3439647: Skip query string compression if zlib extension isn't available works around the issue if zlib is not available, but we can still require it to make things simpler in 11.0.