-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not implicitly fall back to spl_autoload() if no autoloader is reg…
…istered on PHP 7 (#2822) * Do not implicitly fall back to spl_autoload() if no autoloader is registered on PHP 7 This could lead to accidental inclusion of files, breaking __autoload() and possibly including the wrong file. Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
- Loading branch information
Showing
6 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--TEST-- | ||
Execute the default spl_autoload implementation if spl_autoload_register() is called without args | ||
--INI-- | ||
datadog.trace.sources_path="{PWD}/.." | ||
--FILE-- | ||
<?php | ||
|
||
spl_autoload_register(); | ||
|
||
var_dump(class_exists('splautoload')); | ||
|
||
echo "Request start" . PHP_EOL; | ||
|
||
?> | ||
--EXPECT-- | ||
bool(true) | ||
Request start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--TEST-- | ||
Execute __autoload() if present | ||
--SKIPIF-- | ||
<?php if (PHP_VERSION_ID >= 80000) die("skip: __autoload was removed in PHP 8") ?> | ||
--INI-- | ||
error_reporting=8191 | ||
datadog.trace.sources_path="{PWD}/.." | ||
--FILE-- | ||
<?php | ||
|
||
function __autoload($class) { | ||
print "Autoload $class attempted!\n"; | ||
} | ||
|
||
var_dump(class_exists('splautoload')); | ||
|
||
echo "Request start" . PHP_EOL; | ||
|
||
?> | ||
--EXPECT-- | ||
Autoload splautoload attempted! | ||
bool(false) | ||
Request start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--TEST-- | ||
Do not execute the default spl_autoload implementation if no autoloader is specified | ||
--INI-- | ||
datadog.trace.sources_path="{PWD}/.." | ||
--FILE-- | ||
<?php | ||
|
||
var_dump(class_exists('splautoload')); | ||
|
||
echo "Request start" . PHP_EOL; | ||
|
||
?> | ||
--EXPECT-- | ||
bool(false) | ||
Request start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
class splautoload { | ||
var $foo = "Autoloaded!"; | ||
} |