Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14369468
D18797.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D18797.diff
View Options
diff --git a/src/moduleutils/PhutilBootloader.php b/src/moduleutils/PhutilBootloader.php
--- a/src/moduleutils/PhutilBootloader.php
+++ b/src/moduleutils/PhutilBootloader.php
@@ -234,9 +234,27 @@
$old_last = error_get_last();
- $old = error_reporting(0);
- $okay = include_once $path;
- error_reporting($old);
+ try {
+ $old = error_reporting(0);
+ $okay = include_once $path;
+ error_reporting($old);
+ } catch (Exception $ex) {
+ throw $ex;
+ } catch (ParseError $throwable) {
+ // NOTE: As of PHP7, syntax errors may raise a ParseError (which is a
+ // Throwable, not an Exception) with a useless message (like "syntax
+ // error, unexpected ':'") and a trace which ends a level above this.
+
+ // Treating this object normally results in an unusable message which
+ // does not identify where the syntax error occurred. Converting it to
+ // a string and taking the first line gives us something reasonable,
+ // however.
+ $message = (string)$throwable;
+ $message = preg_split("/\n/", $message);
+ $message = reset($message);
+
+ throw new Exception($message);
+ }
if (!$okay) {
throw new Exception("Source file \"{$path}\" failed to load.");
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 4:50 PM (4 h, 52 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6914741
Default Alt Text
D18797.diff (1 KB)
Attached To
Mode
D18797: Improve PHP7 error reporting for include-time syntax errors
Attached
Detach File
Event Timeline
Log In to Comment