Last active
December 14, 2015 18:28
-
-
Save tai2/5129172 to your computer and use it in GitHub Desktop.
A patch to ADODB Active Record cache bug.
c.f. http://phplens.com/lens/lensforum/msgs.php?id=18288&x=1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/concrete/libraries/3rdparty/adodb/adodb-active-record.inc.php b/src/concrete/libraries/3rdparty/adodb/adodb-active-record.inc.php | |
index 474f2a7..4a214ed 100644 | |
--- a/src/concrete/libraries/3rdparty/adodb/adodb-active-record.inc.php | |
+++ b/src/concrete/libraries/3rdparty/adodb/adodb-active-record.inc.php | |
@@ -343,20 +343,11 @@ class ADODB_Active_Record { | |
$table = $this->_table; | |
$tables = $activedb->tables; | |
$tableat = $this->_tableat; | |
- if (!$forceUpdate && !empty($tables[$tableat])) { | |
- | |
- $tobj = $tables[$tableat]; | |
- foreach($tobj->flds as $name => $fld) { | |
- if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value)) | |
- $this->$name = $fld->default_value; | |
- else | |
- $this->$name = null; | |
- } | |
- return; | |
- } | |
$db = $activedb->db; | |
$fname = $ADODB_CACHE_DIR . '/adodb_' . $db->databaseType . '_active_'. $table . '.cache'; | |
- if (!$forceUpdate && $ADODB_ACTIVE_CACHESECS && $ADODB_CACHE_DIR && file_exists($fname)) { | |
+ if (!$forceUpdate && !empty($tables[$tableat])) { | |
+ | |
+ if ($ADODB_ACTIVE_CACHESECS && $ADODB_CACHE_DIR && file_exists($fname)) { | |
$fp = fopen($fname,'r'); | |
@flock($fp, LOCK_SH); | |
$acttab = unserialize(fread($fp,100000)); | |
@@ -364,13 +355,25 @@ class ADODB_Active_Record { | |
if ($acttab->_created + $ADODB_ACTIVE_CACHESECS - (abs(rand()) % 16) > time()) { | |
// abs(rand()) randomizes deletion, reducing contention to delete/refresh file | |
// ideally, you should cache at least 32 secs | |
- $activedb->tables[$table] = $acttab; | |
+ $tables[$table] = $acttab; | |
//if ($db->debug) ADOConnection::outp("Reading cached active record file: $fname"); | |
- return; | |
} else if ($db->debug) { | |
ADOConnection::outp("Refreshing cached active record file: $fname"); | |
} | |
+ } | |
+ | |
+ if (!empty($tables[$tableat])) { | |
+ | |
+ $tobj = $tables[$tableat]; | |
+ foreach($tobj->flds as $name => $fld) { | |
+ if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value)) | |
+ $this->$name = $fld->default_value; | |
+ else | |
+ $this->$name = null; | |
+ } | |
+ return; | |
+ } | |
} | |
$activetab = new ADODB_Active_Table(); | |
$activetab->name = $table; | |
@@ -974,4 +977,4 @@ global $_ADODB_ACTIVE_DBS; | |
return $arr; | |
} | |
-?> | |
\ No newline at end of file | |
+?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment