Skip to content

Commit 858d0c0

Browse files
jmikolanikic
authored andcommitted
Include class name in Serializable deprecation message
The deprecation message was originally introduced in 3e6b447 (#6494). I first encountered this notice when testing the MongoDB extension with PHP 8.1, which produced many duplicate messages that provided no detail about the particular class that needed to be fixed. Closes GH-7346.
1 parent a2e0519 commit 858d0c0

27 files changed

+34
-34
lines changed

Zend/tests/bug64354.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ try {
2121
}
2222
?>
2323
--EXPECTF--
24-
Deprecated: The Serializable interface is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
24+
Deprecated: B implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
2525
string(9) "serialize"

Zend/tests/enum/no-implement-serializable-indirect.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ var_dump(unserialize(serialize(Foo::Bar)));
2121

2222
?>
2323
--EXPECTF--
24-
Deprecated: The Serializable interface is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
24+
Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
2525

2626
Fatal error: Enums may not implement the Serializable interface in %s on line %d

Zend/tests/enum/no-implement-serializable.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ var_dump(unserialize(serialize(Foo::Bar)));
1919

2020
?>
2121
--EXPECTF--
22-
Deprecated: The Serializable interface is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
22+
Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
2323

2424
Fatal error: Enums may not implement the Serializable interface in %s on line %d

Zend/tests/serializable_deprecation.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ class D extends A implements I {
2020

2121
?>
2222
--EXPECTF--
23-
Deprecated: The Serializable interface is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
23+
Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d

Zend/tests/traits/interface_003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var_dump(unserialize($o));
2121

2222
?>
2323
--EXPECTF--
24-
Deprecated: The Serializable interface is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
24+
Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
2525
string(20) "C:3:"bar":6:{foobar}"
2626
string(6) "foobar"
2727
object(bar)#%d (0) {

Zend/zend_interfaces.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ static int zend_implement_serializable(zend_class_entry *interface, zend_class_e
419419
}
420420
if (!(class_type->ce_flags & ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)
421421
&& (!class_type->__serialize || !class_type->__unserialize)) {
422-
zend_error(E_DEPRECATED, "The Serializable interface is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary)");
422+
zend_error(E_DEPRECATED, "%s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary)", ZSTR_VAL(class_type->name));
423423
}
424424
return SUCCESS;
425425
}

ext/pdo/tests/bug_44409.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ print_r($stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE, "bug44409"));
4242

4343
?>
4444
--EXPECTF--
45-
Deprecated: The Serializable interface is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
45+
Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
4646

4747
Deprecated: PDOStatement::fetchAll(): The PDO::FETCH_SERIALIZE mode is deprecated in %s on line %d
4848
Method called: bug44409::unserialize('Data from DB')

ext/pdo/tests/pdo_018.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ var_dump($stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE|PDO::FETCH_SERIAL
184184

185185
?>
186186
--EXPECTF--
187-
Deprecated: The Serializable interface is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
187+
Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
188188

189-
Deprecated: The Serializable interface is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
189+
Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
190190

191-
Deprecated: The Serializable interface is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
191+
Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
192192
string(1) "3"
193193
array(3) {
194194
[0]=>

ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ $db = MySQLPDOTest::factory();
121121
$db->exec('DROP TABLE IF EXISTS test');
122122
?>
123123
--EXPECTF--
124-
Deprecated: The Serializable interface is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
124+
Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
125125
Creating an object, serializing it and writing it to DB...
126126
myclass::singleton(Creating object)
127127
myclass::__construct(Creating object)

ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_simple.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ MySQLPDOTest::skip();
7070
print "done!\n";
7171
?>
7272
--EXPECTF--
73-
Deprecated: The Serializable interface is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
73+
Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
7474
Lets see what the Serializeable interface makes our object behave like...
7575
myclass::__construct('Called by script') - note that it must not be called when unserializing
7676
myclass::serialize()

0 commit comments

Comments
 (0)