mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
Moved cache cleaning code near the begin of functions. Sometimes
it wasnt' executed due to function ending. MDL-7196 Merged from MOODLE_17_STABLE
This commit is contained in:
parent
0163b1d098
commit
2fd40f8cbe
@ -1007,6 +1007,25 @@ function set_field($table, $newfield, $newvalue, $field1, $value1, $field2='', $
|
||||
|
||||
if (defined('MDL_PERFDB')) { global $PERF ; $PERF->dbqueries++; };
|
||||
|
||||
// Clear record_cache based on the parameters passed (individual record or whole table)
|
||||
if ($field1 == 'id') {
|
||||
if (isset($record_cache[$table][$value1])) {
|
||||
unset($record_cache[$table][$value1]);
|
||||
}
|
||||
} else if ($field2 == 'id') {
|
||||
if (isset($record_cache[$table][$value2])) {
|
||||
unset($record_cache[$table][$value2]);
|
||||
}
|
||||
} else if ($field3 == 'id') {
|
||||
if (isset($record_cache[$table][$value3])) {
|
||||
unset($record_cache[$table][$value3]);
|
||||
}
|
||||
} else {
|
||||
if (isset($record_cache[$table])) {
|
||||
unset($record_cache[$table]);
|
||||
}
|
||||
}
|
||||
|
||||
$select = where_clause($field1, $value1, $field2, $value2, $field3, $value3);
|
||||
|
||||
$dataobject = new StdClass;
|
||||
@ -1041,25 +1060,6 @@ function set_field($table, $newfield, $newvalue, $field1, $value1, $field2='', $
|
||||
}
|
||||
}
|
||||
|
||||
// Clear record_cache based on the parameters passed (individual record or whole table)
|
||||
if ($field1 == 'id') {
|
||||
if (isset($record_cache[$table][$value1])) {
|
||||
unset($record_cache[$table][$value1]);
|
||||
}
|
||||
} else if ($field2 == 'id') {
|
||||
if (isset($record_cache[$table][$value2])) {
|
||||
unset($record_cache[$table][$value2]);
|
||||
}
|
||||
} else if ($field3 == 'id') {
|
||||
if (isset($record_cache[$table][$value3])) {
|
||||
unset($record_cache[$table][$value3]);
|
||||
}
|
||||
} else {
|
||||
if (isset($record_cache[$table])) {
|
||||
unset($record_cache[$table]);
|
||||
}
|
||||
}
|
||||
|
||||
/// Arriving here, standard update
|
||||
return $db->Execute('UPDATE '. $CFG->prefix . $table .' SET '. $newfield .' = \''. $newvalue .'\' '. $select);
|
||||
}
|
||||
@ -1122,17 +1122,17 @@ function delete_records_select($table, $select='') {
|
||||
|
||||
global $CFG, $db, $record_cache;
|
||||
|
||||
// Clear record_cache (whole table)
|
||||
if (isset($record_cache[$table])) {
|
||||
unset($record_cache[$table]);
|
||||
}
|
||||
|
||||
if (defined('MDL_PERFDB')) { global $PERF ; $PERF->dbqueries++; };
|
||||
|
||||
if ($select) {
|
||||
$select = 'WHERE '.$select;
|
||||
}
|
||||
|
||||
// Clear record_cache (whole table)
|
||||
if (isset($record_cache[$table])) {
|
||||
unset($record_cache[$table]);
|
||||
}
|
||||
|
||||
return $db->Execute('DELETE FROM '. $CFG->prefix . $table .' '. $select);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user