Skip to content

Fix rendering of database connection error page - #1113

Merged
MTGap merged 4 commits into
masterfrom
fix-issue-1085
Jan 22, 2013
Merged

MTGap merged 4 commits into
masterfrom
fix-issue-1085

Conversation

@MTGap

@MTGap MTGap commented Jan 7, 2013

Copy link
Copy Markdown
Contributor

This is a fix for #1085. When there is no database connection the error page was not being properly rendered because of a loop of additional queries by the template layout.

This moves the calls for apps web roots to only the user template layout and the setting of the js and css minimizer to the setup.

It wasn't ideal, but I also had to unset the logged in user because the localization was trying to get the user's language preference using the database. Are there any other ideas?

@bartv2

@bartv2

bartv2 commented Jan 8, 2013

Copy link
Copy Markdown
Contributor

do users of appswebroots understand that it can be false?
for the language, the only thing i can think of is have the db class it's state and check that in the language function

@MTGap

MTGap commented Jan 10, 2013

Copy link
Copy Markdown
Contributor Author

do users of appswebroots understand that it can be false?
for the language, the only thing i can think of is have the db class it's state and check that in the language function

I'm not quite sure what you're saying. I don't know what the purpose of appswebroots is.

@bartv2

bartv2 commented Jan 10, 2013

Copy link
Copy Markdown
Contributor

appswebroots is used in the filePath function to generate urls for app assets (images/js/css)

@DeepDiver1975

Copy link
Copy Markdown
Contributor

tested with mysql 👍

should we return http status code 503 in this case as well?
@danimo @dragotin

@arkascha

Copy link
Copy Markdown
Contributor

+1 - I confirm that this adds a visible failure feedback when using PostgreSQL as a database backend.

However I am not sure if the error message does not show too much details:

"Failed to connect to pgsql database. (SQLSTATE[08006] [7] could not connect
to server: Connection refused Is the server running on host "localhost"
(127.0.0.1) and accepting TCP/IP connections on port 5432?)"

I often see such error messages in small web pages on the internet. I think
that is way too much information for an external user. It reveals what type of
database server that page is based on, where it is and how it can be reached
(if up). Why all that information?

I mean that is fine for the local administrator, but it is internal stuff.
Wouldn't a plain error about technical problems be enough?
It probably makes sense to show that level of details during setup, since that
is where problems occur most often. But once setup is finished, during normal
usage, a less detailed message might be preferable from a security point of
view.

@dragotin

Copy link
Copy Markdown
Contributor

I would suggest to return 503, yes.

@MTGap

MTGap commented Jan 21, 2013

Copy link
Copy Markdown
Contributor Author

Well maybe we should be returning 503 in other situations as well. checkServer() and checkConfig() for instance.

I agree with @arkascha, I'll make the message more discreet.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

I was thinking in the direction. 
What about moving the status code header to the print  error function and have the status code as parameter with default to 500.

@MTGap

MTGap commented Jan 22, 2013

Copy link
Copy Markdown
Contributor Author

You mean 503, not 500 right?

@DeepDiver1975

Copy link
Copy Markdown
Contributor

500 or 503 or 50x ;-)
Depends on the majority of use cases of the print error function.
Not every error is 503.

@MTGap

MTGap commented Jan 22, 2013

Copy link
Copy Markdown
Contributor Author

@DeepDiver1975 I'm not certain how to do it as a parameter to the function. Passing 'HTTP/1.1 503 Service Temporarily Unavailable' or other status message to the function doesn't seem like it makes anything easier.

There's also quite a few addHeader functions around in lib/template.php and lib/util.php Nothing seems to be using them though.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

I would design the additional parameter to be an int (e.g. 503) and within the template we expand the int to the header(s).

And yes - addheader/header calls deserve some house cleaning ;-)

But this is no scope of this PR.

Let's merge! 🚀

MTGap pushed a commit that referenced this pull request Jan 22, 2013
Fix rendering of database connection error page
@MTGap
MTGap merged commit 9eecb91 into master Jan 22, 2013
@MTGap
MTGap deleted the fix-issue-1085 branch January 22, 2013 22:38
@DeepDiver1975

Copy link
Copy Markdown
Contributor

@karlitschek as usual: shall we backport this one? THX

@bartv2

bartv2 commented Feb 5, 2013

Copy link
Copy Markdown
Contributor

There is also a setStatus function in OC_Response which could be used for the int to string conversion

@lock lock Bot locked as resolved and limited conversation to collaborators Aug 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants