]> git.mxchange.org Git - friendica.git/commitdiff
Fix GROUP BY in dbstructure
authorAlexandre Alapetite <alexandre@alapetite.fr>
Sun, 7 May 2017 08:53:38 +0000 (10:53 +0200)
committerAlexandre Alapetite <alexandre@alapetite.fr>
Sun, 7 May 2017 08:53:38 +0000 (10:53 +0200)
https://github.com/friendica/friendica/issues/3440

boot.php
include/dbstructure.php
update.php

index dfb1073b1cd0b0377dfd5199073aecc9298ed04a..45029fecd2eaf174bf877cd5ffcd19b7f3cd5f13 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM',     'Friendica');
 define ( 'FRIENDICA_CODENAME',     'Asparagus');
 define ( 'FRIENDICA_VERSION',      '3.5.2-dev' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.23'    );
-define ( 'DB_UPDATE_VERSION',      1223      );
+define ( 'DB_UPDATE_VERSION',      1224      );
 
 /**
  * @brief Constant with a HTML line break.
index 8c29eb641526f619d9cc9c330e6f38c004bfedd0..7fcec33a68c2277ec7f7d24a8461e02235971a26 100644 (file)
@@ -398,6 +398,12 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
                                $sql3 .= ";";
                        }
 
+                       $field_list = '';
+                       foreach ($structure['fields'] AS $fieldname => $parameters) {
+                               $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
+                       }
+                       $field_list = rtrim($field_list, ',');
+                       
                        if ($verbose) {
                                // Ensure index conversion to unique removes duplicates
                                if ($is_unique) {
@@ -414,7 +420,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
                                        if ($ignore != "") {
                                                echo "SET session old_alter_table=0;\n";
                                        } else {
-                                               echo "INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";\n";
+                                               echo "INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";\n";
                                                echo "DROP TABLE `".$name."`;\n";
                                                echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
                                        }
@@ -445,7 +451,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
                                        if ($ignore != "") {
                                                $db->q("SET session old_alter_table=0;");
                                        } else {
-                                               $r = $db->q("INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";");
+                                               $r = $db->q("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
                                                if (!dbm::is_result($r)) {
                                                        $errors .= print_update_error($db, $sql3);
                                                        return $errors;
index 31a3068ea5ff477204da0b0d06d14d8901f4fb72..e3b1c31b33a5fee9cc01c8c97eb11b6877ef7a3c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-define('UPDATE_VERSION' , 1223);
+define('UPDATE_VERSION' , 1224);
 
 /**
  *