php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81600 Require once does not throw a fatal error
Submitted: 2021-11-08 15:01 UTC Modified: 2021-11-08 15:18 UTC
From: 7snovic at gmail dot com Assigned:
Status: Duplicate Package: *Directory/Filesystem functions
PHP Version: 8.0.12 OS: Ubuntu 20
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: 7snovic at gmail dot com
New email:
PHP Version: OS:

 

 [2021-11-08 15:01 UTC] 7snovic at gmail dot com
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-08 15:18 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2021-11-08 15:18 UTC] nikic@php.net
Assuming you have ignore_repeated_errors enabled, this is a duplicate of bug #81591.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 18:01:29 2024 UTC