optimization: do not verify each time the presence of blobstreaming plugins; coding standard
This commit is contained in:
@@ -15,6 +15,8 @@
|
|||||||
* @uses PMA_BS_SetVariables()
|
* @uses PMA_BS_SetVariables()
|
||||||
* @uses PMA_BS_GetVariables()
|
* @uses PMA_BS_GetVariables()
|
||||||
* @uses PMA_BS_SetFieldReferences()
|
* @uses PMA_BS_SetFieldReferences()
|
||||||
|
* @uses PMA_cacheSet()
|
||||||
|
* @uses PMA_cacheGet()
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function checkBLOBStreamingPlugins()
|
function checkBLOBStreamingPlugins()
|
||||||
@@ -23,8 +25,20 @@ function checkBLOBStreamingPlugins()
|
|||||||
$PMA_Config = $_SESSION['PMA_Config'];
|
$PMA_Config = $_SESSION['PMA_Config'];
|
||||||
|
|
||||||
// return if unable to load PMA configuration
|
// return if unable to load PMA configuration
|
||||||
if (empty($PMA_Config))
|
if (empty($PMA_Config)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// At this point we might already know that plugins do not exist
|
||||||
|
// because this was recorded in the session (cache).
|
||||||
|
if (PMA_cacheGet('skip_blobstreaming', true)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we don't know that we can skip blobstreaming, we continue
|
||||||
|
// verifications; anyway, in case we won't skip blobstreaming,
|
||||||
|
// we still need to set some variables in non-persistent settings,
|
||||||
|
// which is done via $PMA_Config->set().
|
||||||
|
|
||||||
/** Retrieve current server configuration;
|
/** Retrieve current server configuration;
|
||||||
* at this point, $PMA_Config->get('Servers') contains the server parameters
|
* at this point, $PMA_Config->get('Servers') contains the server parameters
|
||||||
@@ -81,9 +95,7 @@ function checkBLOBStreamingPlugins()
|
|||||||
// set variable indicating BS plugin existence
|
// set variable indicating BS plugin existence
|
||||||
$PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', $allPluginsExist);
|
$PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', $allPluginsExist);
|
||||||
|
|
||||||
// do the plugins exist?
|
if ($allPluginsExist) {
|
||||||
if ($allPluginsExist)
|
|
||||||
{
|
|
||||||
// retrieve BS variables from PMA configuration
|
// retrieve BS variables from PMA configuration
|
||||||
$bs_set_variables = array();
|
$bs_set_variables = array();
|
||||||
|
|
||||||
@@ -99,24 +111,27 @@ function checkBLOBStreamingPlugins()
|
|||||||
$bs_variables = PMA_BS_GetVariables();
|
$bs_variables = PMA_BS_GetVariables();
|
||||||
|
|
||||||
// if no BS variables exist, set plugin existence to false and return
|
// if no BS variables exist, set plugin existence to false and return
|
||||||
if (count($bs_variables) <= 0)
|
if (count($bs_variables) <= 0) {
|
||||||
{
|
|
||||||
$PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', FALSE);
|
$PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', FALSE);
|
||||||
|
PMA_cacheSet('skip_blobstreaming', true, true);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} // end if (count($bs_variables) <= 0)
|
} // end if (count($bs_variables) <= 0)
|
||||||
|
|
||||||
// switch on BS field references
|
// switch on BS field references
|
||||||
if (strtolower($bs_variables[$PMA_Config->get('PBMS_NAME') . '_field_references']) == "off")
|
if (strtolower($bs_variables[$PMA_Config->get('PBMS_NAME') . '_field_references']) == "off") {
|
||||||
if(!PMA_BS_SetFieldReferences('ON'))
|
if (! PMA_BS_SetFieldReferences('ON')) {
|
||||||
return FALSE;
|
PMA_cacheSet('skip_blobstreaming', true, true);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// get BS server port
|
// get BS server port
|
||||||
$BS_PORT = $bs_variables[$PMA_Config->get('PBMS_NAME') . '_port'];
|
$BS_PORT = $bs_variables[$PMA_Config->get('PBMS_NAME') . '_port'];
|
||||||
|
|
||||||
// if no BS server port exists, set plugin existance to false and return
|
// if no BS server port exists, set plugin existance to false and return
|
||||||
if (!$BS_PORT)
|
if (! $BS_PORT) {
|
||||||
{
|
|
||||||
$PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', FALSE);
|
$PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', FALSE);
|
||||||
|
PMA_cacheSet('skip_blobstreaming', true, true);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} // end if (!$BS_PORT)
|
} // end if (!$BS_PORT)
|
||||||
|
|
||||||
@@ -128,14 +143,12 @@ function checkBLOBStreamingPlugins()
|
|||||||
$PMA_Config->set('FILEINFO_EXISTS', FALSE);
|
$PMA_Config->set('FILEINFO_EXISTS', FALSE);
|
||||||
|
|
||||||
// check if CURL exists
|
// check if CURL exists
|
||||||
if (function_exists("curl_init"))
|
if (function_exists("curl_init")) {
|
||||||
{
|
|
||||||
// initialize curl handler
|
// initialize curl handler
|
||||||
$curlHnd = curl_init();
|
$curlHnd = curl_init();
|
||||||
|
|
||||||
// CURL exists, set necessary variable and close resource
|
// CURL exists, set necessary variable and close resource
|
||||||
if (!empty($curlHnd))
|
if (! empty($curlHnd)) {
|
||||||
{
|
|
||||||
$PMA_Config->set('CURL_EXISTS', TRUE);
|
$PMA_Config->set('CURL_EXISTS', TRUE);
|
||||||
curl_close($curlHnd);
|
curl_close($curlHnd);
|
||||||
} // end if (!empty($curlHnd))
|
} // end if (!empty($curlHnd))
|
||||||
@@ -144,18 +157,19 @@ function checkBLOBStreamingPlugins()
|
|||||||
// check if PECL's fileinfo library exist
|
// check if PECL's fileinfo library exist
|
||||||
$finfo = NULL;
|
$finfo = NULL;
|
||||||
|
|
||||||
if (function_exists("finfo_open"))
|
if (function_exists("finfo_open")) {
|
||||||
$finfo = finfo_open(FILEINFO_MIME);
|
$finfo = finfo_open(FILEINFO_MIME);
|
||||||
|
}
|
||||||
|
|
||||||
// fileinfo library exists, set necessary variable and close resource
|
// fileinfo library exists, set necessary variable and close resource
|
||||||
if (!empty($finfo))
|
if (! empty($finfo)) {
|
||||||
{
|
|
||||||
$PMA_Config->set('FILEINFO_EXISTS', TRUE);
|
$PMA_Config->set('FILEINFO_EXISTS', TRUE);
|
||||||
finfo_close($finfo);
|
finfo_close($finfo);
|
||||||
} // end if (!empty($finfo))
|
} // end if (!empty($finfo))
|
||||||
} // end if ($allPluginsExist)
|
} else {
|
||||||
else
|
PMA_cacheSet('skip_blobstreaming', true, true);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
} // end if ($allPluginsExist)
|
||||||
|
|
||||||
$bs_tables = array();
|
$bs_tables = array();
|
||||||
|
|
||||||
@@ -228,9 +242,7 @@ function checkBLOBStreamableDatabases()
|
|||||||
// load PMA configuration
|
// load PMA configuration
|
||||||
$PMA_Config = $_SESSION['PMA_Config'];
|
$PMA_Config = $_SESSION['PMA_Config'];
|
||||||
|
|
||||||
// return if unable to load PMA configuration
|
$serverCfg = $GLOBALS['cfg']['Server'];
|
||||||
if (empty($PMA_Config))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// retrieve BS tables from PMA configuration
|
// retrieve BS tables from PMA configuration
|
||||||
$session_bs_tables = $PMA_Config->get('BLOBSTREAMING_TABLES');
|
$session_bs_tables = $PMA_Config->get('BLOBSTREAMING_TABLES');
|
||||||
|
@@ -976,8 +976,9 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
|||||||
|
|
||||||
// rajk - checks for blobstreaming plugins and databases that support
|
// rajk - checks for blobstreaming plugins and databases that support
|
||||||
// blobstreaming (by having the necessary tables for blobstreaming)
|
// blobstreaming (by having the necessary tables for blobstreaming)
|
||||||
if (checkBLOBStreamingPlugins())
|
if (checkBLOBStreamingPlugins()) {
|
||||||
checkBLOBStreamableDatabases();
|
checkBLOBStreamableDatabases();
|
||||||
|
}
|
||||||
} // end if !defined('PMA_MINIMUM_COMMON')
|
} // end if !defined('PMA_MINIMUM_COMMON')
|
||||||
|
|
||||||
// remove sensitive values from session
|
// remove sensitive values from session
|
||||||
|
Reference in New Issue
Block a user