Problem/Motivation
In #2800605: Warn/inform users when the hosting environment has a too low limit of APCU cache we did not consider that ByteSizeMarkup::create returns a translated string representation of the size.
Steps to reproduce
- Need to make sure that PHP compile with APCu support and APCu cache was enabled
- If site has only English language, needs to add another language, Russian or example.
- Needs to set non-English language to admin user and go to site Status Report
Proposed resolution
Force set English for ByteSizeMarkup::create function
Result
Before patch:

After patch:

| Comment | File | Size | Author |
|---|---|---|---|
| #51 | 2024-07-13_15-04_1.png | 20.3 KB | ivnish |
| #51 | 2024-07-13_15-04.png | 33.99 KB | ivnish |
Issue fork drupal-3142928
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:
Comments
Comment #2
chi commentedComment #3
chi commentedComment #4
andypostComment #5
andypostAs no way to factor/mock this setting
Comment #6
andypostNeeds steps to test
Comment #7
apolitsin commentedI still have this problem after applying the patch. on status report page `/admin/reports/status`
... Drupal can run with a 32 МБ APCu limit. However, a 32 MB APCu limit (the default) or above ...
* 33554312 = [$memory_info['seg_size'] (default php7.+ = value 32M)
* 33554432 = Bytes::toInt($apcu_recommended_size)
We need to add another `120 bytes` somewhere.
it fixes the problem, but maybe the real reasons maybe should be found in `Bytes::toInt()`?
Comment #8
chi commentedRe #7. That's a different issue not related to localization.
Comment #9
keha3912 commentedThe problem is still not resolved
Drupal 9.0.7
Comment #10
chi commented@keha3913 did you try the patch?
Comment #11
keha3912 commented@Chi, I tried it now - patch really works
$ composer update drupal/system
Gathering patches for root package.
Removing package drupal/core so that it can be re-installed and re-patched.
- Removing drupal/core (9.0.7)
Deleting web/core - deleted
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
- Installing drupal/core (9.0.7): Loading from cache
- Applying patches for drupal/core
https://www.drupal.org/files/issues/2020-05-26/apcu-memory-report-314292... (Status report wrongly warns of APCu memory limit when admin language is not English)
$ grep apcu_recommended core/modules/system/system.install
$apcu_recommended_size = '32 MB';
if ($memory_info['seg_size'] < Bytes::toInt($apcu_recommended_size)) {
'@apcu_default_size' => $apcu_recommended_size,
Comment #12
keha3912 commentedDrupal 9.1.0 - patch doesn't work
$ composer update drupal/system
Gathering patches for root package.
Removing package drupal/core so that it can be re-installed and re-patched.
- Removing drupal/core (9.1.0)
Deleting web/core - deleted
Loading composer repositories with package information
Package "drupal/system" listed for update is not locked.
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
- Installing drupal/core (9.1.0): Extracting archive
- Applying patches for drupal/core
https://www.drupal.org/files/issues/2020-05-26/apcu-memory-report-314292... (Status report wrongly warns of APCu memory limit when admin language is not English)
Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2020-05-26/apcu-memory-report-314292...
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Package doctrine/reflection is abandoned, you should avoid using it. Use roave/better-reflection instead.
Generating autoload files
42 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Scaffolding files for drupal/core:
[RuntimeException]
Could not delete /var/www/html/web/sites/default/default.services.yml:
update [--with WITH] [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-install] [--no-autoloader] [--no-scripts] [--no-suggest] [--no-progress] [-w|--with-dependencies] [-W|--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [
]...
Comment #14
neclimdulconflict was with #3142934: Replace \Drupal\Component\Utility\Bytes::toInt() with \Drupal\Component\Utility\Bytes::toNumber() due to return type which just changed the name of the bytes helper method. Resolving the conflict should be trivial.
Concept looks correct though, don't rely on parsing the translated bytes value.
Comment #17
mitrpaka commentedUpdated patch file included for use with composer.
MR: https://git.drupalcode.org/project/drupal/-/merge_requests/670
Comment #18
batkorComment #19
andypostIt should be fixed in 9.3 first
Comment #21
tsotoodeh commentedHi everyone
Here is to report that the issue was detected with Drupal version 9.3.0. Here is the error:
Seems that there is a localization issue since the error is not displayed in the default language. Thanks to the idea provided in #7 the issue was resolved. Hope the core development teams look into this issue and fix it at the core level.
Comment #23
rajandro commentedI have tried to reproduce this issue locally using 9.3.x, 9.4.x, and 9.5.x. For all the versions it's working as expected, i.e. when the
apc.shm_sizeis less than 32MB it's showing the warnings and when it's greater than 32MB, there are no such warnings!NOTE: I have tried using MAMP (apache+mysql) and tried Spanish and French Languages along with/without English.
Comment #24
rajandro commentedAttaching the screenshot for 64MB and 14M messages and warning.
Comment #25
Wiktor7 commentedI solved my problem with this code:
core/modules/system/system.install
395 - $apcu_actual_size = format_size($memory_info['seg_size']);
395 + $apcu_actual_size = format_size($memory_info['seg_size'],'en');
Who can please make these changes in Drupal.
Comment #26
mdranove commented@wiktor7
Attached is a patch with the changes you suggested
Comment #27
neclimdulThe correct fix is already in the merge request. That change breaks localization.
Comment #28
ivnishPatch from MR works (Drupal 9.4) but string number is incorrect for Drupal 9.4. Needs reroll?
Comment #30
Wiktor7 commentedComment #31
smustgrave commentedThis will need tests to show the test.
Also was previously tagged for IS update.
Did not test the issue.
Comment #32
chi commentedSee note #5.
Comment #33
smustgrave commentedMissed that.
Comment #35
Wiktor7 commentedDrupal 9.5.10
Comment #37
Wiktor7 commentedDrupal 10.2.0
Comment #40
alayham commentedTo see this issue on a multilingual site, the string
@size MBmust be localized.My solution fixes the issue while respecting the user language, however, I think the best solution is to make the byte comparison work correctly when comparing two byte representations in two different languages, or to just compare the byte size as numbers, not as strings.
Comment #41
neclimdul@alayham Yeah, the suggestion all along has been to avoid any localization and compare number/byte sizes directly.
https://git.drupalcode.org/project/drupal/-/merge_requests/670/diffs#not...
This was only in needs work because it doesn't have tests which is still true.
Comment #45
ivnishI have same problem as #7
$apcu_actual_size = ByteSizeMarkup::create($memory_info['seg_size'], 'en');doesn't help
if ($memory_info['seg_size'] < Bytes::toNumber($apcu_recommended_size))doesn't help too
Comment #46
bolaghi commentedhi.
this patch work for me in drupal 10.2.7:
status-report-apcu-3142928.patch
go to /core/modules/system/
then edit system.install
in line 427 remove
$apcu_actual_size = ByteSizeMarkup::create($memory_info['seg_size']);
replace with
$apcu_actual_size = ByteSizeMarkup::create($memory_info['seg_size'], 'en');
Comment #47
catchPer #5 this isn't going to be testable in a useful way - we can't fake the apcu memory limit for system_requirements(). Also think this is a good example where the new policy on https://www.drupal.org/about/core/policies/core-change-policies/core-gat... should apply.
Comment #48
smustgrave commentedCan the issue summary be updated with least proposed solution and before/after screenshots.
Also the 1 MR still visible is for 9.1.x and still a number of patches so not sure which is to be reviewed.
Comment #51
ivnishComment #52
smustgrave commentedCan the issue summary be updated to include steps to reproduce the problem and ultimately what the proposed solution is.
Comment #53
ivnishComment #54
smustgrave commentedbtw that after screenshot is that the wrong item?
Comment #55
catchOne comment on the MR.
Comment #56
ivnishComment #57
ivnishsmustgrave, after screenshot doesn't have wrong warning about cache size
Comment #58
hetal.solankiComment #59
catchLatest change in the MR looks good, but probably needs one more round of manual testing?
Comment #60
krakenbite commentedI have the same problem. MR works for me
Comment #61
alexpottCommitted and pushed 37d8ea5cb4 to 11.x and e1902fee88 to 11.0.x and eeca1aec09 to 10.4.x and 2664526bdb to 10.3.x. Thanks!
Comment #62
alexpottComment #67
andypostThanks you a lot!
Comment #68
neclimdulOh wow, this is an old one. Thanks!
Comment #69
nikit commentedJust for info:
If php.ini: apc.shm_size=32M
https://github.com/krakjoe/apcu/blob/v5.1.23/apc_sma.c#L565
seg_size = = 33554312b, not 33554432b (32M) - 120 bytes difference in my server.
so
$apcu_recommended_size = '32 MB';in system.install isn't exact value for comparing.Comment #70
andypost@Nikit nice details, thank you!
Comment #71
taran2lthis requires a follow-up, as now there is a warning with comparing 32 Mb to 32 MB (and the reason is described by @Nikit )
PHP APCu caching
Enabled (32 MB)
Depending on your configuration, Drupal can run with a 32 MB APCu limit. However, a 32 MB APCu limit (the default) or above is recommended, especially if your site uses additional custom or contributed modules.
Comment #72
catchThe follow-up is here: #3466399: APCu requirement for 32M is checking wrong value