Bug #80535 [Com]: Backward compatibility issue - FATAL error

From: Date: Sun, 20 Dec 2020 23:42:00 +0000
Subject: Bug #80535 [Com]: Backward compatibility issue - FATAL error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231199@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80535&edit=1 ID: 80535 Comment by: rtrtrtrtrt at dfdfdfdf dot dfd Reported by: legrand101 at gmail dot com Summary: Backward compatibility issue - FATAL error Status: Not a bug Type: Bug Package: Scripting Engine problem PHP Version: 8.0.0 Assigned To: cmb Block user comment: N Private report: N New Comment: > In this case it has been only *one* year you don't jump to a x.0 major release lightly and especially you don't jump from 7.0 to 8.0 unless you are asking for troubles Previous Comments: ------------------------------------------------------------------------ [2020-12-20 23:14:01] cmb@php.net > So, is there any work around other than explicitly instantiating > each variable. I don't think so. If you strongly feel that this "feature" should not have been disallowed, please raise that on the internals mailing list, although I consider it unlikely that the change will be reverted. > there is a reason to introduce warnings years before In this case it has been only *one* year. ------------------------------------------------------------------------ [2020-12-20 23:05:28] rtrtrtrtrt at dfdfdfdf dot dfd > I was upgrading from PHP7.0 so didn't get any warnings your mistake > This seems like a big inconvenience, special if > one relied this behavior for API development there was 7.1, 7.2, 7.3 and 7.4 sorry, but nobody can help you if you skip 4 major releases there is a reason to introduce warnings years before ------------------------------------------------------------------------ [2020-12-20 20:39:14] legrand101 at gmail dot com Thanks for the quick response. I was upgrading from PHP7.0 so didn't get any warnings. By crash, I meant the my script was crashing. So, is there any work around other than explicitly instantiating each variable. This seems like a big inconvenience, special if one relied this behavior for API development. ------------------------------------------------------------------------ [2020-12-20 16:11:25] cmb@php.net That code already issued E_WARNING as of PHP 7.4.0[1], and the warning was promoted to an Error exception according to the respective RFC[2]. It is also documented as backward incompatible change in the migration guide[3]. Note that an Error exception is not a fatal error per se, and that even a fatal error is not a crash. [1] <https://3v4l.org/h3NJj> [2] <https://wiki.php.net/rfc/engine_warnings> [3] <https://www.php.net/manual/en/migration80.incompatible.php> ------------------------------------------------------------------------ [2020-12-20 16:01:11] legrand101 at gmail dot com Description: ------------ After upgrading to PHP 8, I start getting FATAL error for simple statement that use to work on PHP 7. This statement is now producing a FATAL error (PHP Fatal error: Uncaught Error: Attempt to modify property on null) on PHP 8: $T = &$r->country->state->city; Before PHP8 both $r and properties (r->country, r->country->state, r->country->state->city) are implicitly instantiated as standard classs and $T is pointer. Test script: --------------- $T = &$r->country->state->city; $T = 'home'; Expected result: ---------------- no fatal error. $r object implicitly created. $T and $r->country->state->city value are 'home'. var_dump($r); object(stdClass)#34 (1) { ["country"]=> object(stdClass)#36 (1) { ["state"]=> object(stdClass)#37 (1) { ["city"]=> &string(4) "home" } } } var_dump($T); string(4) "home" Actual result: -------------- PHP Fatal error: Uncaught Error: Attempt to modify property on null ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80535&edit=1

« previous php.bugs (#231199) next »