Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common: Do not crash on PHP startup error #1195

Merged
merged 1 commit into from
May 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
- RSS spout now prefers the feed logo to website favicon. ([#1152](https://github.com/SSilence/selfoss/pull/1152))
- RSS spout now tries to use favicon from the feed domain when there is no logo or home page favicon. ([#1152](https://github.com/SSilence/selfoss/pull/1152))
- Setting `DEBUG` to `1` in `src/common.php` no longer logs HTTP bodies, only headers. Set it to `2` if you need the bodies as well. ([#1152](https://github.com/SSilence/selfoss/pull/1152))
- PHP startup errors are now logged, instead of having F3 crash with Error 500 ([#1195](https://github.com/SSilence/selfoss/pull/1195))


## 2.18 – 2018-03-05
Expand Down
12 changes: 12 additions & 0 deletions src/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
exit;
}

$startup_error = error_get_last();

// F3 crashes when there were PHP startups error even though
// they might not affect the program (e.g. unable to load an extension).
// It also sets its own error_reporting value and uses the previous one
// as a signal to disable the initialization failure check.
error_reporting(0);

$f3 = Base::instance();

$f3->set('DEBUG', 0);
Expand Down Expand Up @@ -186,6 +194,10 @@
}
$log->pushHandler($handler);

if (isset($startup_error)) {
$log->warn('PHP likely encountered a startup error: ', [$startup_error]);
}

// init error handling
$f3->set('ONERROR',
function(Base $f3) use ($log, $handler) {
Expand Down