From 66863fe981e9d5ccac9b498ff834718027d6b6c2 Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Fri, 25 May 2012 00:48:13 +0530 Subject: [PATCH 1/2] Fixed some code violations in display_tbl.lib.php --- libraries/display_tbl.lib.php | 122 +++++++++++++++++++++++----------- 1 file changed, 83 insertions(+), 39 deletions(-) diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 63113e5f8c..6e8c02e6a2 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -393,7 +393,9 @@ function PMA_getTableNavigation($pos_next, $pos_prev, $sql_query, } // end show all // Move to the next page or to the last one - $endpos = $_SESSION['tmp_user_values']['pos'] + $_SESSION['tmp_user_values']['max_rows']; + $endpos = $_SESSION['tmp_user_values']['pos'] + + $_SESSION['tmp_user_values']['max_rows']; + if (($endpos < $unlim_num_rows) && ($num_rows >= $_SESSION['tmp_user_values']['max_rows']) && ($_SESSION['tmp_user_values']['max_rows'] != 'all') @@ -408,7 +410,8 @@ function PMA_getTableNavigation($pos_next, $pos_prev, $sql_query, // show separator if pagination happen if ($nbTotalPage > 1) { - $table_navigation_html .= ''; + $table_navigation_html + .= ''; } $table_navigation_html .= '' @@ -435,13 +438,15 @@ function PMA_getTableNavigation($pos_next, $pos_prev, $sql_query, . '(checkFormElementInRange(' . 'this, ' . '\'session_max_rows\', ' - . '\'' . str_replace('\'', '\\\'', __('%d is not valid row number.')) . '\', ' + . '\'' . str_replace('\'', '\\\'', __('%d is not valid row number.')) + . '\', ' . '1)' . ' && ' . 'checkFormElementInRange(' . 'this, ' . '\'pos\', ' - . '\'' . str_replace('\'', '\\\'', __('%d is not valid row number.')) . '\', ' + . '\'' . str_replace('\'', '\\\'', __('%d is not valid row number.')) + . '\', ' . '0' . ($unlim_num_rows > 0 ? ', ' . ($unlim_num_rows - 1) : '') . ')' . ')' @@ -575,7 +580,8 @@ function PMA_getMoveForwardButtonsForTableNavigation( * Prepare feilds followed by Show button for table navigation * Start row, Number of rows, Headers every * - * @param string $html_sql_query the sql encoded by html special characters + * @param string $html_sql_query the sql encoded by html special + * characters * @param string $goto the URL to go back in case of errors * @param integer $pos_next the offset for the "next" page * @param integer $unlim_num_rows the total number of rows returned by the @@ -845,8 +851,8 @@ function PMA_getTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, } elseif (($GLOBALS['cfg']['RowActionLinks'] == 'none') && ($directionCondition) ) { - // ... elseif display an empty column if the actions links are disabled to - // match the rest of the table + // ... elseif display an empty column if the actions links are disabled to + // match the rest of the table $table_headers_html .= ''; } @@ -1161,8 +1167,8 @@ function PMA_getSortByKeyDropDown( . __('Descending') . ')'; } - $drop_down_html .= '' . '' . "\n" . '' . "\n"; @@ -1921,7 +1927,8 @@ function PMA_getTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) // delete/edit options correctly for tables without keys. $odd_row = true; - $directionCondition = ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal') + $directionCondition + = ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal') || ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped'); while ($row = PMA_DBI_fetch_row($dt_result)) { @@ -1975,7 +1982,9 @@ function PMA_getTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) } // end if (1.2.1) // 1.2.2 Delete/Kill link(s) - if (($is_display['del_lnk'] == 'dr') || ($is_display['del_lnk'] == 'kp')) { + if (($is_display['del_lnk'] == 'dr') + || ($is_display['del_lnk'] == 'kp') + ) { list($del_query, $del_url, $del_str, $js_conf) = PMA_getDeleteAndKillLinks( @@ -2068,7 +2077,8 @@ function PMA_getTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) if (file_exists($include_file)) { - $transformfunction_name = 'PMA_transformation_' . str_replace( + $transformfunction_name = 'PMA_transformation_' + . str_replace( '.inc.php', '', $GLOBALS['mime_map'][$meta->name]['transformation'] ); @@ -2080,8 +2090,11 @@ function PMA_getTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) $transform_function = $transformfunction_name; $transform_options = PMA_transformation_getOptions( - isset($GLOBALS['mime_map'][$meta->name]['transformation_options']) - ? $GLOBALS['mime_map'][$meta->name]['transformation_options'] + isset($GLOBALS['mime_map'][$meta->name] + ['transformation_options'] + ) + ? $GLOBALS['mime_map'][$meta->name] + ['transformation_options'] : '' ); @@ -2105,7 +2118,8 @@ function PMA_getTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) $_url_params['sql_query'] = $url_sql_query; } - $transform_options['wrapper_link'] = PMA_generate_common_url($_url_params); + $transform_options['wrapper_link'] + = PMA_generate_common_url($_url_params); if ($meta->numeric == 1) { // n u m e r i c @@ -2216,11 +2230,12 @@ function PMA_getTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) if (!empty($del_url) && ($is_display['del_lnk'] != 'kp')) { - $vertical_display['row_delete'][$row_no] .= PMA_getCheckboxForMultiRowSubmissions( - $del_url, $is_display, $row_no, $where_clause_html, - $condition_array, $del_query, '[%_PMA_CHECKBOX_DIR_%]', - $alternating_color_class . $vertical_class - ); + $vertical_display['row_delete'][$row_no] + .= PMA_getCheckboxForMultiRowSubmissions( + $del_url, $is_display, $row_no, $where_clause_html, + $condition_array, $del_query, '[%_PMA_CHECKBOX_DIR_%]', + $alternating_color_class . $vertical_class + ); } else { unset($vertical_display['row_delete'][$row_no]); @@ -2376,7 +2391,8 @@ function PMA_getVerticalDisplaySupportSegments( } if ($vertical_display['emptyafter'] > 0) { - $support_html .= ' ' + $support_html .= ' ' . "\n" . '  ' . "\n"; } $support_html .= '' . "\n"; @@ -3100,7 +3116,8 @@ function PMA_getVerticalTable() // assign appropriate key with current column order $key = $col_order ? $col_order[$j] : $j; - $vertical_table_html .= '' . "\n" . $val; @@ -3285,7 +3302,9 @@ function PMA_setConfigParamsForDisplayTable() $_SESSION['tmp_user_values']['query'][$sql_md5]['disp_direction'] = $_REQUEST['disp_direction']; unset($_REQUEST['disp_direction']); - } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['disp_direction'])) { + } elseif ( + empty($_SESSION['tmp_user_values']['query'][$sql_md5]['disp_direction']) + ) { $_SESSION['tmp_user_values']['query'][$sql_md5]['disp_direction'] = $GLOBALS['cfg']['DefaultDisplay']; } @@ -3294,7 +3313,9 @@ function PMA_setConfigParamsForDisplayTable() $_SESSION['tmp_user_values']['query'][$sql_md5]['repeat_cells'] = $_REQUEST['repeat_cells']; unset($_REQUEST['repeat_cells']); - } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['repeat_cells'])) { + } elseif ( + empty($_SESSION['tmp_user_values']['query'][$sql_md5]['repeat_cells']) + ) { $_SESSION['tmp_user_values']['query'][$sql_md5]['repeat_cells'] = $GLOBALS['cfg']['RepeatCells']; } @@ -3324,7 +3345,9 @@ function PMA_setConfigParamsForDisplayTable() $_SESSION['tmp_user_values']['query'][$sql_md5]['display_text'] = $_REQUEST['display_text']; unset($_REQUEST['display_text']); - } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['display_text'])) { + } elseif ( + empty($_SESSION['tmp_user_values']['query'][$sql_md5]['display_text']) + ) { $_SESSION['tmp_user_values']['query'][$sql_md5]['display_text'] = 'P'; } @@ -3332,7 +3355,9 @@ function PMA_setConfigParamsForDisplayTable() $_SESSION['tmp_user_values']['query'][$sql_md5]['relational_display'] = $_REQUEST['relational_display']; unset($_REQUEST['relational_display']); - } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['relational_display'])) { + } elseif ( + empty($_SESSION['tmp_user_values']['query'][$sql_md5]['relational_display']) + ) { $_SESSION['tmp_user_values']['query'][$sql_md5]['relational_display'] = 'K'; } @@ -3340,7 +3365,9 @@ function PMA_setConfigParamsForDisplayTable() $_SESSION['tmp_user_values']['query'][$sql_md5]['geometry_display'] = $_REQUEST['geometry_display']; unset($_REQUEST['geometry_display']); - } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['geometry_display'])) { + } elseif ( + empty($_SESSION['tmp_user_values']['query'][$sql_md5]['geometry_display']) + ) { $_SESSION['tmp_user_values']['query'][$sql_md5]['geometry_display'] = 'GEOM'; } @@ -3365,7 +3392,9 @@ function PMA_setConfigParamsForDisplayTable() unset($_REQUEST['display_binary_as_hex']); } elseif (isset($_REQUEST['display_options_form'])) { // we know that the checkbox was unchecked - unset($_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary_as_hex']); + unset( + $_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary_as_hex'] + ); } elseif (isset($_REQUEST['full_text_button'])) { // do nothing to keep the value that is there in the session } else { @@ -3392,7 +3421,9 @@ function PMA_setConfigParamsForDisplayTable() unset($_REQUEST['hide_transformation']); } elseif (isset($_REQUEST['display_options_form'])) { // we know that the checkbox was unchecked - unset($_SESSION['tmp_user_values']['query'][$sql_md5]['hide_transformation']); + unset( + $_SESSION['tmp_user_values']['query'][$sql_md5]['hide_transformation'] + ); } // move current query to the last position, to be removed last @@ -3420,7 +3451,9 @@ function PMA_setConfigParamsForDisplayTable() ? true : false; $_SESSION['tmp_user_values']['display_binary_as_hex'] - = isset($_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary_as_hex']) + = isset( + $_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary_as_hex'] + ) ? true : false; $_SESSION['tmp_user_values']['display_blob'] @@ -3428,7 +3461,9 @@ function PMA_setConfigParamsForDisplayTable() ? true : false; $_SESSION['tmp_user_values']['hide_transformation'] - = isset($_SESSION['tmp_user_values']['query'][$sql_md5]['hide_transformation']) + = isset( + $_SESSION['tmp_user_values']['query'][$sql_md5]['hide_transformation'] + ) ? true : false; $_SESSION['tmp_user_values']['pos'] @@ -3510,7 +3545,10 @@ function PMA_getTable(&$dt_result, &$the_disp_mode, $analyzed_sql) $pre_count = '~'; $after_count = PMA_showHint( PMA_sanitize( - __('May be approximate. See [a@./Documentation.html#faq3_11@Documentation]FAQ 3.11[/a]') + __( + 'May be approximate. + See [a@./Documentation.html#faq3_11@Documentation]FAQ 3.11[/a]' + ) ) ); } else { @@ -3607,7 +3645,8 @@ function PMA_getTable(&$dt_result, &$the_disp_mode, $analyzed_sql) foreach ($analyzed_sql[0]['table_ref'] as $table_ref_position => $table_ref) { - $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name']; + $target[] = $analyzed_sql[0]['table_ref'] + [$table_ref_position]['table_true_name']; } } @@ -3734,10 +3773,10 @@ function PMA_getOffsets() /** * Get sort parameters * - * @param string $order_by_clause + * @param string $order_by_clause the order by clause of the sql query * - * @return array 3 element array: $sort_expression, - * $sort_expression_nodirection, $sort_direction + * @return array 3 element array: $sort_expression, + * $sort_expression_nodirection, $sort_direction * * @see PMA_getTable() */ @@ -3940,7 +3979,10 @@ function PMA_setMessageInformation( ) { $message = PMA_Message::notice( - __('This view has at least this number of rows. Please refer to %sdocumentation%s.') + __( + 'This view has at least this number of rows. + Please refer to %sdocumentation%s.' + ) ); $message->addParam('[a@./Documentation.html#cfg_MaxExactCount@_blank]'); @@ -4431,7 +4473,8 @@ function PMA_getRowData($class, $condition_field, $analyzed_sql, $meta, $map, $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias']; if (isset($alias) && strlen($alias)) { - $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column']; + $true_column = $analyzed_sql[0]['select_expr'] + [$select_expr_position]['column']; if ($alias == $meta->name) { // this change in the parameter does not matter @@ -4718,7 +4761,8 @@ function PMA_getDeleteLink($del_url, $del_str, $js_conf, $class) * * @param string $position the position of the checkbox and links * @param string $del_url delete url - * @param array $is_display array with explicit indexes for all the display elements + * @param array $is_display array with explicit indexes for all the + * display elements * @param string $row_no row number * @param string $where_clause where clause * @param string $where_clause_html url encoded where cluase From 946009aace50c27ff79a051f0a9f3bbffc456337 Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Fri, 25 May 2012 00:49:01 +0530 Subject: [PATCH 2/2] Fixed some code violations in common.lib.php --- libraries/common.lib.php | 113 ++++++++++++++++++++++++++------------- 1 file changed, 77 insertions(+), 36 deletions(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index db1d425950..be9d13a8a3 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -958,7 +958,8 @@ function PMA_reloadNavigation($jsonly = false) } echo '//getDisplay(); + $retval .= PMA_Message::error( + __('Failed to connect to SQL validator!') + )->getDisplay(); } } elseif (isset($parsed_sql)) { $query_base = PMA_formatSql($parsed_sql, $query_base); @@ -1182,13 +1188,17 @@ function PMA_getMessage( $explain_params['sql_query'] = 'EXPLAIN ' . $sql_query; $_message = __('Explain SQL'); $is_select = true; - } elseif (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $sql_query)) { + } elseif ( + preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $sql_query) + ) { $explain_params['sql_query'] = substr($sql_query, 8); $_message = __('Skip Explain SQL'); } if (isset($explain_params['sql_query'])) { - $explain_link = 'import.php' . PMA_generate_common_url($explain_params); - $explain_link = ' [' . PMA_linkOrButton($explain_link, $_message) . ']'; + $explain_link = 'import.php' + . PMA_generate_common_url($explain_params); + $explain_link = ' [' + . PMA_linkOrButton($explain_link, $_message) . ']'; } } //show explain @@ -1232,7 +1242,8 @@ function PMA_getMessage( if (isset($GLOBALS['show_as_php'])) { $runquery_link = 'import.php' . PMA_generate_common_url($url_params); - $php_link .= ' [' . PMA_linkOrButton($runquery_link, __('Submit Query')) . ']'; + $php_link .= ' [' + . PMA_linkOrButton($runquery_link, __('Submit Query')) . ']'; } } else { $php_link = ''; @@ -1244,7 +1255,8 @@ function PMA_getMessage( && preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $sql_query) ) { $refresh_link = 'import.php' . PMA_generate_common_url($url_params); - $refresh_link = ' [' . PMA_linkOrButton($refresh_link, __('Refresh')) . ']'; + $refresh_link = ' [' + . PMA_linkOrButton($refresh_link, __('Refresh')) . ']'; } else { $refresh_link = ''; } //refresh @@ -1260,8 +1272,10 @@ function PMA_getMessage( $validate_message = __('Validate SQL'); } - $validate_link = 'import.php' . PMA_generate_common_url($validate_params); - $validate_link = ' [' . PMA_linkOrButton($validate_link, $validate_message) . ']'; + $validate_link = 'import.php' + . PMA_generate_common_url($validate_params); + $validate_link = ' [' + . PMA_linkOrButton($validate_link, $validate_message) . ']'; } else { $validate_link = ''; } //validator @@ -1298,7 +1312,9 @@ function PMA_getMessage( // depend on the profiling support or on the refresh link if (empty($refresh_link) || ! PMA_profilingSupported()) { $retval .= '
'; - $retval .= PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); + $retval .= PMA_generate_common_hidden_inputs( + $GLOBALS['db'], $GLOBALS['table'] + ); $retval .= ''; $retval .= '
'; @@ -1323,7 +1339,8 @@ function PMA_getMessage( "//]]>\n" . ""; } - $retval .= $edit_link . $explain_link . $php_link . $refresh_link . $validate_link; + $retval .= $edit_link . $explain_link . $php_link + . $refresh_link . $validate_link; $retval .= ''; } $retval .= ''; @@ -1376,10 +1393,15 @@ function PMA_getProfilingForm($sql_query) if (PMA_profilingSupported()) { $retval .= '
' . "\n"; - $retval .= PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); - $retval .= '' . "\n"; + $retval .= PMA_generate_common_hidden_inputs( + $GLOBALS['db'], $GLOBALS['table'] + ); + $retval .= '' . "\n"; $retval .= '' . "\n"; - $retval .= PMA_getCheckbox('profiling', __('Profiling'), isset($_SESSION['profiling']), true); + $retval .= PMA_getCheckbox( + 'profiling', __('Profiling'), isset($_SESSION['profiling']), true + ); $retval .= '
' . "\n"; } @@ -2131,7 +2153,9 @@ function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row, if (isset($GLOBALS['analyzed_sql'][0]['select_expr']) && is_array($GLOBALS['analyzed_sql'][0]['select_expr']) ) { - foreach ($GLOBALS['analyzed_sql'][0]['select_expr'] as $select_expr) { + foreach ( + $GLOBALS['analyzed_sql'][0]['select_expr'] as $select_expr + ) { // need (string) === (string) // '' !== 0 but '' == 0 if ((string) $select_expr['alias'] === (string) $meta->name) { @@ -2207,7 +2231,8 @@ function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row, $condition = ''; } } elseif ($meta->type == 'bit') { - $con_val = "= b'" . PMA_printableBitValue($row[$i], $meta->length) . "'"; + $con_val = "= b'" + . PMA_printableBitValue($row[$i], $meta->length) . "'"; } else { $con_val = '= \'' . PMA_sqlAddSlashes($row[$i], false, true) . '\''; } @@ -2460,7 +2485,8 @@ function PMA_listNavigator($count, $pos, $_url_params, $script, $frame, $max_cou $caption1 = '<<'; $caption2 = ' < '; $title1 = ' title="' . _pgettext('First page', 'Begin') . '"'; - $title2 = ' title="' . _pgettext('Previous page', 'Previous') . '"'; + $title2 = ' title="' + . _pgettext('Previous page', 'Previous') . '"'; } else { $caption1 = _pgettext('First page', 'Begin') . ' <<'; $caption2 = _pgettext('Previous page', 'Previous') . ' <'; @@ -2477,7 +2503,8 @@ function PMA_listNavigator($count, $pos, $_url_params, $script, $frame, $max_cou . $frame . '">' . $caption2 . ''; } - echo "\n", '
', "\n"; + echo "\n", '', "\n"; echo PMA_generate_common_hidden_inputs($_url_params); echo PMA_pageselector( $max_count, @@ -2635,13 +2662,16 @@ function PMA_getRadioFields($html_field_name, $choices, $checked_choice = '', } $html_field_id = $html_field_name . '_' . $choice_value; $radio_html .= '' - . ($escape_label ? htmlspecialchars($choice_label) : $choice_label) + . ($escape_label + ? htmlspecialchars($choice_label) + : $choice_label) . ''; if ($line_break) { $radio_html .= '
'; @@ -2748,7 +2778,8 @@ function PMA_toggleButton($action, $select_name, $options, $callback) $retval = "\n"; $retval .= "
\n"; $retval .= "
\n"; - $retval .= "
\n"; + $retval .= "
\n"; $retval .= " \n"; $retval .= "
 
\n"; $retval .= " \n"; $retval .= " $link_off\n"; $retval .= "
"; - $retval .= str_replace(' ', ' ', htmlspecialchars($options[0]['label'])) . "\n"; - $retval .= "
\n"; + $retval .= str_replace(' ', ' ', htmlspecialchars($options[0]['label'])); + $retval .= "\n" . "
\n"; $retval .= " \n"; $retval .= " \n"; $retval .= " \n"; @@ -2985,7 +3016,8 @@ function PMA_extractColumnSpec($columnspec) // Increment character index $index++; } // end while - $printtype = $type . '(' . str_replace("','", "', '", $spec_in_brackets) . ')'; + $printtype = $type + . '(' . str_replace("','", "', '", $spec_in_brackets) . ')'; $binary = false; $unsigned = false; $zerofill = false; @@ -2999,7 +3031,9 @@ function PMA_extractColumnSpec($columnspec) // this would be a BINARY or VARBINARY column type; // by the way, a BLOB should not show the BINARY attribute // because this is not accepted in MySQL syntax. - if (preg_match('@binary@', $printtype) && ! preg_match('@binary[\(]@', $printtype)) { + if (preg_match('@binary@', $printtype) + && ! preg_match('@binary[\(]@', $printtype) + ) { $printtype = preg_replace('@binary@', '', $printtype); $binary = true; } else { @@ -3026,7 +3060,9 @@ function PMA_extractColumnSpec($columnspec) $can_contain_collation = false; if (! $binary - && preg_match("@^(char|varchar|text|tinytext|mediumtext|longtext|set|enum)@", $type) + && preg_match( + "@^(char|varchar|text|tinytext|mediumtext|longtext|set|enum)@", $type + ) ) { $can_contain_collation = true; } @@ -3346,7 +3382,8 @@ function PMA_selectUploadFile($import_list, $uploaddir) $matcher = '@\.(' . $extensions . ')(\.(' . PMA_supportedDecompressions() . '))?$@'; - $active = (isset($GLOBALS['timeout_passed']) && $GLOBALS['timeout_passed'] && isset($local_import_file)) + $active = (isset($GLOBALS['timeout_passed']) && $GLOBALS['timeout_passed'] + && isset($local_import_file)) ? $local_import_file : ''; $files = PMA_getFileSelectOptions( @@ -3360,7 +3397,8 @@ function PMA_selectUploadFile($import_list, $uploaddir) )->display(); } elseif (! empty($files)) { echo "\n"; - echo ' ' . "\n"; echo ' ' . "\n"; echo $files; echo ' ' . "\n"; @@ -3672,17 +3710,20 @@ function PMA_getDefaultFunctionForField($field, $insert_mode) $default_function = $cfg['DefaultFunctions']['FUNC_' . $current_class]; } } + + $analyzed_sql_field_array = $analyzed_sql[0]['create_table_fields'] + [$field['Field']]; // what function defined as default? // for the first timestamp we don't set the default function // if there is a default value for the timestamp // (not including CURRENT_TIMESTAMP) // and the column does not have the // ON UPDATE DEFAULT TIMESTAMP attribute. - if ($field['True_Type'] == 'timestamp' + if (($field['True_Type'] == 'timestamp') && empty($field['Default']) && empty($data) - && ! isset($analyzed_sql[0]['create_table_fields'][$field['Field']]['on_update_current_timestamp']) - && $analyzed_sql[0]['create_table_fields'][$field['Field']]['default_value'] != 'NULL' + && ! isset($analyzed_sql_field_array['on_update_current_timestamp']) + && ($analyzed_sql_field_array['default_value'] != 'NULL') ) { $default_function = $cfg['DefaultFunctions']['first_timestamp']; }