-
-
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
Replace hard coded HTTP status codes with proper calls to http_response_code #10009
Replace hard coded HTTP status codes with proper calls to http_response_code #10009
Conversation
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
@@ -38,7 +38,7 @@ | |||
try { | |||
$dirInfo = \OC\Files\Filesystem::getFileInfo($dir); | |||
if (!$dirInfo || !$dirInfo->getType() === 'dir') { | |||
header("HTTP/1.0 404 Not Found"); | |||
http_response_code(404); |
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.
can we get rid of magic numbers too?
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 assume same reasoning as in #9995 (comment)
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 removed them, because they are either in files that we want to migrate to AppFramework anyway (and use the constants over there) or are in error/exception cases on the top level and can't rely on constants being loadable. Thus I went for the straight number. Also http_response_code
+ 404
is quite obvious and will also not change that fast.
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.
okay, makes sense, partly...
We use other OC\ classes before, but I get the point.
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.
nice 👍
Follow up to #9995 and #9996. It also removes the HTTP code constants from
OC_Response
.