View Issue Details

IDProjectCategoryView StatusLast Update
0011166mantisbtadministrationpublic2012-12-28 17:11
Reporterchrisnik Assigned Todhx  
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version1.2.0rc2 
Target Version1.2.1Fixed in Version1.2.1 
Summary0011166: new configuration option of 'complex' type is created with string type
Description

When you try to set configuration option of 'complex' type, the option is created with string type

Steps To Reproduce
  • log in as administrator
  • go to Manage | Configuration Report
  • scroll down and in the Set Configuration Option island set the Configuration Option field to view_issues_page_columns
  • select type complex OR default in in the field Type
  • as value specify:
    array (
    0 => 'selection',
    1 => 'edit',
    2 => 'priority',
    3 => 'id',
    4 => 'category_id',
    5 => 'status',
    6 => 'last_updated',
    7 => 'summary',
    )

(see Picture 1)

  • Press enter
  • => the option is create as string

(See Picture 2)

TagsNo tags attached.
Attached Files
Pictures.pdf (79,276 bytes)
Picture better.pdf (79,281 bytes)
picture1.png (55,577 bytes)   
picture1.png (55,577 bytes)   
picture2.png (18,365 bytes)   
picture2.png (18,365 bytes)   
adm_config_set.php.diff (1,454 bytes)   
--- adm_config_set.php	Tue Mar  2 10:44:32 2010
+++ adm_config_set_new.php	Tue Mar  2 10:30:46 2010
@@ -101,18 +101,21 @@ if ( $t_type === 'string' ) {
 	# 3. associative arrays with the form: array( a=>1, b=>2, c=>3, d=>4 )
 	$t_full_string = trim( $f_value );
 	if ( preg_match('/array[\s]*\((.*)\)/', $t_full_string, $t_match ) === 1 ) {
-		// we have an array here
-		$t_values = explode( ',', trim( $t_match[1] ) );
-		foreach ( $t_values as $key => $value ) {
-			$t_split = explode( '=>', $value, 2 );
-			if ( count( $t_split ) == 2 ) {
-				// associative array
-				$t_new_key = constant_replace( trim( $t_split[0] ) );
-				$t_new_value = constant_replace( trim( $t_split[1] ) );
-				$t_value[ $t_new_key ] = $t_new_value;
-			} else {
-				// regular array
-				$t_value[ $key ] = constant_replace( trim( $value ) );
+		@eval('$t_value='.$t_full_string);
+		if (!$t_value) {
+			// we have an array here
+			$t_values = explode( ',', trim( $t_match[1] ) );
+			foreach ( $t_values as $key => $value ) {
+				$t_split = explode( '=>', $value, 2 );
+				if ( count( $t_split ) == 2 ) {
+					// associative array
+					$t_new_key = constant_replace( trim( $t_split[0] ) );
+					$t_new_value = constant_replace( trim( $t_split[1] ) );
+					$t_value[ $t_new_key ] = $t_new_value;
+				} else {
+					// regular array
+					$t_value[ $key ] = constant_replace( trim( $value ) );
+				}
 			}
 		}
 	} else {
adm_config_set.php.diff (1,454 bytes)   

Relationships

related to 0013298 closeddregad commas and multi-dimensional arrays in adm_config_set 

Activities

yw84ever

yw84ever

2009-11-12 06:48

reporter   ~0023683

extracted the pictures from the pdf files, adding them as images so they can be previewed within the ticket

rolfkleef

rolfkleef

2009-12-06 06:26

reporter   ~0023861

Having the same problem in version 1.1.7 right now.

snyderc

snyderc

2010-02-10 14:22

reporter   ~0024368

I can confirm this in 1.1.8 as well.

dhx

dhx

2010-02-12 08:21

reporter   ~0024381

You can't use line breaks when specifying the "value" AFAIK. The array has to be defined on a single line for things to work. This is something I consider high on the list of bugs to fix for 1.2.x

Thanks for the bug report.

k_nitin_r

k_nitin_r

2010-03-02 02:05

reporter   ~0024584

Hi!

I've posted a patch that illustrates the use of eval to try to convert the string into an actual array. PHP automatically adds detects unquoted strings and converts them to actual strings and so accepts input in various formats so can accept something like this:
array(a => 1, b => 2)
though it should've been:
array('a' => 1, 'b' => 2)

The use of eval may have security implications, but as the Manage Configuration page is used only by the administrator (i.e. Mantis has a privilege-check to ensure other users don't access the page), the possibility for an attack is minimal.

k_nitin_r

k_nitin_r

2010-03-02 02:08

reporter   ~0024585

BTW, would a check like the following be appropriate for determining if the user has entered an array, instead of using a regex check?

$var1check = trim($t_full_string);
if (strlen($var1check)>7 && substr($var1check, 0, 5) == 'array' && substr($var1check, strlen($var1check)-1, 1) == ')') {
//eval the string here
}

fman

fman

2010-03-09 03:03

reporter   ~0024680

this issue is making a nightmare my upgrade from 1.1.1 to 1.2.0. do you have any idea (more than the workaround) when will be fixed ?

regards

Francisco

atrol

atrol

2010-03-09 04:48

developer   ~0024681

at least to manage the columns you have not to use this dialog, there is another page since 1.2 which also does the job: [ Manage Columns ]

wodghor

wodghor

2010-03-11 05:49

reporter   ~0024697

Hi! Ok now I can change simple arrays (with no line breaks). But how can I change arrays with two dimensions like status_enum_workflow?

Thanks

fman

fman

2010-03-11 06:10

reporter   ~0024698

@atrol: You are right, but this option exists if I'm not wrong on for each user on [Manage Account], only drawback need to ask each user to do this change in every project.

atrol

atrol

2010-03-11 08:52

developer   ~0024701

@fman: There is [ Managage ] -> [ Manage Configuration ] -> [ Manage Columns ] which can be used to set defaults for all users

fman

fman

2010-03-11 09:06

reporter   ~0024702

@atrol: Thanks, with this I solve part of my problems => column config, but as pointed by wodghor other persist.
Do you think I can try to fix code using code from 1.1.1 ?

regards

dhx

dhx

2010-04-22 22:49

reporter   ~0025211

I just finished fixing a lot of the problems with setting complex array types. You'll see these fixes in v1.2.1 :)

Current bugs:

  • Cannot handle multidimensional arrays
  • Key and value strings cannot contain commas or "=>"

Related Changesets

MantisBT: master 4dd383f5

2010-04-22 22:40

dhx


Details Diff
Fix 0011166: Complex types could not be entered with newline chars

When setting complex configuration values via Manage Configuration =>
Configuration Report, newline characters weren't parsed correctly. This
meant that users had to enter complex array types on a single line.

This patch resolves the issue by stripping newline characters from any
complex type entered. It also applies a few other fixes to the parsing
of complex array types.

Bugs do remain and this complex array parsing is still very limited. The
current problems are:
* An inability to parse multidimensional arrays
* Array keys and values cannot contain commas or "=>"
Affected Issues
0011166
mod - adm_config_set.php Diff File

MantisBT: master-1.2.x 7f68bdba

2010-04-22 22:40

dhx


Details Diff
Fix 0011166: Complex types could not be entered with newline chars

When setting complex configuration values via Manage Configuration =>
Configuration Report, newline characters weren't parsed correctly. This
meant that users had to enter complex array types on a single line.

This patch resolves the issue by stripping newline characters from any
complex type entered. It also applies a few other fixes to the parsing
of complex array types.

Bugs do remain and this complex array parsing is still very limited. The
current problems are:
* An inability to parse multidimensional arrays
* Array keys and values cannot contain commas or "=>"
Affected Issues
0011166
mod - adm_config_set.php Diff File