Skip to content

Commit

Permalink
Merge pull request #121 from internetarchive/schema-rewrtie
Browse files Browse the repository at this point in the history
Close handles
  • Loading branch information
cyberpower678 committed Jan 16, 2024
2 parents d072c7a + 24105eb commit 297aa49
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1,940 deletions.
9 changes: 8 additions & 1 deletion app/src/html/Includes/DB2.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ public function __construct() {
$this->createUserPreferencesTable();
if ( defined( 'IABOTOFFLOADEDTABLES' ) ) {
$this->offloaded = unserialize( IABOTOFFLOADEDTABLES );
$this->connectOffloadDB();
foreach( $this->offloaded as $connectionData ) {
$this->offloadedTables = [];
foreach( $connectionData['offload'] as $table => $junk ) {
$this->offloadedTables[$table] = [];
}
}
}
}

Expand Down Expand Up @@ -428,6 +433,7 @@ public function queryDB( $query, $noOffload = false ) {
$parts = explode( '.', $fromString );
$whichTable = trim( array_pop( $parts ) );
if ( $isSelect && isset( $this->offloadedTables[$whichTable] ) ) {
if( empty( $this->offloadedTables[$whichTable] ) ) $this->connectOffloadDB();
$response = mysqli_query( $this->offloadedTables[$whichTable][0], str_replace( $fromString, $whichTable, $query) );
if ( $response !== false ) $return->addResultObject( $response );
}
Expand Down Expand Up @@ -479,5 +485,6 @@ public function getAffectedRows() {

public function __destruct() {
mysqli_close( $this->db );
foreach( $this->offloadedDBs as $db ) mysqli_close( $db );
}
}
Loading

0 comments on commit 297aa49

Please sign in to comment.