diff --git a/libraries/core.lib.php b/libraries/core.lib.php index 6fa40c8944..9c26b8af73 100644 --- a/libraries/core.lib.php +++ b/libraries/core.lib.php @@ -565,8 +565,12 @@ function PMA_sendHeaderLocation($uri) */ function PMA_no_cache_header() { - header('Expires: ' . date(DATE_RFC1123)); // rfc2616 - Section 14.21 - header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 + // rfc2616 - Section 14.21 + header('Expires: ' . date(DATE_RFC1123)); + // HTTP/1.1 + header('Cache-Control: no-store, no-cache, must-revalidate,' + . ' pre-check=0, post-check=0, max-age=0' + ); if (PMA_USR_BROWSER_AGENT == 'IE') { /* On SSL IE sometimes fails with: * diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php index e57b7c45b0..f69ebad293 100644 --- a/libraries/database_interface.lib.php +++ b/libraries/database_interface.lib.php @@ -220,11 +220,12 @@ function PMA_DBI_convert_message($message) ); if ($server_language) { $found = array(); - if (preg_match( - '&(?:\\\|\\/)([^\\\\\/]*)(?:\\\|\\/)$&i', - $server_language, - $found - )) { + $match = preg_match( + '&(?:\\\|\\/)([^\\\\\/]*)(?:\\\|\\/)$&i', + $server_language, + $found + ); + if ($match) { $server_language = $found[1]; } } diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php index 95372ec70e..a61eb92a8a 100644 --- a/libraries/relation.lib.php +++ b/libraries/relation.lib.php @@ -30,9 +30,19 @@ function PMA_query_as_controluser($sql, $show_error = true, $options = 0) $cache_affected_rows = false; if ($show_error) { - $result = PMA_DBI_query($sql, $GLOBALS['controllink'], $options, $cache_affected_rows); + $result = PMA_DBI_query( + $sql, + $GLOBALS['controllink'], + $options, + $cache_affected_rows + ); } else { - $result = @PMA_DBI_try_query($sql, $GLOBALS['controllink'], $options, $cache_affected_rows); + $result = @PMA_DBI_try_query( + $sql, + $GLOBALS['controllink'], + $options, + $cache_affected_rows + ); } // end if... else... if ($result) { @@ -58,7 +68,9 @@ function PMA_getRelationsParam($verbose = false) $GLOBALS['cfgRelation'] = $_SESSION['relation'][$GLOBALS['server']]; if ($verbose) { - PMA_printRelationsParamDiagnostic($_SESSION['relation'][$GLOBALS['server']]); + PMA_printRelationsParamDiagnostic( + $_SESSION['relation'][$GLOBALS['server']] + ); } return $_SESSION['relation'][$GLOBALS['server']]; @@ -93,68 +105,195 @@ function PMA_printRelationsParamDiagnostic($cfgRelation) echo '' . "\n"; - PMA_printDiagMessageForParameter('pmadb', $GLOBALS['cfg']['Server']['pmadb'], $messages, 'pmadb'); + PMA_printDiagMessageForParameter( + 'pmadb', + $GLOBALS['cfg']['Server']['pmadb'], + $messages, + 'pmadb' + ); - PMA_printDiagMessageForParameter('relation', isset($cfgRelation['relation']), $messages, 'relation'); + PMA_printDiagMessageForParameter( + 'relation', + isset($cfgRelation['relation']), + $messages, + 'relation' + ); - PMA_printDiagMessageForFeature(__('General relation features'), 'relwork', $messages); + PMA_printDiagMessageForFeature( + __('General relation features'), + 'relwork', + $messages + ); - PMA_printDiagMessageForParameter('table_info', isset($cfgRelation['table_info']), $messages, 'table_info'); + PMA_printDiagMessageForParameter( + 'table_info', + isset($cfgRelation['table_info']), + $messages + 'table_info' + ); - PMA_printDiagMessageForFeature(__('Display Features'), 'displaywork', $messages); + PMA_printDiagMessageForFeature( + __('Display Features'), + 'displaywork', + $messages + ); - PMA_printDiagMessageForParameter('table_coords', isset($cfgRelation['table_coords']), $messages, 'table_coords'); + PMA_printDiagMessageForParameter( + 'table_coords', + isset($cfgRelation['table_coords']), + $messages, + 'table_coords' + ); - PMA_printDiagMessageForParameter('pdf_pages', isset($cfgRelation['pdf_pages']), $messages, 'table_coords'); + PMA_printDiagMessageForParameter( + 'pdf_pages', + isset($cfgRelation['pdf_pages']), + $messages, + 'table_coords' + ); - PMA_printDiagMessageForFeature(__('Creation of PDFs'), 'pdfwork', $messages); + PMA_printDiagMessageForFeature( + __('Creation of PDFs'), + 'pdfwork', + $messages + ); - PMA_printDiagMessageForParameter('column_info', isset($cfgRelation['column_info']), $messages, 'col_com'); + PMA_printDiagMessageForParameter( + 'column_info', + isset($cfgRelation['column_info']), + $messages, + 'col_com' + ); - PMA_printDiagMessageForFeature(__('Displaying Column Comments'), 'commwork', $messages, false); + PMA_printDiagMessageForFeature( + __('Displaying Column Comments'), + 'commwork', + $messages, + false + ); - PMA_printDiagMessageForFeature(__('Browser transformation'), 'mimework', $messages); + PMA_printDiagMessageForFeature( + __('Browser transformation'), + 'mimework', + $messages + ); if ($cfgRelation['commwork'] && ! $cfgRelation['mimework']) { - echo '' . "\n"; + echo '' . "\n"; } - PMA_printDiagMessageForParameter('bookmarktable', isset($cfgRelation['bookmark']), $messages, 'bookmark'); + PMA_printDiagMessageForParameter( + 'bookmarktable', + isset($cfgRelation['bookmark']), + $messages, + 'bookmark' + ); - PMA_printDiagMessageForFeature(__('Bookmarked SQL query'), 'bookmarkwork', $messages); + PMA_printDiagMessageForFeature( + __('Bookmarked SQL query'), + 'bookmarkwork', + $messages + ); - PMA_printDiagMessageForParameter('history', isset($cfgRelation['history']), $messages, 'history'); + PMA_printDiagMessageForParameter( + 'history', + isset($cfgRelation['history']), + $messages, + 'history' + ); - PMA_printDiagMessageForFeature(__('SQL history'), 'historywork', $messages); + PMA_printDiagMessageForFeature( + __('SQL history'), + 'historywork', + $messages + ); - PMA_printDiagMessageForParameter('designer_coords', isset($cfgRelation['designer_coords']), $messages, 'designer_coords'); + PMA_printDiagMessageForParameter( + 'designer_coords', + isset($cfgRelation['designer_coords']), + $messages, + 'designer_coords' + ); - PMA_printDiagMessageForFeature(__('Designer'), 'designerwork', $messages); + PMA_printDiagMessageForFeature( + __('Designer'), + 'designerwork', + $messages + ); - PMA_printDiagMessageForParameter('recent', isset($cfgRelation['recent']), $messages, 'recent'); + PMA_printDiagMessageForParameter( + 'recent', + isset($cfgRelation['recent']), + $messages, + 'recent' + ); - PMA_printDiagMessageForFeature(__('Persistent recently used tables'), 'recentwork', $messages); + PMA_printDiagMessageForFeature( + __('Persistent recently used tables'), + 'recentwork', + $messages + ); - PMA_printDiagMessageForParameter('table_uiprefs', isset($cfgRelation['table_uiprefs']), $messages, 'table_uiprefs'); + PMA_printDiagMessageForParameter( + 'table_uiprefs', + isset($cfgRelation['table_uiprefs']), + $messages, + 'table_uiprefs' + ); - PMA_printDiagMessageForFeature(__('Persistent tables\' UI preferences'), 'uiprefswork', $messages); + PMA_printDiagMessageForFeature( + __('Persistent tables\' UI preferences'), + 'uiprefswork', + $messages + ); - PMA_printDiagMessageForParameter('tracking', isset($cfgRelation['tracking']), $messages, 'tracking'); + PMA_printDiagMessageForParameter( + 'tracking', + isset($cfgRelation['tracking']), + $messages, + 'tracking' + ); - PMA_printDiagMessageForFeature(__('Tracking'), 'trackingwork', $messages); + PMA_printDiagMessageForFeature( + __('Tracking'), + 'trackingwork', + $messages + ); - PMA_printDiagMessageForParameter('userconfig', isset($cfgRelation['userconfig']), $messages, 'userconfig'); + PMA_printDiagMessageForParameter( + 'userconfig', + isset($cfgRelation['userconfig']), + $messages, + 'userconfig' + ); - PMA_printDiagMessageForFeature(__('User preferences'), 'userconfigwork', $messages); + PMA_printDiagMessageForFeature( + __('User preferences'), + 'userconfigwork', + $messages + ) echo '
' . __('Please see the documentation on how to update your column_comments table') . '
' + . __('Please see the documentation on how to update your column_comments table') + . '
' . "\n"; echo '

' . __('Quick steps to setup advanced features:') . '

'; echo ''; } diff --git a/server_synchronize.php b/server_synchronize.php index d6948664d6..ff18b893f6 100644 --- a/server_synchronize.php +++ b/server_synchronize.php @@ -115,14 +115,27 @@ if ((isset($_REQUEST['submit_connect']))) { if (${"{$con}_connection"} != null) { ${"{$con}_link"} = PMA_DBI_connect( ${"{$con}_username"}, - ${"{$con}_password"}, $is_controluser = false, ${"{$con}_server"} + ${"{$con}_password"}, + $is_controluser = false, + ${"{$con}_server"} ); } else { ${"{$con}_link"} = null; } - ${"{$con}_db_selected"} = PMA_DBI_select_db(${"{$con}_db"}, ${"{$con}_link"}); - ${"{$con}_version"} = PMA_DBI_fetch_value('SELECT VERSION()', 0, 0, ${"{$con}_link"}); - ${"{$con}_is_drizzle"} = (bool)preg_match('/\d{4}\./', ${"{$con}_version"}); + ${"{$con}_db_selected"} = PMA_DBI_select_db( + ${"{$con}_db"}, + ${"{$con}_link"} + ); + ${"{$con}_version"} = PMA_DBI_fetch_value( + 'SELECT VERSION()', + 0, + 0, + ${"{$con}_link"} + ); + ${"{$con}_is_drizzle"} = (bool)preg_match( + '/\d{4}\./', + ${"{$con}_version"} + ); } // end foreach ($cons as $con) if (($src_db_selected != 1) || ($trg_db_selected != 1)) { @@ -131,10 +144,16 @@ if ((isset($_REQUEST['submit_connect']))) { */ echo '
'; if ($src_db_selected != 1) { - echo sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($src_db)); + echo sprintf( + __('\'%s\' database does not exist.'), + htmlspecialchars($src_db) + ); } if ($trg_db_selected != 1) { - echo sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($trg_db)); + echo sprintf( + __('\'%s\' database does not exist.'), + htmlspecialchars($trg_db) + ); } echo '
'; unset($_REQUEST['submit_connect']); @@ -166,43 +185,91 @@ if ((isset($_REQUEST['submit_connect']))) { * Using PMA_getMatchingTables to find which of the tables' names match * in target and source database. */ - PMA_getMatchingTables($trg_tables, $src_tables, $matching_tables, $source_tables_uncommon); + PMA_getMatchingTables( + $trg_tables, + $src_tables, + $matching_tables, + $source_tables_uncommon + ); /** * Finding the uncommon tables for the target database * using function PMA_getNonMatchingTargetTables() */ - PMA_getNonMatchingTargetTables($trg_tables, $matching_tables, $target_tables_uncommon); + PMA_getNonMatchingTargetTables( + $trg_tables, + $matching_tables, + $target_tables_uncommon + ); /** * Initializing several arrays to save the data and structure * difference between the source and target databases. */ - $row_count = array(); //number of rows in source table that needs to be created in target database - $fields_num = array(); //number of fields in each matching table - $delete_array = array(); //stores the primary key values for target tables that have excessive rows than corresponding source tables. - $insert_array = array(array(array()));// stores the primary key values for the rows in each source table that are not present in target tables. - $update_array = array(array(array())); //stores the primary key values, name of field to be updated, value of the field to be updated for - // each row of matching table. - $matching_tables_fields = array(); //contains the fields' names for each matching table - $matching_tables_keys = array(); //contains the primary keys' names for each matching table - $uncommon_tables_fields = array(); //coantains the fields for all the source tables that are not present in target + // number of rows in source table that needs to be created in target + // database + $row_count = array(); + // number of fields in each matching table + $fields_num = array(); + // stores the primary key values for target tables that have + // excessive rows than corresponding source tables. + $delete_array = array(); + // stores the primary key values for the rows in each source table + // that are not present in target tables. + $insert_array = array(array(array())); + // stores the primary key values, name of field to be updated, + // value of the field to be updated for each row of matching table. + $update_array = array(array(array())); + + // contains the fields' names for each matching table + $matching_tables_fields = array(); + // contains the primary keys' names for each matching table + $matching_tables_keys = array(); + // coantains the fields for all the source tables that are not + // present in target + $uncommon_tables_fields = array(); $matching_tables_num = sizeof($matching_tables); - $source_columns = array(); //contains the full columns' information for all the source tables' columns - $target_columns = array(); //contains the full columns' information for all the target tables' columns - $uncommon_columns = array(); //contains names of columns present in source table but absent from the corresponding target table - $source_indexes = array(); //contains indexes on all the source tables - $target_indexes = array(); //contains indexes on all the target tables - $add_indexes_array = array(); //contains the indexes name present in source but absent from target tables - $target_tables_keys = array(); //contains the keys of all the target tables - $alter_indexes_array = array(); //contains the names of all the indexes for each table that need to be altered in target database - $remove_indexes_array = array(); //contains the names of indexes that are excessive in target tables - $alter_str_array = array(array()); //contains the criteria for each column that needs to be altered in target tables - $add_column_array = array(array()); //contains the name of columns that need to be added in target tables + // contains the full columns' information for all the source + // tables' columns + $source_columns = array(); + // contains the full columns' information for all the target + // tables' columns + $target_columns = array(); + // contains names of columns present in source table but absent from + // the corresponding target table + $uncommon_columns = array(); + // contains indexes on all the source tables + $source_indexes = array(); + // contains indexes on all the target tables + $target_indexes = array(); + // contains the indexes name present in source but absent from + // target tables + $add_indexes_array = array(); + // contains the keys of all the target tables + $target_tables_keys = array(); + // contains the names of all the indexes for each table that need + // to be altered in target database + $alter_indexes_array = array(); + // contains the names of indexes that are excessive in target tables + $remove_indexes_array = array(); + // contains the criteria for each column that needs to be altered + // in target tables + $alter_str_array = array(array()); + // contains the name of columns that need to be added in target tables + $add_column_array = array(array()); /** - * The criteria array contains all the criteria against which columns are compared for differences. - */ - $criteria = array('Field', 'Type', 'Null', 'Collation', 'Key', 'Default', 'Comment'); + * The criteria array contains all the criteria against which columns + * are compared for differences. + */ + $criteria = array( + 'Field', + 'Type', + 'Null', + 'Collation', + 'Key', + 'Default', + 'Comment' + ); for ($i = 0; $i < sizeof($matching_tables); $i++) { /** @@ -226,7 +293,8 @@ if ((isset($_REQUEST['submit_connect']))) { PMA_indexesDiffInTables( $src_db, $trg_db, $src_link, $trg_link, $matching_tables, $source_indexes, $target_indexes, - $add_indexes_array, $alter_indexes_array, $remove_indexes_array, $i + $add_indexes_array, $alter_indexes_array, + $remove_indexes_array, $i ); } @@ -378,8 +446,14 @@ if ((isset($_REQUEST['submit_connect']))) { || ($num_add_index > 0) || ($num_remove_index > 0) ) { - $btn_structure_params = array($i, $num_alter_cols, $num_insert_cols, - $num_remove_cols, $num_add_index, $num_remove_index); + $btn_structure_params = array( + $i, + $num_alter_cols, + $num_insert_cols, + $num_remove_cols, + $num_add_index, + $num_remove_index + ); } /** @@ -467,8 +541,9 @@ if ((isset($_REQUEST['submit_connect']))) { '; /** - * This fieldset displays the checkbox to confirm deletion of previous rows from target tables - */ + * This fieldset displays the checkbox to confirm deletion of previous + * rows from target tables + */ echo '

' . PMA_generate_common_hidden_inputs('', ''); @@ -980,8 +1062,9 @@ if (isset($_REQUEST['Table_ids'])) {
'; /** - * This fieldset displays the checkbox to confirm deletion of previous rows from target tables - */ + * This fieldset displays the checkbox to confirm deletion of previous + * rows from target tables + */ echo '

@@ -1071,7 +1154,12 @@ if (isset($_REQUEST['synchronize_db'])) { * connecting the source and target servers */ if ('cur' != $_SESSION['src_type']) { - $src_link = PMA_DBI_connect($src_username, $src_password, $is_controluser = false, $_SESSION['src_server']); + $src_link = PMA_DBI_connect( + $src_username, + $src_password, + $is_controluser = false, + $_SESSION['src_server'] + ); $src_version = PMA_DBI_fetch_value('SELECT VERSION()', 0, 0, $src_link); $src_is_drizzle = (bool)preg_match('/\d{4}\./', $src_version); } else { @@ -1083,7 +1171,12 @@ if (isset($_REQUEST['synchronize_db'])) { $GLOBALS['db'] = $_SESSION['src_db']; } if ('cur' != $_SESSION['trg_type']) { - $trg_link = PMA_DBI_connect($trg_username, $trg_password, $is_controluser = false, $_SESSION['trg_server']); + $trg_link = PMA_DBI_connect( + $trg_username, + $trg_password, + $is_controluser = false, + $_SESSION['trg_server'] + ); $trg_version = PMA_DBI_fetch_value('SELECT VERSION()', 0, 0, $trg_link); $trg_is_drizzle = (bool)preg_match('/\d{4}\./', $trg_version); } else { @@ -1103,9 +1196,10 @@ if (isset($_REQUEST['synchronize_db'])) { */ for ($p = 0; $p < sizeof($matching_tables); $p++) { /** - * If the check box is checked for deleting previous rows from the target database tables then - * first find out rows to be deleted and then delete the rows. - */ + * If the check box is checked for deleting previous rows from the + * target database tables then first find out rows to be deleted + * and then delete the rows. + */ if (isset($_REQUEST['delete_rows'])) { PMA_findDeleteRowsFromTargetTables( $delete_array, $matching_tables, $p, @@ -1186,7 +1280,8 @@ if (isset($_REQUEST['synchronize_db'])) { $trg_link, $matching_tables_fields, $insert_array, $p, $matching_tables_keys, $matching_tables_keys, $source_columns, $add_column_array, $criteria, $target_tables_keys, $uncommon_tables, - $uncommon_tables_fields, $uncommon_cols, $alter_str_array, $source_indexes, + $uncommon_tables_fields, $uncommon_cols, $alter_str_array, + $source_indexes, $target_indexes, $add_indexes_array, $alter_indexes_array, $delete_array, $update_array, true );