Bug #81600 [NEW]: Require once does not throw a fatal error

From: Date: Mon, 08 Nov 2021 15:01:49 +0000
Subject: Bug #81600 [NEW]: Require once does not throw a fatal error
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237612@lists.php.net to get a copy of this message
From:             7snovic at gmail dot com
Operating system: Ubuntu 20
PHP version:      8.0.12
Package:          *Directory/Filesystem functions
Bug Type:         Bug
Bug description:Require once does not throw a fatal error

Description:
------------
require & require_once should throw a Fatal error exception or
fatal_error message when the required file does not exist.
but it only throws the warning message.


Version:

PHP 8.0.12 (cli) (built: Oct 22 2021 12:34:48) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.12, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.12, Copyright (c), by Zend Technologies

------

The list of modules my PHP compiled with:
$ php8.0 -m
bz2
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

Test script:
---------------
<?php
require_once("non-existing-file");

Expected result:
----------------
PHP Warning:  require_once(non-existing-file): Failed to open stream: No
such file or directory in /var/www/test.php on line 2
PHP Fatal error:  Uncaught Error: Failed opening required
'non-existing-file' (include_path='.:/usr/share/php') in
/var/www/test.php:2
Stack trace:
#0 {main}
  thrown in /var/www/test.php on line 2


Actual result:
--------------
PHP Warning:  require_once(non-existing-file): Failed to open stream: No
such file or directory in /var/www/test.php on line 2

-- 
Edit bug report at https://bugs.php.net/bug.php?id=81600&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81600&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81600&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81600&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81600&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81600&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81600&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81600&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81600&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81600&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81600&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81600&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81600&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81600&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81600&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81600&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81600&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81600&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#237612) next »