In-Portal Issue Tracker - In-Portal CMS
Viewing Issue Advanced Details
953 [In-Portal CMS] Database bug report always 2010-12-14 10:20 2011-03-30 09:53
alex  
alex  
normal  
closed 5.1.1  
fixed  
 
none 5.1.2-RC1  
https://groups.google.com/d/topic/in-portal-dev/-YTo16ihRy4/discussion
Fixes database query error reporting
0
0000953: Incorrect database query error reporting
In-Portal has kDBConnection class, that can handle any type of database interactions. When database query being executed produces an error, then it's handled differently based on criteria listed below:

debug mode enabled AND DBG_SQL_FAILURE option set in debug.php file - will be PHP fatal error and script stops
debug mode enabled AND DBG_SQL_FAILURE option not set in debug.php file - will be PHP warning and script continues to execute
debug mode is disabled - will be PHP warning and script continues to execute
All works ok, until you need to check if last database query ended with error in last 2 cases from above mentioned.

Class kDBConnection has "getErrorCode", "getErrorMsg" and "hasError" methods, that do the trick, but if there was a query with error before checked query, then error isn't cleared an all methods will tell, that there is an error, but there are none.

I propose to reset "last remembered error information" before running new database query.
parent of 0001002closed  (5.1.2)alex Process critical database errors even when debug mode is off 
related to 0000956needs work  (Icebox)!COMMUNITY Insufficient database permission handling 
related to 0000973needs work  (Icebox)!COMMUNITY Daemon mode 
patch reset_db_error_before_each_query.patch (952) 2010-12-30 06:57
http://tracker.in-portal.org/file_download.php?file_id=887&type=bug
patch processing_of_mysql_has_gone_away_error.patch (5,178) 2011-02-18 02:11
http://tracker.in-portal.org/file_download.php?file_id=949&type=bug
patch improved_db_error_processing.patch (5,794) 2011-02-18 02:11
http://tracker.in-portal.org/file_download.php?file_id=950&type=bug
Issue History
2011-03-30 09:53 Dmitry Note Added: 0003322
2011-03-30 09:53 Dmitry Status resolved => closed
2011-02-19 06:13 alex Note Added: 0003278
2011-02-19 06:13 alex Status reviewed and tested => resolved
2011-02-19 06:13 alex Fixed in Version => 5.1.2-RC1
2011-02-19 06:13 alex Resolution open => fixed
2011-02-19 06:13 alex Assigned To !COMMUNITY => alex
2011-02-19 06:13 alex Changeset attached 5.1.x r14235
2011-02-18 16:58 Dmitry Note Added: 0003277
2011-02-18 16:58 Dmitry Status needs testing => reviewed and tested
2011-02-18 02:16 alex Target Version Icebox => 5.1.2
2011-02-18 02:16 alex Note Added: 0003271
2011-02-18 02:13 alex Relationship added parent of 0001002
2011-02-18 02:12 alex Note Added: 0003270
2011-02-18 02:11 alex File Added: improved_db_error_processing.patch
2011-02-18 02:11 alex File Added: processing_of_mysql_has_gone_away_error.patch
2011-01-25 04:22 alex Relationship added related to 0000973
2011-01-10 12:46 alex Relationship added related to 0000956
2010-12-30 07:01 alex Note Added: 0003124
2010-12-30 07:01 alex Assigned To => !COMMUNITY
2010-12-30 07:01 alex Developer => alex
2010-12-30 07:01 alex Status active => needs testing
2010-12-30 06:57 alex File Added: reset_db_error_before_each_query.patch
2010-12-14 10:20 alex New Issue
2010-12-14 10:20 alex Reference => https://groups.google.com/d/topic/in-portal-dev/-YTo16ihRy4/discussion
2010-12-14 10:20 alex Change Log Message => Fixes database query error reporting

Notes
(0003124)
alex   
2010-12-30 07:01   
To test:
1. find any 2 subsequent SELECT database queries in debugger report
2. find places in PHP code, where they are invoked
3. make error in first query
4. set DBG_SQL_FAILURE in debug.php to 0
5. display $this->Conn->getErrorCode() after both queries

When patch is not applied, then database error from 1st query will stay even after 2nd query execution was successful. After patch is applied, then there will be no error after 2nd query execution.
(0003270)
alex   
2011-02-18 02:12   
Patch "improved_db_error_processing.patch" is combination of "reset_db_error_before_each_query.patch" and "processing_of_mysql_has_gone_away_error.patch" patches, since when applied one after another merging conflict was created.

That's why patch "improved_db_error_processing.patch" should be tested here.
(0003271)
alex   
2011-02-18 02:16   
Moving to 5.1.2, since it's database error handing and catching an error, when it happens is a high priority.
(0003277)
Dmitry   
2011-02-18 16:58   
Patch "improved_db_error_processing.patch" tested good as part of 0001002 task and fully covers all patches in the task.

Ready to be committed to 5.1.2-RC1
(0003278)
alex   
2011-02-19 06:13   
Fix committed to 5.1.x branch. Commit Message:

Fixes 0000953: Incorrect database query error reporting
(0003322)
Dmitry   
2011-03-30 09:53   
Closing, since 5.1.2 release has been released.