From a790c2cf33097a8a3666f394c6217487b083dbb6 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Fri, 9 Jan 2015 21:31:28 +0530 Subject: [PATCH 1/4] rfe #347 allow table with transformed column anywhere in FROM clause Signed-off-by: Madhura Jayaratne --- ChangeLog | 1 + libraries/DisplayResults.class.php | 91 +++++++++++++++--------- libraries/transformations.lib.php | 21 ++++-- test/classes/PMA_DisplayResults_test.php | 8 +++ 4 files changed, 82 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index 565aaa64ad..adb1212ac1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,7 @@ phpMyAdmin - ChangeLog + rfe #1590 Recaptcha API v2 + rfe #1580 Individual Zeroconf PMA tables support + rfe #1525 Generate keys one per line ++ rfe #347 allow table with transformed column anywhere in FROM clause 4.3.7.0 (not yet released) - bug #4694 js error on marking table as favorite in Safari (in private mode) diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index db24328f33..92c6ca1ecc 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -1098,17 +1098,6 @@ class PMA_DisplayResults // because of space usage $comments_map = $this->_getTableCommentsArray($direction, $analyzed_sql); - if ($GLOBALS['cfgRelation']['commwork'] - && $GLOBALS['cfgRelation']['mimework'] - && $GLOBALS['cfg']['BrowseMIME'] - && ! $_SESSION['tmpval']['hide_transformation'] - ) { - $this->__set( - 'mime_map', - PMA_getMIME($this->__get('db'), $this->__get('table')) - ); - } - // See if we have to highlight any header fields of a WHERE query. // Uses SQL-Parser results. $this->_setHighlightedColumnGlobalField($analyzed_sql); @@ -2553,8 +2542,9 @@ class PMA_DisplayResults } $mime_map = $this->__get('mime_map'); + $orgFullColName = $meta->db . '.' . $meta->orgtable . '.' . $meta->orgname; if ($transformation_plugin != $default_function - || !empty($mime_map[$meta->name]['input_transformation']) + || !empty($mime_map[$orgFullColName]['input_transformation']) ) { $classes[] = 'transformed'; } @@ -2757,6 +2747,7 @@ class PMA_DisplayResults } // end if (1) // 2. Displays the rows' values + $this->_setMimeMap(); $table_body_html .= $this->_getRowValues( $dt_result, $row, $row_no, $col_order, $map, $grid_edit_class, $col_visib, $where_clause, @@ -2800,6 +2791,40 @@ class PMA_DisplayResults } // end of the '_getTableBody()' function + /** + * Sets the MIME details of the columns in the results set + * + * @return void + */ + private function _setMimeMap() + { + $fields_meta = $this->__get('fields_meta'); + $mimeMap = array(); + $added = array(); + + for ($currentColumn = 0; + $currentColumn < $this->__get('fields_cnt'); + ++$currentColumn) { + + $meta = $fields_meta[$currentColumn]; + $orgFullTableName = $meta->db . '.' . $meta->orgtable; + + if ($GLOBALS['cfgRelation']['commwork'] + && $GLOBALS['cfgRelation']['mimework'] + && $GLOBALS['cfg']['BrowseMIME'] + && ! $_SESSION['tmpval']['hide_transformation'] + && empty($added[$orgFullTableName]) + ) { + $mimeMap = array_merge( + $mimeMap, PMA_getMIME($meta->db, $meta->orgtable, false, true) + ); + $added[$orgFullTableName] = true; + } + } + + $this->__set('mime_map', $mimeMap); + } + /** * Get the values for one data row @@ -2850,6 +2875,9 @@ class PMA_DisplayResults $i = $col_order ? $col_order[$currentColumn] : $currentColumn; $meta = $fields_meta[$i]; + $orgFullColName + = $meta->db . '.' . $meta->orgtable . '.' . $meta->orgname; + $not_null_class = $meta->not_null ? 'not_null' : ''; $relation_class = isset($map[$meta->name]) ? 'relation' : ''; $hide_class = ($col_visib && ! $col_visib[$currentColumn] @@ -2887,12 +2915,12 @@ class PMA_DisplayResults && $GLOBALS['cfg']['BrowseMIME'] ) { - if (isset($mime_map[$meta->name]['mimetype']) - && isset($mime_map[$meta->name]['transformation']) - && !empty($mime_map[$meta->name]['transformation']) + if (isset($mime_map[$orgFullColName]['mimetype']) + && isset($mime_map[$orgFullColName]['transformation']) + && !empty($mime_map[$orgFullColName]['transformation']) ) { - $file = $mime_map[$meta->name]['transformation']; + $file = $mime_map[$orgFullColName]['transformation']; $include_file = 'libraries/plugins/transformations/' . $file; if (file_exists($include_file)) { @@ -2906,17 +2934,17 @@ class PMA_DisplayResults ); $transform_options = PMA_Transformation_getOptions( - isset($mime_map[$meta->name] + isset($mime_map[$orgFullColName] ['transformation_options'] ) - ? $mime_map[$meta->name] + ? $mime_map[$orgFullColName] ['transformation_options'] : '' ); $meta->mimetype = str_replace( '_', '/', - $mime_map[$meta->name]['mimetype'] + $mime_map[$orgFullColName]['mimetype'] ); } // end if file_exists @@ -2936,14 +2964,14 @@ class PMA_DisplayResults $this->__get('fields_meta'), $row, false, - $this->__get('table') + $meta->orgtable ); $transform_url_params = array( - 'db' => $this->__get('db'), - 'table' => $this->__get('table'), + 'db' => $meta->db, + 'table' => $meta->orgtable, 'where_clause' => $unique_conditions[0], - 'transform_key' => $meta->name + 'transform_key' => $meta->orgname ); if (! empty($sql_query)) { @@ -2958,9 +2986,9 @@ class PMA_DisplayResults // Check whether the field needs to display with syntax highlighting - $dbLower = /*overload*/mb_strtolower($this->__get('db')); - $tblLower = /*overload*/mb_strtolower($this->__get('table')); - $nameLower = /*overload*/mb_strtolower($meta->name); + $dbLower = /*overload*/mb_strtolower($meta->db); + $tblLower = /*overload*/mb_strtolower($meta->orgtable); + $nameLower = /*overload*/mb_strtolower($meta->orgname); if (! empty($this->transformation_info[$dbLower][$tblLower][$nameLower]) && (trim($row[$i]) != '') ) { @@ -2971,17 +2999,16 @@ class PMA_DisplayResults [$dbLower][$tblLower][$nameLower][1](null); $transform_options = PMA_Transformation_getOptions( - isset($mime_map[$meta->name]['transformation_options']) - ? $mime_map[$meta->name]['transformation_options'] + isset($mime_map[$orgFullColName]['transformation_options']) + ? $mime_map[$orgFullColName]['transformation_options'] : '' ); - $dbLower = /*overload*/mb_strtolower($this->__get('db')); $meta->mimetype = str_replace( '_', '/', $this->transformation_info[$dbLower] - [/*overload*/mb_strtolower($this->__get('table'))] - [/*overload*/mb_strtolower($meta->name)][2] + [/*overload*/mb_strtolower($meta->orgtable)] + [/*overload*/mb_strtolower($meta->orgname)][2] ); } @@ -2994,7 +3021,7 @@ class PMA_DisplayResults ) { $linking_url = $this->_getSpecialLinkUrl( - $row[$i], $row_info, /*overload*/mb_strtolower($meta->name) + $row[$i], $row_info, /*overload*/mb_strtolower($meta->orgname) ); include_once "libraries/plugins/transformations/Text_Plain_Link.class.php"; diff --git a/libraries/transformations.lib.php b/libraries/transformations.lib.php index 3e1cb237d7..128f1fb293 100644 --- a/libraries/transformations.lib.php +++ b/libraries/transformations.lib.php @@ -179,15 +179,16 @@ function PMA_getTransformationDescription($file, $html_formatted = true) /** * Gets the mimetypes for all columns of a table * - * @param string $db the name of the db to check for - * @param string $table the name of the table to check for - * @param boolean $strict whether to include only results having a mimetype set + * @param string $db the name of the db to check for + * @param string $table the name of the table to check for + * @param boolean $strict whether to include only results having a mimetype set + * @param boolean $fullName whether to use full column names as the key * * @access public * * @return array [field_name][field_key] = field_value */ -function PMA_getMIME($db, $table, $strict = false) +function PMA_getMIME($db, $table, $strict = false, $fullName = false) { $cfgRelation = PMA_getRelationsParam(); @@ -195,9 +196,15 @@ function PMA_getMIME($db, $table, $strict = false) return false; } - $com_qry = ' - SELECT `column_name`, - `mimetype`, + $com_qry = ''; + if ($fullName) { + $com_qry .= "SELECT CONCAT(" + . "`db_name`, '.', `table_name`, '.', `column_name`" + . ") AS column_name,"; + } else { + $com_qry = "SELECT `column_name`,"; + } + $com_qry .= '`mimetype`, `transformation`, `transformation_options`, `input_transformation`, diff --git a/test/classes/PMA_DisplayResults_test.php b/test/classes/PMA_DisplayResults_test.php index 93c450370f..657d9efefe 100644 --- a/test/classes/PMA_DisplayResults_test.php +++ b/test/classes/PMA_DisplayResults_test.php @@ -1647,15 +1647,23 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase { $transformation_plugin = new Text_Plain_Link(); $meta = new StdClass(); + $meta->db = 'foo'; + $meta->table = 'tbl'; + $meta->orgtable = 'tbl'; $meta->type = 'BLOB'; $meta->flags = 'blob binary'; $meta->name = 'tblob'; + $meta->orgname = 'tblob'; $meta2 = new StdClass(); + $meta2->db = 'foo'; + $meta2->table = 'tbl'; + $meta2->orgtable = 'tbl'; $meta2->type = 'string'; $meta2->flags = ''; $meta2->decimals = 0; $meta2->name = 'varchar'; + $meta2->orgname = 'varchar'; $url_params = array('db' => 'foo'); return array( From 9e26714239d33a4c66c2475ebb875c65780bdd2a Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Fri, 9 Jan 2015 21:32:03 +0530 Subject: [PATCH 2/4] Fix failing test Signed-off-by: Madhura Jayaratne --- test/classes/plugin/export/PMA_ExportSql_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/classes/plugin/export/PMA_ExportSql_test.php b/test/classes/plugin/export/PMA_ExportSql_test.php index bbbca012aa..2c7b7f9ddc 100644 --- a/test/classes/plugin/export/PMA_ExportSql_test.php +++ b/test/classes/plugin/export/PMA_ExportSql_test.php @@ -1293,7 +1293,7 @@ class PMA_ExportSql_Test extends PHPUnit_Framework_TestCase ); $this->assertContains( - 'ADD CONSTRAINT KEYS ADD FOREIGN KEY;', + ' ADD CONSTRAINT KEYS ADD FOREIGN KEY;', $GLOBALS['sql_constraints_query'] ); From 0be79a9972356c447acab729c6ba9c34aaa52b15 Mon Sep 17 00:00:00 2001 From: Marco Pozzato Date: Fri, 9 Jan 2015 15:52:08 +0100 Subject: [PATCH 3/4] Translated using Weblate (Italian) Currently translated at 80.5% (2412 of 2995 strings) [CI skip] --- po/it.po | 110 +++++++++++++++++++++++++++---------------------------- 1 file changed, 54 insertions(+), 56 deletions(-) diff --git a/po/it.po b/po/it.po index 389a1529a1..53ebc5a22f 100644 --- a/po/it.po +++ b/po/it.po @@ -4,16 +4,16 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.4.0-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2015-01-08 12:00-0500\n" -"PO-Revision-Date: 2014-06-08 22:28+0200\n" +"PO-Revision-Date: 2015-01-09 15:52+0200\n" "Last-Translator: Marco Pozzato \n" -"Language-Team: Italian \n" +"Language-Team: Italian " +"\n" +"Language: it\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: it\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 1.10-dev\n" +"X-Generator: Weblate 2.2-dev\n" #: changelog.php:36 license.php:28 #, php-format @@ -26,7 +26,7 @@ msgstr "" #: db_central_columns.php:85 msgid "The central list of columns for the current database is empty." -msgstr "" +msgstr "L'elenco centrale di colonne per il database corrente è vuota." #: db_central_columns.php:109 msgid "Click to sort." @@ -254,15 +254,15 @@ msgid "Database %1$s has been copied to %2$s." msgstr "Il database %1$s è stato copiato come %2$s." #: db_operations.php:259 -#, fuzzy, php-format +#, php-format #| msgid "" #| "The phpMyAdmin configuration storage has been deactivated. To find out " #| "why click %shere%s." msgid "" "The phpMyAdmin configuration storage has been deactivated. %sFind out why%s." msgstr "" -"Le opzioni di configurazione dello storage di phpMyAdmin sono state " -"disabilitate. Per scoprire la ragione, clicca %squi%s." +"La configurazione dello storage di phpMyAdmin è disabilitata. %sScopri la " +"ragione%s." #: db_printview.php:48 db_tracking.php:124 db_tracking.php:264 #: libraries/Menu.class.php:241 libraries/config/messages.inc.php:764 @@ -597,20 +597,18 @@ msgstr "" "sottostante nel campo \"Valore\"." #: import.php:54 -#, fuzzy #| msgid "Access denied!" msgid "Succeeded" -msgstr "Accesso negato!" +msgstr "Riuscito" #: import.php:58 js/messages.php:441 msgid "Failed" -msgstr "" +msgstr "Fallito" #: import.php:62 -#, fuzzy #| msgid "complete inserts" msgid "Incomplete params" -msgstr "inserimenti completi" +msgstr "Parametri incompleti" #: import.php:162 #, php-format @@ -901,7 +899,7 @@ msgstr "" "persone non autorizzate che scaricano la vostra configurazione." #: index.php:533 -#, fuzzy, php-format +#, php-format #| msgid "" #| "The phpMyAdmin configuration storage is not completely configured, some " #| "extended features have been deactivated. To find out why click %shere%s." @@ -909,14 +907,15 @@ msgid "" "The phpMyAdmin configuration storage is not completely configured, some " "extended features have been deactivated. %sFind out why%s. " msgstr "" -"La configurazione di phpMyAdmin non é completa, quindi alcune " -"caratteristiche aggiuntive sono state disattivate. Per scoprire perché " -"clicca %squi%s." +"La configurazione dello storage di phpMyAdmin non é completa, quindi alcune " +"caratteristiche aggiuntive sono state disattivate. %sScopri perché%s. " #: index.php:540 msgid "" "Or alternately go to 'Operations' tab of any database to set it up there." msgstr "" +"In alternativa, vai alla scheda 'Operazioni' di qualunque database per " +"configurarlo da lì." #: index.php:585 #, php-format @@ -997,7 +996,7 @@ msgstr "Cancellazione Chiave primaria/index" #, fuzzy #| msgid "Select Foreign Key" msgid "Dropping Foreign key." -msgstr "Seleziona Foreign Key" +msgstr "Scarta Foreign Key." #: js/messages.php:47 msgid "This operation could take a long time. Proceed anyway?" @@ -1014,26 +1013,23 @@ msgid "Do you really want to delete the search \"%s\"?" msgstr "Sei sicuro di voler eliminare la ricerca \"%s\"?" #: js/messages.php:50 -#, fuzzy #| msgid "" #| "You have edited some data and they have not been saved. Are you sure you " #| "want to leave this page before saving the data?" msgid "You have unsaved changes; are you sure you want to leave this page?" msgstr "" -"Hai modificato dei dati e non hai salvato. Sei sicuro di voler navigare via " -"da questa pagina senza salvare i dati?" +"Le modifiche non sono state salvate; sei sicuro di voler lasciare questa " +"pagina?" #: js/messages.php:51 -#, fuzzy #| msgid "Do you really want to delete the search \"%s\"?" msgid "Do you really want to revoke the selected user(s) ?" -msgstr "Sei sicuro di voler eliminare la ricerca \"%s\"?" +msgstr "Sei sicuro di voler eliminare l'utente/i selezionati?" #: js/messages.php:54 -#, fuzzy #| msgid "Save as file" msgid "Save & Close" -msgstr "Salva con nome" +msgstr "Salva & Chiudi" #: js/messages.php:55 libraries/config/FormDisplay.tpl.php:395 #: libraries/insert_edit.lib.php:1543 prefs_manage.php:339 @@ -1042,10 +1038,9 @@ msgid "Reset" msgstr "Riavvia" #: js/messages.php:56 -#, fuzzy #| msgid "Select All" msgid "Reset All" -msgstr "Seleziona tutto" +msgstr "Reimposta tutto" #: js/messages.php:59 msgid "Missing value in the form!" @@ -1080,25 +1075,25 @@ msgstr "Aggiungi %s campo/i all'indice" #, fuzzy #| msgid "Create routine" msgid "Create single-column index" -msgstr "Crea routine" +msgstr "Crea indice a colonna singola" #: js/messages.php:67 #, fuzzy #| msgid "Create routine" msgid "Create composite index" -msgstr "Crea routine" +msgstr "Crea indice composito" #: js/messages.php:68 #, fuzzy #| msgid "Columns enclosed with:" msgid "Composite with:" -msgstr "Campi limitati da:" +msgstr "Composto da:" #: js/messages.php:69 #, fuzzy #| msgid "Add %s column(s) to index" msgid "Please select column(s) for the index." -msgstr "Aggiungi %s campo/i all'indice" +msgstr "Selezionare la colonna/e per l'indice." #: js/messages.php:72 libraries/structure.lib.php:1679 msgid "You have to add at least one column." @@ -1111,13 +1106,11 @@ msgid "Preview SQL" msgstr "Anteprima SQL" #: js/messages.php:78 -#, fuzzy #| msgid "in query" msgid "Simulate query" -msgstr "nella query" +msgstr "Simula query" #: js/messages.php:79 -#, fuzzy #| msgid "Affected rows:" msgid "Matched rows:" msgstr "Righe coinvolte:" @@ -1362,12 +1355,14 @@ msgid "Pause monitor" msgstr "Arresta il monitoraggio" #: js/messages.php:152 libraries/server_status_processes.lib.php:37 +#, fuzzy msgid "Start auto refresh" -msgstr "" +msgstr "Avvia auto-refresh" #: js/messages.php:153 +#, fuzzy msgid "Stop auto refresh" -msgstr "" +msgstr "Ferma auto-refresh" #: js/messages.php:155 msgid "general_log and slow_query_log are enabled." @@ -1870,7 +1865,6 @@ msgid "Browse foreign values" msgstr "Naviga tra i valori esterni" #: js/messages.php:306 libraries/normalization.lib.php:849 -#, fuzzy msgid "Pick" msgstr "Seleziona" @@ -1892,26 +1886,27 @@ msgstr "" "il database %s abbia colonne non presenti nella tabella corrente." #: js/messages.php:310 -#, fuzzy #| msgid "Free memory" msgid "See more" msgstr "Vedi altri" #: js/messages.php:311 msgid "Are you sure?" -msgstr "" +msgstr "Sei sicuro?" #: js/messages.php:312 +#, fuzzy msgid "" "This action may change some of the columns definition.
Are you sure you " "want to continue?" msgstr "" +"Questa azione potrebbe cambiare la definizione di alcune colonne.
Vuoi " +"continuare?" #: js/messages.php:313 -#, fuzzy #| msgid "Contribute" msgid "Continue" -msgstr "Contribuisci" +msgstr "Continua" #: js/messages.php:316 libraries/structure.lib.php:2164 #: libraries/structure.lib.php:2167 @@ -1919,21 +1914,20 @@ msgid "Add primary key" msgstr "Aggiungi chiave primaria" #: js/messages.php:317 -#, fuzzy #| msgid "A primary key has been added on %s." msgid "Primary key added." -msgstr "Una chiave primaria è stata aggiunta in %s." +msgstr "Chiave primaria aggiunta." #: js/messages.php:318 libraries/normalization.lib.php:174 #, fuzzy #| msgid "Tracking report" msgid "Taking you to next step…" -msgstr "Rapporto tracking" +msgstr "Alla fase successiva…" #: js/messages.php:319 #, php-format msgid "The first step of normalization is complete for table '%s'." -msgstr "" +msgstr "La prima fase di normalizzazione per la tabella '%s' è completa." #: js/messages.php:320 libraries/normalization.lib.php:422 #: libraries/normalization.lib.php:469 libraries/normalization.lib.php:552 @@ -1941,11 +1935,11 @@ msgstr "" #, fuzzy #| msgid "End of line" msgid "End of step" -msgstr "Fine del file" +msgstr "Fase terminata" #: js/messages.php:321 msgid "Second step of normalization (2NF)" -msgstr "" +msgstr "Seconda fase di normalizzazione (2NF)" #. l10n: Display text for calendar close link #: js/messages.php:322 js/messages.php:556 libraries/normalization.lib.php:264 @@ -1954,47 +1948,51 @@ msgstr "Fatto" #: js/messages.php:323 msgid "Confirm partial dependencies" -msgstr "" +msgstr "Conferma dipendenze parziali" #: js/messages.php:324 +#, fuzzy msgid "Selected partial dependencies are as follows:" -msgstr "" +msgstr "Le dipendenze parziali selezionate sono come segue:" #: js/messages.php:325 msgid "" "Note: a, b -> d,f implies values of columns a and b combined together can " "determine values of column d and column f." msgstr "" +"Nota: a, b -> d, f implica che i valori delle colonne a e b combinati " +"possono determinare i valori delle colonne d ed f." #: js/messages.php:326 -#, fuzzy #| msgid "No databases selected." msgid "No partial dependencies selected!" -msgstr "Nessun database selezionato." +msgstr "Nessuna dipendenza parziale selezionata!" #: js/messages.php:328 msgid "Show me the possible partial dependencies based on data in the table" msgstr "" +"Mostrami le possibili dipendenze parziali basandoti sui dati nella tabella" #: js/messages.php:329 msgid "Hide partial dependencies list" -msgstr "" +msgstr "Nascondi la lista delle dipendenze parziali" #: js/messages.php:330 msgid "" "Sit tight! It may take few seconds depending on data size and column count " "of the table." msgstr "" +"Stai pronto! Potrebbero volerci alcuni secondi, in base alla quantità di " +"dati e al numero di colonne della tabella." #: js/messages.php:331 msgid "Step" -msgstr "" +msgstr "Fase" #: js/messages.php:332 -#, fuzzy #| msgid "The following queries have been executed:" msgid "The following actions will be performed:" -msgstr "Le seguenti query sono state eseguite:" +msgstr "Verranno eseguite le seguenti azioni:" #: js/messages.php:333 #, php-format From f805f09bc4d26000691c89301af52ee4b76fdd1b Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Fri, 9 Jan 2015 21:52:24 +0530 Subject: [PATCH 4/4] Fix failing test Signed-off-by: Madhura Jayaratne --- libraries/transformations.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/transformations.lib.php b/libraries/transformations.lib.php index 128f1fb293..a202e0ea99 100644 --- a/libraries/transformations.lib.php +++ b/libraries/transformations.lib.php @@ -200,9 +200,9 @@ function PMA_getMIME($db, $table, $strict = false, $fullName = false) if ($fullName) { $com_qry .= "SELECT CONCAT(" . "`db_name`, '.', `table_name`, '.', `column_name`" - . ") AS column_name,"; + . ") AS column_name, "; } else { - $com_qry = "SELECT `column_name`,"; + $com_qry = "SELECT `column_name`, "; } $com_qry .= '`mimetype`, `transformation`,