[evolvis-commits] r17121: [#944] Unbreak again after svn r17118↵ ↵ This breakage can only be fixed by introducing a new format↵ for =?UTF-8?Q?=20the=20art=5Fcust=20prefere?==?UTF-8?Q?nces?=. Note, it is generally a bad↵ idea to introduce optional fields _before_ non-optional ones↵ in CSV data…?==?UTF-8?Q?↵

mirabilos at evolvis.org mirabilos at evolvis.org
Wed Mar 9 11:15:00 CET 2011


Author: mirabilos
Date: 2011-03-09 11:15:00 +0100 (Wed, 09 Mar 2011)
New Revision: 17121

Modified:
   trunk/gforge_base/evolvisforge/gforge/common/tracker/ArtifactFactory.class.php
Log:
[#944] Unbreak again after svn r17118

This breakage can only be fixed by introducing a new format
for the art_cust preferences. Note, it is generally a bad
idea to introduce optional fields _before_ non-optional ones
in CSV data…


Modified: trunk/gforge_base/evolvisforge/gforge/common/tracker/ArtifactFactory.class.php
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/common/tracker/ArtifactFactory.class.php	2011-03-08 13:48:58 UTC (rev 17120)
+++ trunk/gforge_base/evolvisforge/gforge/common/tracker/ArtifactFactory.class.php	2011-03-09 10:15:00 UTC (rev 17121)
@@ -132,18 +132,43 @@
 				} else {
 					$custom_pref=$u->getPreference('art_cust'.$this->ArtifactType->getID());
 					if ($custom_pref) {
-//$_assigned_to.'|'.$_status.'|'.$_order_col.'|'.$_sort_ord.'|'.$_changed.'|'.serialize($_extra_fields).'|'.$_submitted_by
-						$pref_arr=explode('|',$custom_pref);
-						$_assigned_to=$pref_arr[0];
-						$_status=$pref_arr[1];
-						$order_col=$pref_arr[2];
-						$sort=$pref_arr[3];
-						$_changed=$pref_arr[4];
-						$_submitted_by = util_ifsetor($pref_arr[5], 0); //It is $pref_arr[5] definitely
-						if ($this->ArtifactType->usesCustomStatuses()) {
-							$_extra_fields=unserialize($pref_arr[4]);
+/**
+ * $custom_pref is in one of the following formats:
+ * v2|_assigned_to|_status|_order_col|_sort_ord|_changed|_submitted_by|serialize(_extra_fields)
+ * _assigned_to|_status|_order_col|_sort_ord|_changed|_submitted_by|serialize(_extra_fields)
+ * _assigned_to|_status|_order_col|_sort_ord|_changed|serialize(_extra_fields)|_submitted_by
+ * (This is due to some earlier programming bugs.) Since we cannot
+ * distinguish between the latter two, we only use fields 0-4 there,
+ * fields 1-7 for v2 format prefs.
+ */
+						$pref_arr = explode('|', $custom_pref);
+						if ($pref_arr[0] === 'v2') {
+							$_assigned_to = $pref_arr[1];
+							$_status = $pref_arr[2];
+							$order_col = $pref_arr[3];
+							$sort = $pref_arr[4];
+							$_changed = $pref_arr[5];
+							$_submitted_by = $pref_arr[6];
+							$_extra_fields = unserialize($pref_arr[7]);
 						} else {
-							$_status=$pref_arr[1];
+							/*
+							 * cope with bugs in
+							 * earlier Evolvis -
+							 * sucks, but what can
+							 * we do… [#944]
+							 */
+							$_assigned_to = $pref_arr[0];
+							$_status = $pref_arr[1];
+							$order_col = $pref_arr[2];
+							$sort = $pref_arr[3];
+							$_changed = $pref_arr[4];
+							/* if it’s numeric, chances are good */
+							$_submitted_by = $pref_arr[5];
+							$tmp = (int)$_submitted_by;
+							if ($_submitted_by != $tmp)
+								$_submitted_by = 0;
+							/* we take no chances here */
+							$_extra_fields = array();
 						}
 						$set='custom';
 					} else {
@@ -199,11 +224,14 @@
 				}
 
 				$extra_pref = '';
-				if (count($aux_extra_fields)>0) {
-					$extra_pref = '|'.serialize($aux_extra_fields);
+				if (count($aux_extra_fields) > 0) {
+					$extra_pref = serialize($aux_extra_fields);
 				}
 				
-				$pref_=$_assigned_to.'|'.$_status.'|'.$_order_col.'|'.$_sort_ord.'|'.$_changed.$extra_pref.'|'.$_submitted_by;
+				$pref_ = 'v2|' . $_assigned_to . '|' .
+				    $_status . '|' . $_order_col . '|' .
+				    $_sort_ord . '|' . $_changed . '|' .
+				    $_submitted_by . '|' . $extra_pref;
 				if ($pref_ != $u->getPreference('art_cust'.$this->ArtifactType->getID())) {
 					$u->setPreference('art_cust'.$this->ArtifactType->getID(),$pref_);
 				}



More information about the evolvis-commits mailing list