This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "FusionForge".
The branch, master has been updated via df60c9d181f9eb4806853779dee8adcae23c3a52 (commit) via 6769c44de02277d5318c151dcf34a789789cdcdc (commit) from 2848045a5df9fd01c93759db05f6fb72928e012e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=df60c9d181f9eb4806853779dee8adcae23c3a52 commit df60c9d181f9eb4806853779dee8adcae23c3a52 Author: Franck Villaume <franck.villa...@trivialdev.com> Date: Mon May 3 19:23:24 2021 +0200 remove the delete contents section. no need since another request able the content for the other column. + clean-up diff --git a/src/common/widget/WidgetLayoutManager.class.php b/src/common/widget/WidgetLayoutManager.class.php index 4a21447..a212604 100644 --- a/src/common/widget/WidgetLayoutManager.class.php +++ b/src/common/widget/WidgetLayoutManager.class.php @@ -753,7 +753,7 @@ class WidgetLayoutManager { next($new); } $sql = "UPDATE layouts_contents - SET layout_id = $1, column_id =$2 + SET layout_id = $1, column_id = $2 WHERE owner_type =$3 AND owner_id =$4 AND layout_id =$5 @@ -930,17 +930,15 @@ class WidgetLayoutManager { //See if it already exists but not used $sql = "SELECT column_id FROM layouts_contents - WHERE owner_type =$1 + WHERE owner_type = $1 AND owner_id = $2 AND layout_id = $3 AND name = $4"; $res = db_query_params($sql, array($owner_type, $owner_id, $layout_id, $name)); - echo db_error(); if (db_numrows($res) && !$widget->isUnique() && db_result($res, 0, 'column_id') == 0) { //search for rank $sql = "SELECT min(rank) - 1 AS rank FROM layouts_contents WHERE owner_type =$1 AND owner_id = $2 AND layout_id = $3 AND column_id = $4 "; $res = db_query_params($sql, array($owner_type, $owner_id, $layout_id, $column_id)); - echo db_error(); $rank = db_result($res, 0, 'rank'); //Update @@ -951,7 +949,6 @@ class WidgetLayoutManager { AND name = $5 AND layout_id = $6"; db_query_params($sql, array($column_id, $rank, $owner_type, $owner_id, $name, $layout_id)); - echo db_error(); } else { //Insert $sql = "INSERT INTO layouts_contents(owner_type, owner_id, layout_id, column_id, name, content_id, rank) @@ -961,7 +958,6 @@ class WidgetLayoutManager { ORDER BY rank ASC LIMIT 1"; db_query_params($sql, array($name, $content_id, $owner_type, $owner_id, $layout_id, $column_id)); - echo db_error(); } $this->feedback(); } @@ -1070,6 +1066,7 @@ class WidgetLayoutManager { $names[] = array($id, $name); } + db_begin(); //Compute differences $originals = array(); $sql = "SELECT * FROM layouts_contents WHERE owner_type = $1 AND owner_id = $2 AND column_id = $3 ORDER BY rank"; @@ -1079,27 +1076,6 @@ class WidgetLayoutManager { $originals[] = array($data['content_id'], $data['name']); } - //delete removed contents - $deleted_names = utils_array_diff_names($originals, $names, ); - if (count($deleted_names)) { - $_and = ''; - foreach($deleted_names as $id => $name) { - if ($_and) { - $_and .= ' OR '; - } else { - $_and .= ' AND ('; - } - $_and .= " (name = '".$name[1]."' AND content_id = ". $name[0] .") "; - } - $_and .= ')'; - $sql = "UPDATE layouts_contents - SET column_id = 0 - WHERE owner_type = $1 - AND owner_id = $2 - AND column_id = $3". $_and; - db_query_params($sql, array($owner_type, $owner_id, $column_id)); - } - //Insert new contents $added_names = utils_array_diff_names($names, $originals); if (count($added_names)) { @@ -1122,6 +1098,8 @@ class WidgetLayoutManager { db_query_params($sql, array($column_id, $owner_type, $owner_id, $layout_id)); } + // we do not need to delete old contents since another request is sent to add the new content to the other column. + //Update ranks $rank = 0; $values = array(); @@ -1129,6 +1107,7 @@ class WidgetLayoutManager { $sql = 'UPDATE layouts_contents SET rank = $1 WHERE owner_type =$2 AND owner_id = $3 AND column_id = $4 AND name = $5 AND content_id = $6'; db_query_params($sql, array($rank++, $owner_type, $owner_id, $column_id, $name[1], $name[0])); } + db_commit(); } } } https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=6769c44de02277d5318c151dcf34a789789cdcdc commit 6769c44de02277d5318c151dcf34a789789cdcdc Author: Franck Villaume <franck.villa...@trivialdev.com> Date: Mon May 3 19:22:11 2021 +0200 reset array pointer to ensure we loop on all elements diff --git a/src/common/include/utils.php b/src/common/include/utils.php index 80c76d8..ee96ae3 100644 --- a/src/common/include/utils.php +++ b/src/common/include/utils.php @@ -1651,6 +1651,7 @@ function compareObjectName ($a, $b) { */ function utils_array_diff_names($tab1, $tab2) { $diff = array(); + reset($tab1); foreach($tab1 as $e1) { $found = false; reset($tab2); @@ -1661,6 +1662,8 @@ function utils_array_diff_names($tab1, $tab2) { $diff[] = $e1; } } + reset($tab1); + reset($tab2); return $diff; } ----------------------------------------------------------------------- Summary of changes: src/common/include/utils.php | 3 +++ src/common/widget/WidgetLayoutManager.class.php | 33 +++++-------------------- 2 files changed, 9 insertions(+), 27 deletions(-) hooks/post-receive -- FusionForge _______________________________________________ Fusionforge-commits mailing list Fusionforge-commits@lists.fusionforge.org http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits