From c72ff23fc766c1257f03fa24b4b667d734a13fcc Mon Sep 17 00:00:00 2001 From: skodak Date: Sun, 1 Jun 2008 16:19:00 +0000 Subject: [PATCH] MDL-14679 removed all instances of lobs related code --- lib/dmllib_todo.php | 182 -------------------------------------------- 1 file changed, 182 deletions(-) diff --git a/lib/dmllib_todo.php b/lib/dmllib_todo.php index b8dbf173c1..a63d469f31 100644 --- a/lib/dmllib_todo.php +++ b/lib/dmllib_todo.php @@ -784,188 +784,6 @@ function oracle_dirty_hack ($table, &$dataobject, $usecache = true) { } /// End of DIRTY HACK -/** - * This function will search for all the CLOBs and BLOBs fields passed in the dataobject, replacing - * their contents by the fixed strings '@#CLOB#@' and '@#BLOB#@' and returning one array for all the - * found CLOBS and another for all the found BLOBS - * Used by Oracle drivers to perform the two-step insertion/update of LOBs and - * by MSSQL to perform the same exclusively for BLOBs (IMAGE fields) - * - * This function is private and must not be used outside dmllib at all - * - * @param $table string the table where the record is going to be inserted/updated (without prefix) - * @param $dataobject object the object to be inserted/updated - * @param $clobs array of clobs detected - * @param $dataobject array of blobs detected - * @param $unset boolean to specify if we must unset found LOBs from the original object (true) or - * just return them modified to @#CLOB#@ and @#BLOB#@ (false) - * @param $usecache boolean flag to determinate if we must use the per request cache of metadata - * true to use it, false to ignore and delete it - */ -function db_detect_lobs ($table, &$dataobject, &$clobs, &$blobs, $unset = false, $usecache = true) { - -error('todo'); - global $CFG, $db, $metadata_cache; - - $dataarray = (array)$dataobject; //Convert to array. It's supposed that PHP 4.3 doesn't iterate over objects - -/// Initial configuration, based on DB - switch ($CFG->dbfamily) { - case 'oracle': - $clobdbtype = 'CLOB'; //Name of clobs for this DB - $blobdbtype = 'BLOB'; //Name of blobs for this DB - break; - case 'mssql': - $clobdbtype = 'NOTPROCESSES'; //Name of clobs for this DB (under mssql flavours we don't process CLOBS) - $blobdbtype = 'IMAGE'; //Name of blobs for this DB - break; - case 'postgres': - $clobdbtype = 'NOTPROCESSES'; //Name of clobs for this DB (under postgres flavours we don't process CLOBS) - $blobdbtype = 'BYTEA'; //Name of blobs for this DB - break; - default: - return; //Other DB doesn't need this two step to happen, prevent continue - } - -/// Init and delete metadata cache - if (!isset($metadata_cache) || !$usecache) { - $metadata_cache = array(); - } - -/// Get Meta info to know what to change, using the cached meta if exists - if (!isset($metadata_cache[$table])) { - $metadata_cache[$table] = array_change_key_case($db->MetaColumns($CFG->prefix . $table), CASE_LOWER); - } - $columns = $metadata_cache[$table]; - - foreach ($dataarray as $fieldname => $fieldvalue) { - /// If the field doesn't exist in metadata, skip - if (!isset($columns[strtolower($fieldname)])) { - continue; - } - /// If the field is CLOB, update its value to '@#CLOB#@' and store it in the $clobs array - if (strtoupper($columns[strtolower($fieldname)]->type) == $clobdbtype) { - /// Oracle optimization. CLOBs under 4000cc can be directly inserted (no need to apply 2-phases to them) - if ($CFG->dbfamily == 'oracle' && strlen($dataobject->$fieldname) < 4000) { - continue; - } - $clobs[$fieldname] = $dataobject->$fieldname; - if ($unset) { - unset($dataobject->$fieldname); - } else { - $dataobject->$fieldname = '@#CLOB#@'; - } - continue; - } - - /// If the field is BLOB OR IMAGE OR BYTEA, update its value to '@#BLOB#@' and store it in the $blobs array - if (strtoupper($columns[strtolower($fieldname)]->type) == $blobdbtype) { - $blobs[$fieldname] = $dataobject->$fieldname; - if ($unset) { - unset($dataobject->$fieldname); - } else { - $dataobject->$fieldname = '@#BLOB#@'; - } - continue; - } - } -} - -/** - * This function will iterate over $clobs and $blobs array, executing the needed - * UpdateClob() and UpdateBlob() ADOdb function calls to store LOBs contents properly - * Records to be updated are always searched by PK (id always!) - * - * Used by Orace CLOBS and BLOBS and MSSQL IMAGES - * - * This function is private and must not be used outside dmllib at all - * - * @param $table string the table where the record is going to be inserted/updated (without prefix) - * @param $sqlcondition mixed value defining the records to be LOB-updated. It it's a number, must point - * to the PK og the table (id field), else it's processed as one harcoded SQL condition (WHERE clause) - * @param $clobs array of clobs to be updated - * @param $blobs array of blobs to be updated - */ -function db_update_lobs ($table, $sqlcondition, &$clobs, &$blobs) { - -error('todo'); - - global $CFG, $db; - - $status = true; - -/// Initial configuration, based on DB - switch ($CFG->dbfamily) { - case 'oracle': - $clobdbtype = 'CLOB'; //Name of clobs for this DB - $blobdbtype = 'BLOB'; //Name of blobs for this DB - break; - case 'mssql': - $clobdbtype = 'NOTPROCESSES'; //Name of clobs for this DB (under mssql flavours we don't process CLOBS) - $blobdbtype = 'IMAGE'; //Name of blobs for this DB - break; - case 'postgres': - $clobdbtype = 'NOTPROCESSES'; //Name of clobs for this DB (under postgres flavours we don't process CLOBS) - $blobdbtype = 'BYTEA'; //Name of blobs for this DB - break; - default: - return; //Other DB doesn't need this two step to happen, prevent continue - } - -/// Calculate the update sql condition - if (is_numeric($sqlcondition)) { /// If passing a number, it's the PK of the table (id) - $sqlcondition = 'id=' . $sqlcondition; - } else { /// Else, it's a formal standard SQL condition, we try to delete the WHERE in case it exists - $sqlcondition = trim(preg_replace('/^WHERE/is', '', trim($sqlcondition))); - } - -/// Update all the clobs - if ($clobs) { - foreach ($clobs as $key => $value) { - - if (defined('MDL_PERFDB')) { global $PERF ; $PERF->dbqueries++; }; /// Count the extra updates in PERF - - /// Oracle CLOBs doesn't like quoted strings (are inserted via prepared statemets) - if ($CFG->dbfamily == 'oracle') { - $value = stripslashes_safe($value); - } - - if (!$db->UpdateClob($CFG->prefix.$table, $key, $value, $sqlcondition)) { - $status = false; - $statement = "UpdateClob('$CFG->prefix$table', '$key', '" . substr($value, 0, 100) . "...', '$sqlcondition')"; - debugging($db->ErrorMsg() ."

".s($statement)); - if (!empty($CFG->dblogerror)) { - $debug=array_shift(debug_backtrace()); - error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $statement"); - } - } - } - } -/// Update all the blobs - if ($blobs) { - foreach ($blobs as $key => $value) { - - if (defined('MDL_PERFDB')) { global $PERF ; $PERF->dbqueries++; }; /// Count the extra updates in PERF - - /// Oracle, MSSQL and PostgreSQL BLOBs doesn't like quoted strings (are inserted via prepared statemets) - if ($CFG->dbfamily == 'oracle' || $CFG->dbfamily == 'mssql' || $CFG->dbfamily == 'postgres') { - $value = stripslashes_safe($value); - } - - if(!$db->UpdateBlob($CFG->prefix.$table, $key, $value, $sqlcondition)) { - $status = false; - $statement = "UpdateBlob('$CFG->prefix$table', '$key', '" . substr($value, 0, 100) . "...', '$sqlcondition')"; - debugging($db->ErrorMsg() ."

".s($statement)); - if (!empty($CFG->dblogerror)) { - $debug=array_shift(debug_backtrace()); - error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $statement"); - } - } - } - } - return $status; -} - /** * This function is used to convert all the Oracle 1-space defaults to the empty string * like a really DIRTY HACK to allow it to work better until all those NOT NULL DEFAULT '' -- 2.39.5