From: ca at lsp dot net
Operating system: Windows 10
PHP version: 7.3.19
Package: opcache
Bug Type: Bug
Bug description:Strings missing last character (Apache + OPcache)
Description:
------------
I observed a very strange behaviour in combination with Apache + OPcache
today.
My colleague was using the test instance of our PHP application this
morning (no deployment since yesterday), and it was working fine, until
suddenly the following error appeared (and didn't disappear anymore):
```
Error: Uncaught --> Smarty: Plugin 'cut_hea' not callable
```
The string "cut_hea" doesn't exist in our code base, but instead comes
from a class constant string array containing the element "cut_head":
```
class SmartyModifiers
{
const MODIFIERS = [
"cut_head",
...
];
public static function cut_head( ... )
{
...
}
}
```
This class constant is being used as follows:
```
foreach (SmartyModifiers::MODIFIERS as $modifier) {
$ref = SmartyModifiers::class . '::' . $modifier;
$this->registerPlugin("modifier", $modifier, $ref);
}
```
The error was logged inside the registerPlugin method, because
SmartyModifiers::cut_hea (without the "d") doesn't exist and is
therefore not callable.
Now, as if this wasn't strange enough, the corresponding Sentry event
also contained the same anomaly:
```
There was 1 error encountered while processing this event
* environmen: Discarded unknown attribute
```
(Note the missing "t" in "environmen" vs. "environment".)
To mitigate the issue, I tried to opcache_reset() and restart the
Apache server, but both didn't solve the issue. The only solution I
found was to disable zend_extension=php_opcache.dll temporarily
(disable, restart, enable, restart).
Our OPcache configuration is as follows, following the recommendations
from [1]:
```
[opcache]
zend_extension=php_opcache.dll
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
```
[1] https://www.php.net/manual/de/opcache.installation.php
--
Edit bug report at https://bugs.php.net/bug.php?id=79729&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79729&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79729&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79729&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79729&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79729&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79729&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79729&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79729&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79729&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79729&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79729&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79729&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79729&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79729&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79729&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79729&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79729&r=mysqlcfg