Edit report at https://bugs.php.net/bug.php?id=79729&edit=1
ID: 79729
Comment by: ca at lsp dot net
Reported by: ca at lsp dot net
Summary: Strings missing last character (Apache + OPcache)
Status: Feedback
Type: Bug
Package: opcache
Operating System: Windows 10
PHP Version: 7.3.19
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
@nikic Thanks, I will try that once the issue occurs again (which I hope it does).
@cmb The server is running PHP 7.3.19 since 2020-06-11 (but actually the OS is Windows Server 2016
Standard, not Windows 10).
```
$ php --version
PHP 7.3.19 (cli) (built: Jun 9 2020 11:54:59) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.19, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.19, Copyright (c) 1999-2018, by Zend Technologies
```
Previous Comments:
------------------------------------------------------------------------
[2020-06-24 10:38:26] cmb@php.net
Are you really using PHP 7.3.19, or maybe an older 7.3 version?
If the latter, could you check with 7.3.19?
Also, do you use mod_php or FCGI; in other words, is about a ZTS
(thread-safe) or NTS (non thread-safe) PHP build?
------------------------------------------------------------------------
[2020-06-24 10:30:09] nikic@php.net
Does opcache.optimization_level=0 fix the issue?
------------------------------------------------------------------------
[2020-06-24 10:18:17] ca at lsp dot net
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 this bug report at https://bugs.php.net/bug.php?id=79729&edit=1