Index: trunk/phase3/includes/db/DatabaseMysql.php |
— | — | @@ -154,18 +154,8 @@ |
155 | 155 | /** |
156 | 156 | * @return bool |
157 | 157 | */ |
158 | | - function close() { |
159 | | - $this->mOpened = false; |
160 | | - if ( $this->mConn ) { |
161 | | - if ( $this->trxLevel() ) { |
162 | | - $this->commit( __METHOD__ ); |
163 | | - } |
164 | | - $ret = mysql_close( $this->mConn ); |
165 | | - $this->mConn = false; |
166 | | - return $ret; |
167 | | - } else { |
168 | | - return true; |
169 | | - } |
| 158 | + protected function closeConnection() { |
| 159 | + return mysql_close( $this->mConn ); |
170 | 160 | } |
171 | 161 | |
172 | 162 | /** |
Index: trunk/phase3/includes/db/DatabaseOracle.php |
— | — | @@ -288,18 +288,8 @@ |
289 | 289 | * Returns success, true if already closed |
290 | 290 | * @return bool |
291 | 291 | */ |
292 | | - function close() { |
293 | | - $this->mOpened = false; |
294 | | - if ( $this->mConn ) { |
295 | | - if ( $this->mTrxLevel ) { |
296 | | - $this->commit( __METHOD__ ); |
297 | | - } |
298 | | - $ret = oci_close( $this->mConn ); |
299 | | - $this->mConn = null; |
300 | | - return null; |
301 | | - } else { |
302 | | - return true; |
303 | | - } |
| 292 | + protected function closeConnection() { |
| 293 | + return oci_close( $this->mConn ); |
304 | 294 | } |
305 | 295 | |
306 | 296 | function execFlags() { |
Index: trunk/phase3/includes/db/DatabasePostgres.php |
— | — | @@ -240,15 +240,8 @@ |
241 | 241 | * Returns success, true if already closed |
242 | 242 | * @return bool |
243 | 243 | */ |
244 | | - function close() { |
245 | | - $this->mOpened = false; |
246 | | - if ( $this->mConn ) { |
247 | | - $ret = pg_close( $this->mConn ); |
248 | | - $this->mConn = null; |
249 | | - return $ret; |
250 | | - } else { |
251 | | - return true; |
252 | | - } |
| 244 | + protected function closeConnection() { |
| 245 | + return pg_close( $this->mConn ); |
253 | 246 | } |
254 | 247 | |
255 | 248 | protected function doQuery( $sql ) { |
Index: trunk/phase3/includes/db/DatabaseIbm_db2.php |
— | — | @@ -557,18 +557,8 @@ |
558 | 558 | * Returns success, true if already closed |
559 | 559 | * @return bool |
560 | 560 | */ |
561 | | - public function close() { |
562 | | - $this->mOpened = false; |
563 | | - if ( $this->mConn ) { |
564 | | - if ( $this->trxLevel() > 0 ) { |
565 | | - $this->commit( __METHOD__ ); |
566 | | - } |
567 | | - $ret = db2_close( $this->mConn ); |
568 | | - $this->mConn = null; |
569 | | - return $ret; |
570 | | - } else { |
571 | | - return true; |
572 | | - } |
| 561 | + protected function closeConnection() { |
| 562 | + return db2_close( $this->mConn ); |
573 | 563 | } |
574 | 564 | |
575 | 565 | /** |
Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -733,12 +733,28 @@ |
734 | 734 | * |
735 | 735 | * @return Bool operation success. true if already closed. |
736 | 736 | */ |
737 | | - function close() { |
738 | | - # Stub, should probably be overridden |
739 | | - return true; |
| 737 | + public function close() { |
| 738 | + $this->mOpened = false; |
| 739 | + if ( $this->mConn ) { |
| 740 | + if ( $this->trxLevel() ) { |
| 741 | + $this->commit( __METHOD__ ); |
| 742 | + } |
| 743 | + $ret = $this->closeConnection(); |
| 744 | + $this->mConn = false; |
| 745 | + return $ret; |
| 746 | + } else { |
| 747 | + return true; |
| 748 | + } |
740 | 749 | } |
741 | 750 | |
742 | 751 | /** |
| 752 | + * Closes underlying database connection |
| 753 | + * @since 1.20 |
| 754 | + * @return bool: Whether connection was closed successfully |
| 755 | + */ |
| 756 | + protected abstract function closeConnection(); |
| 757 | + |
| 758 | + /** |
743 | 759 | * @param $error String: fallback error message, used if none is given by DB |
744 | 760 | */ |
745 | 761 | function reportConnectionError( $error = 'Unknown error' ) { |
Index: trunk/phase3/includes/db/DatabaseMssql.php |
— | — | @@ -110,15 +110,8 @@ |
111 | 111 | * Returns success, true if already closed |
112 | 112 | * @return bool |
113 | 113 | */ |
114 | | - function close() { |
115 | | - $this->mOpened = false; |
116 | | - if ( $this->mConn ) { |
117 | | - $ret = sqlsrv_close( $this->mConn ); |
118 | | - $this->mConn = null; |
119 | | - return $ret; |
120 | | - } else { |
121 | | - return true; |
122 | | - } |
| 114 | + protected function closeConnection() { |
| 115 | + return sqlsrv_close( $this->mConn ); |
123 | 116 | } |
124 | 117 | |
125 | 118 | protected function doQuery( $sql ) { |
Index: trunk/phase3/includes/db/DatabaseSqlite.php |
— | — | @@ -115,16 +115,11 @@ |
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
119 | | - * Close an SQLite database |
120 | | - * |
| 119 | + * Does not actually close the connection, just destroys the reference for GC to do its work |
121 | 120 | * @return bool |
122 | 121 | */ |
123 | | - function close() { |
124 | | - $this->mOpened = false; |
125 | | - if ( is_object( $this->mConn ) ) { |
126 | | - if ( $this->trxLevel() ) $this->commit( __METHOD__ ); |
127 | | - $this->mConn = null; |
128 | | - } |
| 122 | + protected function closeConnection() { |
| 123 | + $this->mConn = null; |
129 | 124 | return true; |
130 | 125 | } |
131 | 126 | |