Skip to content

Commit

Permalink
optimize: skip unneeded code in case BLOB streaming is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
lem9 committed Jul 16, 2009
1 parent 9b4ee15 commit 56defc1
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions tbl_replace.php
Expand Up @@ -54,6 +54,7 @@
* 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'));
Expand Down Expand Up @@ -94,6 +95,7 @@
$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;
}
Expand Down Expand Up @@ -207,7 +209,9 @@
? $_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
Expand All @@ -226,30 +230,28 @@
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;

// 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 = "''";
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 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])) {
Expand Down Expand Up @@ -360,6 +362,7 @@
if (! $result) {
$error_messages[] = PMA_DBI_getError();
} else {
// the following is a real assignment:
if ($tmp = @PMA_DBI_affected_rows()) {
$total_affected_rows += $tmp;
}
Expand Down

0 comments on commit 56defc1

Please sign in to comment.