Community
Participate
Working Groups
Some pages connect to MySQL databases using PHP connection objects. These objects halt the page execution if the database connection fails. These connection failures should be returned to the caller so that the page can handle them gracefully. D.
We currently use the MySQL objects provided by the Eclipse webmasters (e.g., dbconnection_*.class.php). Do these objects return anything specific upon failure to connect? or are they still using exit()?
(In reply to comment #1) They currently exit(), which is the problem.
Expanding this bug into a feature request. The purpose of this FR is to extend the functionality of the databases, while improving our site security, improving our site's 'robustness' where database connections are required, and removing some development burden from the developers. The current database connection mechanisms have the following drawbacks: - they are difficult to maintain by the webmaster, as the number of classes increases - they require the developer to manage DB connects, disconnects, SQL sanitizing - do not fail gracefully if the database is not there - require the programmer to select between the master and slave - don't allow code to run locally, where no database is present - prevent the actual dbconnection PHP code from being in CVS, because of passwords and trusted path information I'm proposing we deprecate the many dbconnection_*.class.php and create a database connection handler for *all* the eclipse.org databases, where the handler: - will connect to the appropriate database server (master always for writes, or slave(s) for selects) - will handle trusted paths for all the databases - will handle disconnecting - will handle SQL sanitizing, to prevent SQL injection attacks - will gracefully fail if the database server is unavailable - will gracefully route SELECT queries to the MASTER if the SLAVE is unavailable - will use username/password and trusted path information from root-accessible files, allowing the actual code to be stored in CVS This proposed suggestion will make it easy to add the following functionality later on: - handle intelligent load balancing for SELECTs among slaves, depending on load and locks Proposed client-side implementation would look like this: $eclipse_db = new DatabaseHandler(); $resultset = $eclipse_db->query("database1", "SELECT blabla"); $some_xml = $eclipse_db->query("database2", "SELECT something else", "xml"); $resultset3 = $eclipse_db->query("database1", "INSERT INTO something"); The return value for the resultset would either be the actual PHP/mysql resultset for SELECTS (or xml if specified), the number of matched rows for all other queries, or some special indicator that the database is unavailable. Obviously, this will only apply to Phoenix-related code that accesses a database, i.e. Bugzilla, Wiki and Search won't be affected by this. I'm tossing this up in the air for comment. Any specific implementation suggestions or ideas are welcome. D.
Sounds good. My question is "what is gracefully fail?" Will they return an error code? An empty select? Call a handler? I don't think it really matters, I just want to know the spec/API so that we can use it.
"The return value for the resultset would either be the actual PHP/mysql resultset for SELECTS (or xml if specified), the number of matched rows for all other queries, or some special indicator that the database is unavailable." I'm not sure yet what the actual value would be, but it would be something. Any suggestions?
Nothing comes to mind. Perhaps some string that is not numeric, thus I can distinguish between success (an object) or success (an integer) or failure (a string). But I'm sure you've already thought that far along and so my comment here is seriously redundant.
Moving to Community/Website
*** This bug has been marked as a duplicate of bug 203636 ***