Page 1 of 1

new adodb_error() missing db_error.html customization

Posted: Tue Mar 21, 2017 1:38 am
by fredp
In CMSMS 1.21.1, and earlier releases, the adodb_error() function would invoke an optionally user defined db_error.html page so that developers could customize/style how DB errors would be reported to visitors of that site. I have sites that use this.

It appears, however, that this functionality is not supported in 2.2beta! :(

I discovered this "regression" after successfully running the installer to upgrade a copy of a 1.12.1 install on a test machine. As luck would have it, while attempting to view the converted site, an unrelated MySQL corruption trashed some db user passwords, resulting in login failures. I noticed the MySQL problem because visiting the site yielded an all white screen with this generic message:
Sorry, something has gone wrong. Please contact a site administrtor. (CMSMS\Database\DatabaseConnectionException)
Not, however, the customized db_error.html page that I would have expected/desired.

You can reproduce the same error by temporarily changing a db_username or db_password value in config.php and then attempt to view any page on your site.

I don't know if the loss of customization was inadvertent or by design, but it would be great if db_error.html or some other form of DB error reporting customization were available in 2.2.

Thanks to the team for all the effort!
Now, back to the upgrade testing...

Re: new adodb_error() missing db_error.html customization

Posted: Tue Mar 21, 2017 9:16 pm
by calguy1000
The db_error.html thing was an undocumented feature.

it was implemented in 2008 because otherwise fatal errors could reveal the database name, and username (though not the password).

And PHP didn't have exceptions at the time.

It was deemed a minor feature that only a small percentage of the user community knew about the ability to nicely style an HTML page for a fatal database error message. Note, that only applied to database errors, but not other types of fatal errors.

It was also a potential security issue.

So we've made sure that the private information is hidden when a critical, fatal database error occurs, provided a hint as to what the error may be... but the output page cannot be styled.

Re: new adodb_error() missing db_error.html customization

Posted: Wed Mar 22, 2017 5:31 am
by fredp
Understood. But, just to be clear, can developer code catch and handle an CMSMS\Database\DatabaseConnectionException? If not, then while the loss of customization is unfortunate, it's not a huge deal.

I'm old enough to remember when one could buy Generic "BEER" in the store--nothing but an all white label with the word "BEER" on it. Not stylish, but cheap and it did what beer does. ;-) ;-) ;-)

You might still consider giving developers at least some way to insert text or an email link into the current generic message. It says to "Please contact a site administrtor.", but with the site offline I'm not sure most visitors will know how to do that. Also, I just noticed the misspelling of 'administrator'.

If you'd like, I can prepend '[will not fix]', or whatever, onto the article title.

Thanks again for all the hard work!!

Re: new adodb_error() missing db_error.html customization

Posted: Tue May 23, 2017 12:12 pm
by PinkElephant
Just a +1 for fredp's take. Some of my finest work is in db_error.html ;) and it's the sort of detail that helps deliver a stand-out site.

I appreciate that with the huge improvements in 2.2 this feature isn't likely to see the light of day again... but 'just saying'.

(The minor "administrtor" typo is still present, line 172 \lib\include.php)

Thanks, all.

Re: new adodb_error() missing db_error.html customization

Posted: Wed May 24, 2017 2:15 am
by fredp
PinkElephant, thanks for the comment! It reminded me to report the following:

Dev Team, please note that there is a copy of doc/db_error.html in the data/data.tar.gz archive in the standalone Beta3 installer (cmsms-2.2-beta3-install.expanded.zip). Not sure if is also included in the PHAR installer. This file might cause some confusion if it makes it into the final release and then it doesn't work when a user copies it to doc root, as it instructs:
doc/db_error.html wrote:/**
* Move this file to the website root and it will be displayed in case of a database connection failure.
*/
...
Thanks again for all the work!
fredp

Re: new adodb_error() missing db_error.html customization

Posted: Wed May 24, 2017 2:59 am
by calguy1000
Thanks. I will remove that file soon.