Bug #75699 [NEW]: Conditional __autoload declaration always causes deprecation notice
| From: | scott dot vivian at gmail dot com | Date: | Sun, 17 Dec 2017 01:08:51 +0000 |
| Subject: | Bug #75699 [NEW]: Conditional __autoload declaration always causes deprecation notice | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-213142@lists.php.net to get a copy of this message | ||
From: scott dot vivian at gmail dot com
Operating system: Ubuntu
PHP version: 7.2.0
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Conditional __autoload declaration always causes deprecation notice
Description:
------------
If the __autoload function is declared in a branch that never gets
executed, PHP still outputs a deprecation notice. The notice is a little
haphazard and mostly only appears the first time a page is loaded.
Subsequent refreshes don't show the notice until a restart.
Also, it doesn't occur if you run the script below directly, only if you
include it from another script (i.e. autoload.php contains the code
below, and test.php includes autoload.php).
Test script:
---------------
<?php
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
// use spl_autoload_register()
} else {
function __autoload($classname)
{
echo 'called autoloader';
}
}
Expected result:
----------------
No deprecation notice on PHP 7.2, because the else clause doesn't run
and so the function is not defined.
Actual result:
--------------
Deprecated: __autoload() is deprecated, use spl_autoload_register()
instead in /path/autoload.php on line 6
Appears the first time the page is viewed, disappears after that.
--
Edit bug report at https://bugs.php.net/bug.php?id=75699&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75699&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75699&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75699&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75699&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75699&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75699&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75699&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75699&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75699&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75699&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75699&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75699&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75699&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75699&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75699&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75699&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75699&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75699&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75699&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75699&r=mysqlcfg