Skip to content

Commit

Permalink
Make include/require error messages more vebose
Browse files Browse the repository at this point in the history
Summary: Closes #6686

Reviewed By: sgolemon, JoelMarcey

Differential Revision: D2775286

Pulled By: sgolemon

fb-gh-sync-id: 6ecf19a7453ec12e4ef5d92cd922341a94c9bf09
  • Loading branch information
fadimko authored and hhvm-bot committed Feb 2, 2016
1 parent 01bb09f commit 6cac021
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 10 deletions.
20 changes: 12 additions & 8 deletions hphp/runtime/vm/bytecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6493,7 +6493,7 @@ OPTBLD_INLINE void iopCIterFree(IOP_ARGS) {
it->cfree();
}

OPTBLD_INLINE void inclOp(PC& pc, InclOpFlags flags) {
OPTBLD_INLINE void inclOp(PC& pc, InclOpFlags flags, const char* opName) {
Cell* c1 = vmStack().topC();
auto path = String::attach(prepareKey(*c1));
bool initial;
Expand Down Expand Up @@ -6527,9 +6527,9 @@ OPTBLD_INLINE void inclOp(PC& pc, InclOpFlags flags) {
vmStack().popC();
if (unit == nullptr) {
if (flags & InclOpFlags::Fatal) {
raise_error("File not found: %s", path.data());
raise_error("%s(%s): File not found", opName, path.data());
} else {
raise_warning("File not found: %s", path.data());
raise_warning("%s(%s): File not found", opName, path.data());
}
vmStack().pushBool(false);
return;
Expand All @@ -6544,23 +6544,27 @@ OPTBLD_INLINE void inclOp(PC& pc, InclOpFlags flags) {
}

OPTBLD_INLINE void iopIncl(IOP_ARGS) {
inclOp(pc, InclOpFlags::Default);
inclOp(pc, InclOpFlags::Default, "include");
}

OPTBLD_INLINE void iopInclOnce(IOP_ARGS) {
inclOp(pc, InclOpFlags::Once);
inclOp(pc, InclOpFlags::Once, "include_once");
}

OPTBLD_INLINE void iopReq(IOP_ARGS) {
inclOp(pc, InclOpFlags::Fatal);
inclOp(pc, InclOpFlags::Fatal, "require");
}

OPTBLD_INLINE void iopReqOnce(IOP_ARGS) {
inclOp(pc, InclOpFlags::Fatal | InclOpFlags::Once);
inclOp(pc, InclOpFlags::Fatal | InclOpFlags::Once, "require_once");
}

OPTBLD_INLINE void iopReqDoc(IOP_ARGS) {
inclOp(pc, InclOpFlags::Fatal | InclOpFlags::Once | InclOpFlags::DocRoot);
inclOp(
pc,
InclOpFlags::Fatal | InclOpFlags::Once | InclOpFlags::DocRoot,
"require_once"
);
}

OPTBLD_INLINE void iopEval(IOP_ARGS) {
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/quick/FPassC-2.php.expectf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Warning: File not found: doesnotexist.php in %s on line 14
Warning: include(doesnotexist.php): File not found in %s on line 14
bool(false)
NULL
object(stdClass)#1 (0) {
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/compilation/open-rc-check.php.expectf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Fatal error: File not found: %s in %s on line 10
Fatal error: require(%s): File not found in %s on line 10
6 changes: 6 additions & 0 deletions hphp/test/slow/include-error1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
include('non-existing-file.php');
include 'non-existing-file.php';
include_once('non-existing-file.php');
include_once 'non-existing-file.php';
require('non-existing-file.php');
10 changes: 10 additions & 0 deletions hphp/test/slow/include-error1.php.expectf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

Warning: include(non-existing-file.php): File not found in %s/include-error1.php on line 2

Warning: include(non-existing-file.php): File not found in %s/include-error1.php on line 3

Warning: include_once(non-existing-file.php): File not found in %s/include-error1.php on line 4

Warning: include_once(non-existing-file.php): File not found in %s/include-error1.php on line 5

Fatal error: require(non-existing-file.php): File not found in %s/include-error1.php on line 6
2 changes: 2 additions & 0 deletions hphp/test/slow/include-error2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
require 'non-existing-file.php';
2 changes: 2 additions & 0 deletions hphp/test/slow/include-error2.php.expectf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Fatal error: require(non-existing-file.php): File not found in %s/include-error2.php on line 2
2 changes: 2 additions & 0 deletions hphp/test/slow/include-error3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
require_once('non-existing-file.php');
2 changes: 2 additions & 0 deletions hphp/test/slow/include-error3.php.expectf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Fatal error: require_once(non-existing-file.php): File not found in %s/include-error3.php on line 2
2 changes: 2 additions & 0 deletions hphp/test/slow/include-error4.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
require_once 'non-existing-file.php';
2 changes: 2 additions & 0 deletions hphp/test/slow/include-error4.php.expectf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Fatal error: require_once(non-existing-file.php): File not found in %s/include-error4.php on line 2

0 comments on commit 6cac021

Please sign in to comment.