-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Server error/hint pages with a 500 error code to avoid it being seen … #9995
Server error/hint pages with a 500 error code to avoid it being seen … #9995
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙈
lib/private/legacy/template.php
Outdated
@@ -317,6 +317,7 @@ public static function printErrorPage( $error_msg, $hint = '' ) { | |||
$hint = ''; | |||
} | |||
|
|||
header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about http://php.net/http_response_code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just used the way it was before. We can of course also move to this. What is the advantage? No need to juggle again with the protocol and terms behind the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would for now vote for this approach to have a minimal backportable solution and then fix the http_response_code in a separated PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed that it is not that easy and I will change it already to make the code more clear.
6186e83
to
574aa04
Compare
574aa04
to
6fb0ae2
Compare
Codecov Report
@@ Coverage Diff @@
## master #9995 +/- ##
=========================================
Coverage ? 51.98%
Complexity ? 26014
=========================================
Files ? 1660
Lines ? 96145
Branches ? 1290
=========================================
Hits ? 49983
Misses ? 46162
Partials ? 0
|
6fb0ae2
to
77826b3
Compare
Okay - I fixed a bit more, but now error and exception pages are properly covered. I would not backport it anymore, but this should be fine for now. Ready for review 🚢 |
lib/private/legacy/template.php
Outdated
* @suppress PhanAccessMethodInternal | ||
*/ | ||
public static function printErrorPage( $error_msg, $hint = '' ) { | ||
public static function printErrorPage( $error_msg, $hint = '', $statusCode = \OC_Response::STATUS_INTERNAL_SERVER_ERROR ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be very specific and unexpected, but what if the OC_Response
class has not been loaded at this point and autoloading causes another error/exception? Should we use 500
instead, just to be on the safe side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure - let me update it.
a2efd12
to
18e8c5c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…instead of the actual resource * found while reviewing #7205 * allow to specify a special status code Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
18e8c5c
to
1399f6b
Compare
…instead of the actual resource
Could this solve most of the issues we had in the past with files being overwritten? Because error pages were served with HTTP code 200 :/
This should at least avoid problems with clients and the web UI.
Usages: