[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_5RC1-18583-gdd0b139

Madhura Jayaratne madhuracj at users.sourceforge.net
Sat Sep 10 19:32:51 CEST 2011


The branch, master has been updated
       via  dd0b1399e0808a20c5a6ec5b5444ab4ee8900e93 (commit)
       via  ef86c8d879760cf5ff779b94a7249d90a39787c9 (commit)
      from  5fd403f3267c7945c121fb74b1251be25d44937e (commit)


- Log -----------------------------------------------------------------
commit dd0b1399e0808a20c5a6ec5b5444ab4ee8900e93
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Sat Sep 10 22:59:47 2011 +0530

    Coding style improvements for blobstreaming.lib.php

commit ef86c8d879760cf5ff779b94a7249d90a39787c9
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Sat Sep 10 22:36:58 2011 +0530

    Coding style improvements for Advisor.class.php

-----------------------------------------------------------------------

Summary of changes:
 libraries/Advisor.class.php     |  156 ++++++++++++++++++++++--------------
 libraries/blobstreaming.lib.php |  168 ++++++++++++++++++++++++---------------
 2 files changed, 200 insertions(+), 124 deletions(-)

diff --git a/libraries/Advisor.class.php b/libraries/Advisor.class.php
index 533fe88..b43455c 100644
--- a/libraries/Advisor.class.php
+++ b/libraries/Advisor.class.php
@@ -13,7 +13,8 @@ class Advisor
     var $parseResult;
     var $runResult;
 
-    function run() {
+    function run()
+    {
         // HowTo: A simple Advisory system in 3 easy steps.
 
         // Step 1: Get some variables to evaluate on
@@ -22,10 +23,13 @@ class Advisor
             PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1)
         );
         if (PMA_DRIZZLE) {
-            $this->variables = array_merge($this->variables,
+            $this->variables = array_merge(
+                $this->variables,
                 PMA_DBI_fetch_result(
                     "SELECT concat('Com_', variable_name), variable_value
-                    FROM data_dictionary.GLOBAL_STATEMENTS", 0, 1));
+                    FROM data_dictionary.GLOBAL_STATEMENTS", 0, 1
+                )
+            );
         }
         // Add total memory to variables as well
         include_once 'libraries/sysinfo.lib.php';
@@ -38,10 +42,14 @@ class Advisor
         // Step 3: Feed the variables to the rules and let them fire. Sets $runResult
         $this->runRules();
 
-        return array('parse' => array('errors' => $this->parseResult['errors']), 'run' => $this->runResult);
+        return array(
+            'parse' => array('errors' => $this->parseResult['errors']),
+            'run'   => $this->runResult
+        );
     }
 
-    function runRules() {
+    function runRules()
+    {
         $this->runResult = array(
             'fired' => array(),
             'notfired' => array(),
@@ -57,7 +65,9 @@ class Advisor
                 try {
                      $precond = $this->ruleExprEvaluate($rule['precondition']);
                 } catch (Exception $e) {
-                    $this->runResult['errors'][] = 'Failed evaluating precondition for rule \''.$rule['name'].'\'. PHP threw following error: '.$e->getMessage();
+                    $this->runResult['errors'][] = 'Failed evaluating precondition for rule \''
+                        . $rule['name'] . '\'. PHP threw following error: '
+                        . $e->getMessage();
                     continue;
                 }
             }
@@ -68,7 +78,9 @@ class Advisor
                 try {
                     $value = $this->ruleExprEvaluate($rule['formula']);
                 } catch(Exception $e) {
-                    $this->runResult['errors'][] = 'Failed calculating value for rule \''.$rule['name'].'\'. PHP threw following error: '.$e->getMessage();
+                    $this->runResult['errors'][] = 'Failed calculating value for rule \''
+                        . $rule['name'] . '\'. PHP threw following error: '
+                        . $e->getMessage();
                     continue;
                 }
 
@@ -81,7 +93,9 @@ class Advisor
                         $this->addRule('notfired', $rule);
                     }
                 }  catch(Exception $e) {
-                    $this->runResult['errors'][] = 'Failed running test for rule \''.$rule['name'].'\'. PHP threw following error: '.$e->getMessage();
+                    $this->runResult['errors'][] = 'Failed running test for rule \''
+                        . $rule['name'] . '\'. PHP threw following error: '
+                        . $e->getMessage();
                 }
             }
         }
@@ -92,12 +106,13 @@ class Advisor
     /**
      * Escapes percent string to be used in format string.
      *
-     * @param string $str
+     * @param string $str string to escape
+     *
      * @return string
      */
     function escapePercent($str)
     {
-        return preg_replace('/%( |,|\.|$)/','%%\1', $str);
+        return preg_replace('/%( |,|\.|$)/', '%%\1', $str);
     }
 
     /**
@@ -105,6 +120,7 @@ class Advisor
      *
      * @param string $str
      * @param mixed  $param
+     *
      * @return string
      */
     function translate($str, $param = null)
@@ -124,6 +140,7 @@ class Advisor
      * Splits justification to text and formula.
      *
      * @param string $rule
+     *
      * @return array
      */
     function splitJustification($rule)
@@ -131,7 +148,7 @@ class Advisor
         $jst = preg_split('/\s*\|\s*/', $rule['justification'], 2);
         if (count($jst) > 1) {
             return array($jst[0], $jst[1]);
-       }
+        }
         return array($rule['justification']);
     }
 
@@ -139,42 +156,44 @@ class Advisor
     function addRule($type, $rule)
     {
         switch($type) {
-            case 'notfired':
-            case 'fired':
-                $jst = Advisor::splitJustification($rule);
-                if (count($jst) > 1) {
-                    try {
-                        /* Translate */
-                        $str = $this->translate($jst[0], $jst[1]);
-                    } catch (Exception $e) {
-                        $this->runResult['errors'][] = sprintf(
-                            __('Failed formatting string for rule \'%s\'. PHP threw following error: %s'),
-                            $rule['name'],
-                            $e->getMessage()
-                        );
-                        return;
-                    }
-
-                    $rule['justification'] = $str;
-                } else {
-                    $rule['justification'] = $this->translate($rule['justification']);
+        case 'notfired':
+        case 'fired':
+            $jst = Advisor::splitJustification($rule);
+            if (count($jst) > 1) {
+                try {
+                    /* Translate */
+                    $str = $this->translate($jst[0], $jst[1]);
+                } catch (Exception $e) {
+                    $this->runResult['errors'][] = sprintf(
+                        __('Failed formatting string for rule \'%s\'. PHP threw following error: %s'),
+                        $rule['name'],
+                        $e->getMessage()
+                    );
+                    return;
                 }
-                $rule['name'] = $this->translate($rule['name']);
-                $rule['issue'] = $this->translate($rule['issue']);
-
-                // Replaces {server_variable} with 'server_variable' linking to server_variables.php
-                $rule['recommendation'] = preg_replace(
-                    '/\{([a-z_0-9]+)\}/Ui',
-                    '<a href="server_variables.php?' . PMA_generate_common_url() . '#filter=\1">\1</a>',
-                    $this->translate($rule['recommendation']));
-
-                // Replaces external Links with PMA_linkURL() generated links
-                $rule['recommendation'] = preg_replace(
-                    '#href=("|\')(https?://[^\1]+)\1#ie',
-                    '\'href="\' . PMA_linkURL("\2") . \'"\'',
-                    $rule['recommendation']
-                );
-                break;
+
+                $rule['justification'] = $str;
+            } else {
+                $rule['justification'] = $this->translate($rule['justification']);
+            }
+            $rule['name'] = $this->translate($rule['name']);
+            $rule['issue'] = $this->translate($rule['issue']);
+
+            // Replaces {server_variable} with 'server_variable'
+            // linking to server_variables.php
+            $rule['recommendation'] = preg_replace(
+                '/\{([a-z_0-9]+)\}/Ui',
+                '<a href="server_variables.php?' . PMA_generate_common_url() . '#filter=\1">\1</a>',
+                $this->translate($rule['recommendation'])
+            );
+
+            // Replaces external Links with PMA_linkURL() generated links
+            $rule['recommendation'] = preg_replace(
+                '#href=("|\')(https?://[^\1]+)\1#ie',
+                '\'href="\' . PMA_linkURL("\2") . \'"\'',
+                $rule['recommendation']
+            );
+            break;
         }
 
         $this->runResult[$type][] = $rule;
@@ -197,15 +216,24 @@ class Advisor
     }
 
     // Runs a code expression, replacing variable names with their respective values
-    // ignoreUntil: if > 0, it doesn't replace any variables until that string position, but still evaluates the whole expr
+    // ignoreUntil: if > 0, it doesn't replace any variables until that string
+    // position, but still evaluates the whole expr
     function ruleExprEvaluate($expr, $ignoreUntil = 0)
     {
         if ($ignoreUntil > 0) {
-            $exprIgnore = substr($expr,0,$ignoreUntil);
-            $expr = substr($expr,$ignoreUntil);
+            $exprIgnore = substr($expr, 0, $ignoreUntil);
+            $expr = substr($expr, $ignoreUntil);
         }
-        $expr = preg_replace_callback('/fired\s*\(\s*(\'|")(.*)\1\s*\)/Ui', array($this, 'ruleExprEvaluate_var1'), $expr);
-        $expr = preg_replace_callback('/\b(\w+)\b/', array($this, 'ruleExprEvaluate_var2'), $expr);
+        $expr = preg_replace_callback(
+            '/fired\s*\(\s*(\'|")(.*)\1\s*\)/Ui',
+            array($this, 'ruleExprEvaluate_var1'),
+            $expr
+        );
+        $expr = preg_replace_callback(
+            '/\b(\w+)\b/',
+            array($this, 'ruleExprEvaluate_var2'),
+            $expr
+        );
         if ($ignoreUntil > 0) {
             $expr = $exprIgnore . $expr;
         }
@@ -217,7 +245,9 @@ class Advisor
         $err = ob_get_contents();
         ob_end_clean();
         if ($err) {
-            throw new Exception(strip_tags($err) . '<br />Executed code: $value = '.$expr.';');
+            throw new Exception(
+                strip_tags($err) . '<br />Executed code: $value = ' . $expr . ';'
+            );
         }
         return $value;
     }
@@ -228,7 +258,7 @@ class Advisor
         $file = file('libraries/advisory_rules.txt');
         $errors = array();
         $rules = array();
-        $ruleSyntax = array('name','formula','test','issue','recommendation','justification');
+        $ruleSyntax = array('name', 'formula', 'test', 'issue', 'recommendation', 'justification');
         $numRules = count($ruleSyntax);
         $numLines = count($file);
         $j = -1;
@@ -243,14 +273,18 @@ class Advisor
             // Reading new rule
             if (substr($line, 0, 4) == 'rule') {
                 if ($ruleLine > 0) {
-                    $errors[] = 'Invalid rule declaration on line '.($i+1). ', expected line '.$ruleSyntax[$ruleLine++].' of previous rule' ;
+                    $errors[] = 'Invalid rule declaration on line ' . ($i+1)
+                        . ', expected line ' . $ruleSyntax[$ruleLine++]
+                        . ' of previous rule' ;
                     continue;
                 }
-                if (preg_match("/rule\s'(.*)'( \[(.*)\])?$/",$line,$match)) {
+                if (preg_match("/rule\s'(.*)'( \[(.*)\])?$/", $line, $match)) {
                     $ruleLine = 1;
                     $j++;
                     $rules[$j] = array( 'name' => $match[1]);
-                    if(isset($match[3])) $rules[$j]['precondition'] = $match[3];
+                    if (isset($match[3])) {
+                        $rules[$j]['precondition'] = $match[3];
+                    }
                 } else {
                     $errors[] = 'Invalid rule declaration on line '.($i+1);
                 }
@@ -272,7 +306,7 @@ class Advisor
                         . Expected tab, but found \''.$line[0].'\'';
                     continue;
                 }
-                $rules[$j][$ruleSyntax[$ruleLine++]] = chop(substr($line,1));
+                $rules[$j][$ruleSyntax[$ruleLine++]] = chop(substr($line, 1));
             }
 
             // Rule complete
@@ -288,12 +322,12 @@ class Advisor
 function PMA_bytime($num, $precision)
 {
     $per = '';
-    if ($num >= 1) { # per second
+    if ($num >= 1) { // per second
         $per = "per second";
-    } elseif ($num*60 >= 1) { # per minute
+    } elseif ($num*60 >= 1) { // per minute
         $num = $num*60;
         $per = "per minute";
-    } elseif ($num*60*60 >=1 ) { # per hour
+    } elseif ($num*60*60 >=1 ) { // per hour
         $num = $num*60*60;
         $per = "per hour";
     } else {
@@ -304,7 +338,7 @@ function PMA_bytime($num, $precision)
     $num = round($num, $precision);
 
     if ($num == 0) {
-        $num = '<'.pow(10,-$precision);
+        $num = '<' . pow(10, -$precision);
     }
 
     return "$num $per";
diff --git a/libraries/blobstreaming.lib.php b/libraries/blobstreaming.lib.php
index cdcbb0b..8d416d8 100644
--- a/libraries/blobstreaming.lib.php
+++ b/libraries/blobstreaming.lib.php
@@ -11,7 +11,8 @@
  */
 function initPBMSDatabase()
 {
-    $query = "create database IF NOT EXISTS pbms;"; // If no other choice then try this.
+    // If no other choice then try this.
+    $query = "create database IF NOT EXISTS pbms;";
     /*
      * The user may not have privileges to create the 'pbms' database
      * so if it doesn't exist then we perform a select on a pbms system
@@ -26,18 +27,21 @@ function initPBMSDatabase()
                 return true;
             }
             if ($target == "") {
-                if ($current_db != 'pbxt' && !PMA_is_system_schema($current_db, true)) {
+                if ($current_db != 'pbxt'
+                    && ! PMA_is_system_schema($current_db, true)
+                ) {
                     $target = $current_db;
                 }
             }
         }
 
         if ($target != "") {
-            $query = "select * from $target.pbms_metadata_header"; // If it exists this table will not contain much
+            // If it exists this table will not contain much
+            $query = "select * from $target.pbms_metadata_header";
         }
     }
 
-    $result = PMA_DBI_query($query );
+    $result = PMA_DBI_query($query);
     if (! $result) {
         return false;
     }
@@ -96,7 +100,7 @@ function checkBLOBStreamingPlugins()
     $has_blobstreaming = PMA_cacheGet('has_blobstreaming', true);
 
     if ($has_blobstreaming === null) {
-        if (!PMA_DRIZZLE && PMA_MYSQL_INT_VERSION >= 50109) {
+        if (! PMA_DRIZZLE && PMA_MYSQL_INT_VERSION >= 50109) {
 
             // Retrieve MySQL plugins
             $existing_plugins = PMA_DBI_fetch_result('SHOW PLUGINS');
@@ -104,19 +108,21 @@ function checkBLOBStreamingPlugins()
             foreach ($existing_plugins as $one_existing_plugin) {
                 // check if required plugins exist
                 if ( strtolower($one_existing_plugin['Library']) == 'libpbms.so'
-                    && $one_existing_plugin['Status'] == "ACTIVE") {
+                    && $one_existing_plugin['Status'] == "ACTIVE"
+                ) {
                     $has_blobstreaming = true;
                     break;
                 }
             }
             unset($existing_plugins, $one_existing_plugin);
         } else if (PMA_DRIZZLE) {
-            $has_blobstreaming = (bool)PMA_DBI_fetch_result(
+            $has_blobstreaming = (bool) PMA_DBI_fetch_result(
                 "SELECT 1
                 FROM data_dictionary.plugins
                 WHERE module_name = 'PBMS'
                     AND is_active = true
-                LIMIT 1");
+                LIMIT 1"
+            );
         }
         PMA_cacheSet('has_blobstreaming', $has_blobstreaming, true);
     }
@@ -124,7 +130,7 @@ function checkBLOBStreamingPlugins()
     // set variable indicating BS plugin existence
     $PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', $has_blobstreaming);
 
-    if (!$has_blobstreaming) {
+    if (! $has_blobstreaming) {
         PMA_cacheSet('skip_blobstreaming', true, true);
         return false;
     }
@@ -132,7 +138,7 @@ function checkBLOBStreamingPlugins()
     if ($has_blobstreaming) {
         $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) {
             $PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', false);
             PMA_cacheSet('skip_blobstreaming', true, true);
@@ -141,14 +147,15 @@ function checkBLOBStreamingPlugins()
         } // end if (count($bs_variables) <= 0)
 
         // Check that the required pbms functions exist:
-        if ((function_exists("pbms_connect") == false) ||
-            (function_exists("pbms_error") == false) ||
-            (function_exists("pbms_close") == false) ||
-            (function_exists("pbms_is_blob_reference") == false) ||
-            (function_exists("pbms_get_info") == false) ||
-            (function_exists("pbms_get_metadata_value") == false) ||
-            (function_exists("pbms_add_metadata") == false) ||
-            (function_exists("pbms_read_stream") == false)) {
+        if (function_exists("pbms_connect") == false
+            || function_exists("pbms_error") == false
+            || function_exists("pbms_close") == false
+            || function_exists("pbms_is_blob_reference") == false
+            || function_exists("pbms_get_info") == false
+            || function_exists("pbms_get_metadata_value") == false
+            || function_exists("pbms_add_metadata") == false
+            || function_exists("pbms_read_stream") == false
+        ) {
 
             // We should probably notify the user that they need to install
             // the pbms client lib and PHP extension to make use of blob streaming.
@@ -173,7 +180,8 @@ function checkBLOBStreamingPlugins()
          // get BS server port
         $BS_PORT = $bs_variables['pbms_port'];
 
-        // if no BS server port or 'pbms' database exists, set plugin existance to false and return
+        // if no BS server port or 'pbms' database exists,
+        // set plugin existance to false and return
         if ((! $BS_PORT) || (! initPBMSDatabase())) {
             $PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', false);
             PMA_cacheSet('skip_blobstreaming', true, true);
@@ -227,16 +235,16 @@ function checkBLOBStreamingPlugins()
  *
  * @access  public
  * @return  array - list of BLOBStreaming variables
-*/
+ */
 function PMA_BS_GetVariables()
 {
     // load PMA configuration
     $PMA_Config = $GLOBALS['PMA_Config'];
 
     // return if unable to load PMA configuration
-    if (empty($PMA_Config))
-        return NULL;
-
+    if (empty($PMA_Config)) {
+        return null;
+    }
     // run query to retrieve BS variables
     $query = "SHOW VARIABLES LIKE '%pbms%'";
     $result = PMA_DBI_query($query);
@@ -244,9 +252,9 @@ function PMA_BS_GetVariables()
     $BS_Variables = array();
 
     // while there are records to retrieve
-    while ($data = @PMA_DBI_fetch_assoc($result))
+    while ($data = @PMA_DBI_fetch_assoc($result)) {
         $BS_Variables[$data['Variable_name']] = $data['Value'];
-
+    }
     // return BS variables
     return $BS_Variables;
 }
@@ -254,6 +262,8 @@ function PMA_BS_GetVariables()
 /**
  * Retrieves and shows PBMS error.
  *
+ * @param sting $msg error message
+ *
  * @return nothing
  */
 function PMA_BS_ReportPBMSError($msg)
@@ -292,7 +302,10 @@ function PMA_do_connect($db_name, $quiet)
 
     if ($ok == false) {
         if ($quiet == false) {
-            PMA_BS_ReportPBMSError(__('PBMS connection failed:') . " pbms_connect($pbms_host, $pbms_port, $db_name)");
+            PMA_BS_ReportPBMSError(
+                __('PBMS connection failed:')
+                . " pbms_connect($pbms_host, $pbms_port, $db_name)"
+            );
         }
         return false;
     }
@@ -313,7 +326,7 @@ function PMA_do_disconnect()
  * Checks whether the BLOB reference looks valid
  *
  * @param string $bs_reference BLOB reference
- * @param string $db_name Database name
+ * @param string $db_name      Database name
  *
  * @return bool True on success.
  */
@@ -328,7 +341,7 @@ function PMA_BS_IsPBMSReference($bs_reference, $db_name)
     // requires one at this point so until the API is updated
     // we need to epen one here. If you use pool connections this
     // will not be a performance problem.
-     if (PMA_do_connect($db_name, false) == false) {
+    if (PMA_do_connect($db_name, false) == false) {
         return false;
     }
 
@@ -344,7 +357,10 @@ function PMA_BS_CreateReferenceLink($bs_reference, $db_name)
     }
 
     if (pbms_get_info(trim($bs_reference)) == false) {
-        PMA_BS_ReportPBMSError(__('PBMS get BLOB info failed:') . " pbms_get_info($bs_reference)");
+        PMA_BS_ReportPBMSError(
+            __('PBMS get BLOB info failed:')
+            . " pbms_get_info($bs_reference)"
+        );
         PMA_do_disconnect();
         return __('Error');
     }
@@ -352,7 +368,10 @@ function PMA_BS_CreateReferenceLink($bs_reference, $db_name)
     $content_type = pbms_get_metadata_value("Content-Type");
     if ($content_type == false) {
         $br = trim($bs_reference);
-        PMA_BS_ReportPBMSError("PMA_BS_CreateReferenceLink('$br', '$db_name'): " . __('PBMS get BLOB Content-Type failed'));
+        PMA_BS_ReportPBMSError(
+            "PMA_BS_CreateReferenceLink('$br', '$db_name'): "
+            . __('PBMS get BLOB Content-Type failed')
+        );
     }
 
     PMA_do_disconnect();
@@ -371,27 +390,37 @@ function PMA_BS_CreateReferenceLink($bs_reference, $db_name)
 
     // specify custom HTML for various content types
     switch ($content_type) {
-        // no content specified
-        case NULL:
-            $output = "NULL";
-            break;
-        // image content
-        case 'image/jpeg':
-        case 'image/png':
-            $output .= ' (<a href="' . $bs_url . '" target="new">' . __('View image') . '</a>)';
+    // no content specified
+    case null:
+        $output = "NULL";
+        break;
+    // image content
+    case 'image/jpeg':
+    case 'image/png':
+        $output .= ' (<a href="' . $bs_url . '" target="new">'
+            . __('View image') . '</a>)';
         break;
-        // audio content
-        case 'audio/mpeg':
-            $output .= ' (<a href="#" onclick="popupBSMedia(\'' . PMA_generate_common_url() . '\',\'' . urlencode($bs_reference) . '\', \'' . urlencode($content_type) . '\',' . ($is_custom_type ? 1 : 0) . ', 640, 120)">' . __('Play audio'). '</a>)';
-            break;
-        // video content
-        case 'application/x-flash-video':
-        case 'video/mpeg':
-            $output .= ' (<a href="#" onclick="popupBSMedia(\'' . PMA_generate_common_url() . '\',\'' . urlencode($bs_reference) . '\', \'' . urlencode($content_type) . '\',' . ($is_custom_type ? 1 : 0) . ', 640, 480)">' . __('View video') . '</a>)';
-            break;
-        // unsupported content. specify download
-        default:
-            $output .= ' (<a href="' . $bs_url . '" target="new">' . __('Download file'). '</a>)';
+    // audio content
+    case 'audio/mpeg':
+        $output .= ' (<a href="#" onclick="popupBSMedia(\''
+            . PMA_generate_common_url() . '\',\'' . urlencode($bs_reference)
+            . '\', \'' . urlencode($content_type) . '\','
+            . ($is_custom_type ? 1 : 0) . ', 640, 120)">' . __('Play audio')
+            . '</a>)';
+        break;
+    // video content
+    case 'application/x-flash-video':
+    case 'video/mpeg':
+        $output .= ' (<a href="#" onclick="popupBSMedia(\''
+            . PMA_generate_common_url() . '\',\'' . urlencode($bs_reference)
+            . '\', \'' . urlencode($content_type) . '\','
+            . ($is_custom_type ? 1 : 0) . ', 640, 480)">' . __('View video')
+            . '</a>)';
+        break;
+    // unsupported content. specify download
+    default:
+        $output .= ' (<a href="' . $bs_url . '" target="new">'
+            . __('Download file') . '</a>)';
     }
 
     return $output;
@@ -403,9 +432,10 @@ function PMA_BS_CreateReferenceLink($bs_reference, $db_name)
  * PMA_BS_IsTablePBMSEnabled() passes in the table and database name even though
  * they are not currently needed.
  *
- * @param string $db_name
- * @param string $tbl_name
- * @param string $tbl_type
+ * @param string $db_name  database name
+ * @param string $tbl_name table name
+ * @param string $tbl_type table type
+ *
  * @return bool
  */
 function PMA_BS_IsTablePBMSEnabled($db_name, $tbl_name, $tbl_type)
@@ -431,8 +461,11 @@ function PMA_BS_IsTablePBMSEnabled($db_name, $tbl_name, $tbl_type)
     }
 
     // This information should be cached rather than selecting it each time.
-    //$query = "SELECT count(*)  FROM information_schema.TABLES T, pbms.pbms_enabled E where T.table_schema = ". PMA_backquote($db_name) . " and T.table_name = ". PMA_backquote($tbl_name) . " and T.engine = E.name";
-    $query = "SELECT count(*)  FROM pbms.pbms_enabled E where E.name = '" . PMA_sqlAddSlashes($tbl_type) . "'";
+    // $query = "SELECT count(*)  FROM information_schema.TABLES T,
+    // pbms.pbms_enabled E where T.table_schema = ". PMA_backquote($db_name) . "
+    // and T.table_name = ". PMA_backquote($tbl_name) . " and T.engine = E.name";
+    $query = "SELECT count(*)  FROM pbms.pbms_enabled E where E.name = '"
+        . PMA_sqlAddSlashes($tbl_type) . "'";
     $result = PMA_DBI_query($query);
 
     $data = PMA_DBI_fetch_row($result);
@@ -484,23 +517,28 @@ function PMA_BS_SetContentType($db_name, $bsTable, $blobReference, $contentType)
     // This is a really ugly way to do this but currently there is nothing better.
     // In a future version of PBMS the system tables will be redesigned to make this
     // more efficient.
-    $query = "SELECT Repository_id, Repo_blob_offset FROM pbms_reference  WHERE Blob_url='" . PMA_sqlAddSlashes($blobReference) . "'";
+    $query = "SELECT Repository_id, Repo_blob_offset FROM pbms_reference"
+        . " WHERE Blob_url='" . PMA_sqlAddSlashes($blobReference) . "'";
     //error_log(" PMA_BS_SetContentType: $query\n", 3, "/tmp/mylog");
     $result = PMA_DBI_query($query);
     //error_log(" $query\n", 3, "/tmp/mylog");
 
-// if record exists
+    // if record exists
     if ($data = PMA_DBI_fetch_assoc($result)) {
-        $where = "WHERE Repository_id=" . $data['Repository_id'] . " AND Repo_blob_offset=" . $data['Repo_blob_offset'] ;
+        $where = "WHERE Repository_id=" . $data['Repository_id']
+           . " AND Repo_blob_offset=" . $data['Repo_blob_offset'] ;
         $query = "SELECT name from  pbms_metadata $where";
         $result = PMA_DBI_query($query);
 
         if (PMA_DBI_num_rows($result) == 0) {
-            $query = "INSERT into pbms_metadata Values( ". $data['Repository_id'] . ", " . $data['Repo_blob_offset']  . ", 'Content_type', '" . PMA_sqlAddSlashes($contentType)  . "')";
+            $query = "INSERT into pbms_metadata Values( ". $data['Repository_id']
+                . ", " . $data['Repo_blob_offset']  . ", 'Content_type', '"
+                . PMA_sqlAddSlashes($contentType)  . "')";
         } else {
-            $query = "UPDATE pbms_metadata SET name = 'Content_type', Value = '" . PMA_sqlAddSlashes($contentType)  . "' $where";
+            $query = "UPDATE pbms_metadata SET name = 'Content_type', Value = '"
+                . PMA_sqlAddSlashes($contentType) . "' $where";
         }
-//error_log("$query\n", 3, "/tmp/mylog");
+        //error_log("$query\n", 3, "/tmp/mylog");
         PMA_DBI_query($query);
     } else {
         return false;
@@ -511,8 +549,12 @@ function PMA_BS_SetContentType($db_name, $bsTable, $blobReference, $contentType)
 //------------
 function PMA_BS_IsHiddenTable($table)
 {
-    if ($table === 'pbms_repository' || $table === 'pbms_reference' || $table === 'pbms_metadata'
-    || $table === 'pbms_metadata_header' || $table === 'pbms_dump') {
+    if ($table === 'pbms_repository'
+        || $table === 'pbms_reference'
+        || $table === 'pbms_metadata'
+        || $table === 'pbms_metadata_header'
+        || $table === 'pbms_dump'
+    ) {
         return true;
     }
     return false;


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list