php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80225 broken namespace usage in eval code
Submitted: 2020-10-12 13:47 UTC Modified: 2020-10-12 14:51 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: remi@php.net Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 8.0.0rc1 OS: GNU/Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: remi@php.net
New email:
PHP Version: OS:

 

 [2020-10-12 13:47 UTC] remi@php.net
Description:
------------
Looks like a regression in 8.0.0rc1

Was working in previous versions (7.2, 7.3, 7.4 and up to 8.0.0beta4)

https://3v4l.org/gWW0K



Test script:
---------------
<?php

eval("echo \"One\n\";\n");
eval("namespace Bar;\n\necho \"Two\n\";\n");
eval("?><?php\necho \"Three\n\";\n");
eval("?><?php\nnamespace Bar;\n\necho \"Four\n\";\n");



Expected result:
----------------
One
Two
Three
Four

Actual result:
--------------
One
Two
Three

Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in /in/gWW0K(6) : eval()'d code on line 2


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-10-12 14:30 UTC] nikic@php.net
-Status: Open +Status: Verified
 [2020-10-12 14:30 UTC] nikic@php.net
Basically same as https://3v4l.org/bBCrm. No idea if that's "right", but I guess we can just match the previous behavior.
 [2020-10-12 14:35 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f9b7609d17694c5b5d5bba6321b27944220566be
Log: Fixed bug #80225
 [2020-10-12 14:35 UTC] nikic@php.net
-Status: Verified +Status: Closed
 [2020-10-12 14:40 UTC] remi@php.net
Thanks for the quick fix.

(for memory was affecting mockery/mockery).
 [2020-10-12 14:42 UTC] nikic@php.net
-Assigned To: +Assigned To: nikic
 [2020-10-12 14:42 UTC] nikic@php.net
It makes me wonder if we shouldn't also lift this restriction for declare(strict_types)... That is allow `<?php ; declare(strict_types=1);` or `?><?php declare(strict_types=1);` in eval.
 [2020-10-12 14:51 UTC] remi@php.net
> It makes me wonder if we shouldn't also lift this restriction for declare(strict_types)... 

I think it make sense
 [2020-10-12 14:56 UTC] remi@php.net
Well, NOOP before declare was not allowed in previous versions, so can also stay like now.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC