[php-src] PHP-8.6: Fix GH-24745: File cache loses attributes on constants on 32-bit builds
| From: | lazerg via ndossche | Date: | Mon, 26 Oct 2026 17:37:03 +0000 |
| Subject: | [php-src] PHP-8.6: Fix GH-24745: File cache loses attributes on constants on 32-bit builds | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142743@lists.php.net to get a copy of this message | ||
Author: lazerg (lazerg)
Committer: ndossche (ndossche)
Date: 2026-10-26T18:36:17+01:00
Commit: https://github.com/php/php-src/commit/a2052f318ab4c7d4fb2e03d576e51488ad7aa097
Raw diff: https://github.com/php/php-src/commit/a2052f318ab4c7d4fb2e03d576e51488ad7aa097.diff
Fix GH-24745: File cache loses attributes on constants on 32-bit builds
Closes GH-24750.
Co-authored-by: Yannick Decat <17177411+mho22@users.noreply.github.com>
Changed paths:
A ext/opcache/tests/gh24745.inc
A ext/opcache/tests/gh24745.phpt
M NEWS
M ext/opcache/zend_file_cache.c
Diff:
diff --git a/NEWS b/NEWS
index 6254d1807c39..5bb01a160a23 100644
--- a/NEWS
+++ b/NEWS
@@ -104,6 +104,8 @@ PHP NEWS
into a hash. (jorgsowa)
. Fixed bug GH-24436 (Tracing JIT: keep the SEND_VAL type guard after
assigning to a reference). (waroad)
+ . Fixed bug GH-24745 (File cache loses attributes on constants on 32-bit
+ builds). (Yannick Decat, Lazizbek Ergashev)
- PDO:
. Fixed invalid ATTR_ORACLE_NULLS values being accepted and truncated.
diff --git a/ext/opcache/tests/gh24745.inc b/ext/opcache/tests/gh24745.inc
new file mode 100644
index 000000000000..d51e96835b2b
--- /dev/null
+++ b/ext/opcache/tests/gh24745.inc
@@ -0,0 +1,4 @@
+<?php
+
+#[Deprecated(message: 'bar')]
+const FOO = 1;
diff --git a/ext/opcache/tests/gh24745.phpt b/ext/opcache/tests/gh24745.phpt
new file mode 100644
index 000000000000..b35b0e45827d
--- /dev/null
+++ b/ext/opcache/tests/gh24745.phpt
@@ -0,0 +1,20 @@
+--TEST--
+GH-24745: File cache loses attributes on constants on 32-bit builds
+--EXTENSIONS--
+opcache
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.file_cache="{TMP}"
+opcache.file_cache_only=1
+--FILE--
+<?php
+require __DIR__ . '/gh24745.inc';
+
+var_dump((new ReflectionConstant('FOO'))->getAttributes()[0]->getArguments());
+?>
+--EXPECT--
+array(1) {
+ ["message"]=>
+ string(3) "bar"
+}
diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c
index d1d49890f515..0f9b48feccfc 100644
--- a/ext/opcache/zend_file_cache.c
+++ b/ext/opcache/zend_file_cache.c
@@ -561,6 +561,10 @@ static void zend_file_cache_serialize_op_array(zend_op_array
*op_arra
&& (opline-1)->opcode == ZEND_DECLARE_ATTRIBUTED_CONST
) {
zval *literal = RT_CONSTANT(opline, opline->op1);
+#if ZEND_USE_ABS_CONST_ADDR
+ SERIALIZE_PTR(literal);
+ UNSERIALIZE_PTR(literal);
+#endif
SERIALIZE_ATTRIBUTES(Z_PTR_P(literal));
}