From 56defc1153eb3f846da1678d2a3863094452654d Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Thu, 16 Jul 2009 11:51:09 +0000 Subject: [PATCH] optimize: skip unneeded code in case BLOB streaming is not available --- tbl_replace.php | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/tbl_replace.php b/tbl_replace.php index 5b20fb4a3..e41ee12db 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -54,6 +54,7 @@ if (! defined('PMA_NO_VARIABLES_IMPORT')) { * Gets some core libraries */ require_once './libraries/common.inc.php'; +$blob_streaming_active = $_SESSION['PMA_Config']->get('BLOBSTREAMING_PLUGINS_EXIST'); // Check parameters PMA_checkParameters(array('db', 'table', 'goto')); @@ -94,6 +95,7 @@ if (isset($_REQUEST['after_insert']) $meta = PMA_DBI_get_fields_meta($res); // must find a unique condition based on unique key, // not a combination of all fields + // (the following is a real assignment) if ($tmp = PMA_getUniqueCondition($res, count($meta), $meta, $row, true)) { $_SESSION['edit_next'] = $tmp; } @@ -207,7 +209,9 @@ foreach ($loop_array as $rowcount => $primary_key) { ? $_REQUEST['auto_increment']['multi_edit'][$rowcount] : null; - $primary_field = PMA_BS_GetPrimaryField($GLOBALS['db'], $GLOBALS['table']); + if ($blob_streaming_active) { + $primary_field = PMA_BS_GetPrimaryField($GLOBALS['db'], $GLOBALS['table']); + } // Fetch the current values of a row to use in case we have a protected field // @todo possibly move to ./libraries/tbl_replace_fields.inc.php @@ -226,30 +230,28 @@ foreach ($loop_array as $rowcount => $primary_key) { require './libraries/tbl_replace_fields.inc.php'; // rajk - for blobstreaming - if (NULL != $primary_field || strlen($primary_field) > 0) - { - $remove_blob_repo = isset($_REQUEST['remove_blob_repo_' . $key]) ? $_REQUEST['remove_blob_repo_' . $key] : NULL; - $upload_blob_repo = isset($_REQUEST['upload_blob_repo_' . $key]) ? $_REQUEST['upload_blob_repo_' . $key] : NULL; + if ($blob_streaming_active && (NULL != $primary_field || strlen($primary_field) > 0)) { + $remove_blob_repo = isset($_REQUEST['remove_blob_repo_' . $key]) ? $_REQUEST['remove_blob_repo_' . $key] : NULL; + $upload_blob_repo = isset($_REQUEST['upload_blob_repo_' . $key]) ? $_REQUEST['upload_blob_repo_' . $key] : NULL; - // checks if an existing blob repository reference should be removed - if (isset($remove_blob_repo) && !isset($upload_blob_repo)) - { - $remove_blob_reference = $_REQUEST['remove_blob_ref_' . $key]; - - if (isset($remove_blob_reference)) - $val = "''"; + // checks if an existing blob repository reference should be removed + if (isset($remove_blob_repo) && !isset($upload_blob_repo)) { + $remove_blob_reference = $_REQUEST['remove_blob_ref_' . $key]; + if (isset($remove_blob_reference)) { + $val = "''"; } // checks if this field requires a bs reference attached to it - if (isset($upload_blob_repo)) - { + if (isset($upload_blob_repo)) { // get the most recent BLOB reference - $bs_reference = PMA_File::getRecentBLOBReference(); + $bs_reference = PMA_File::getRecentBLOBReference(); - // if the most recent BLOB reference exists, set it as a field value - if (!is_null($bs_reference)) - $val = "'" . PMA_sqlAddslashes($bs_reference) . "'"; + // if the most recent BLOB reference exists, set it as a field value + if (!is_null($bs_reference)) { + $val = "'" . PMA_sqlAddslashes($bs_reference) . "'"; + } } + } } if (empty($me_funcs[$key])) { @@ -360,6 +362,7 @@ foreach ($query as $single_query) { if (! $result) { $error_messages[] = PMA_DBI_getError(); } else { + // the following is a real assignment: if ($tmp = @PMA_DBI_affected_rows()) { $total_affected_rows += $tmp; }