2014-12-19 07:54 EST

View Issue Details Jump to Notes ] Wiki ] Related Changesets ]
IDProjectCategoryView StatusLast Update
0011166mantisbtadministrationpublic2012-12-28 17:11
Reporterchrisnik 
Assigned Todhx 
PriorityhighSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
Product Version1.2.0rc2 
Target Version1.2.1Fixed in Version1.2.1 
Summary0011166: new configuration option of 'complex' type is created with string type
DescriptionWhen 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
  • pdf file icon Pictures.pdf (79,276 bytes) 2009-11-12 06:13
  • pdf file icon Picture better.pdf (79,281 bytes) 2009-11-12 06:16
  • png file icon picture1.png (55,577 bytes) 2009-11-12 06:47 - 
    png file icon picture1.png (55,577 bytes) 2009-11-12 06:47 + 
  • png file icon picture2.png (18,365 bytes) 2009-11-12 06:47 - 
    png file icon picture2.png (18,365 bytes) 2009-11-12 06:47 + 
  • diff file icon adm_config_set.php.diff (1,454 bytes) 2010-03-02 01:58 - 
    --- 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 {
    
    diff file icon adm_config_set.php.diff (1,454 bytes) 2010-03-02 01:58 + 

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

-  Notes
User avatar

~0023683

yw84ever (reporter)

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

~0023861

rolfkleef (reporter)

Having the same problem in version 1.1.7 right now.
User avatar

~0024368

snyderc (reporter)

I can confirm this in 1.1.8 as well.
User avatar

~0024381

dhx (reporter)

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.
User avatar

~0024584

k_nitin_r (reporter)

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.
User avatar

~0024585

k_nitin_r (reporter)

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
}
User avatar

~0024680

fman (reporter)

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
User avatar

~0024681

atrol (developer)

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 ]
User avatar

~0024697

wodghor (reporter)

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
User avatar

~0024698

fman (reporter)

@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.
User avatar

~0024701

atrol (developer)

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

~0024702

fman (reporter)

@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
User avatar

~0025211

dhx (reporter)

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 "=>"
+  Notes

- Related Changesets
MantisBT: master 4dd383f5
Timestamp: 2010-04-23 02:40:36
Author: 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 "=>"
mod - adm_config_set.php Diff ] File ]
MantisBT: master-1.2.x 7f68bdba
Timestamp: 2010-04-23 02:40:36
Author: 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 "=>"
mod - adm_config_set.php Diff ] File ]

+ Related Changesets

- Issue History
Date Modified Username Field Change
2009-11-12 06:13 chrisnik New Issue
2009-11-12 06:13 chrisnik File Added: Pictures.pdf
2009-11-12 06:16 chrisnik File Added: Picture better.pdf
2009-11-12 06:47 yw84ever File Added: picture1.png
2009-11-12 06:47 yw84ever File Added: picture2.png
2009-11-12 06:48 yw84ever Note Added: 0023683
2009-12-06 06:26 rolfkleef Note Added: 0023861
2010-02-10 14:22 snyderc Note Added: 0024368
2010-02-12 08:21 dhx Note Added: 0024381
2010-02-12 08:21 dhx Status new => confirmed
2010-02-12 08:21 dhx Priority normal => high
2010-02-12 08:21 dhx Target Version => 1.2.2
2010-02-22 14:32 jreese Target Version 1.2.0 => 1.2.2
2010-03-02 01:58 k_nitin_r File Added: adm_config_set.php.diff
2010-03-02 02:05 k_nitin_r Note Added: 0024584
2010-03-02 02:08 k_nitin_r Note Added: 0024585
2010-03-09 03:03 fman Note Added: 0024680
2010-03-09 04:48 atrol Note Added: 0024681
2010-03-11 05:49 wodghor Note Added: 0024697
2010-03-11 06:10 fman Note Added: 0024698
2010-03-11 08:52 atrol Note Added: 0024701
2010-03-11 09:06 fman Note Added: 0024702
2010-04-21 09:14 jreese Target Version 1.2.1 => 1.2.2
2010-04-22 22:48 dhx Assigned To => dhx
2010-04-22 22:48 dhx Severity minor => major
2010-04-22 22:48 dhx Status confirmed => assigned
2010-04-22 22:48 dhx Target Version 1.2.2 => 1.2.1
2010-04-22 22:49 dhx Note Added: 0025211
2010-04-22 22:49 dhx Status assigned => resolved
2010-04-22 22:49 dhx Fixed in Version => 1.2.1
2010-04-22 22:49 dhx Resolution open => fixed
2010-04-22 22:50 dhx Changeset attached => MantisBT master 4dd383f5
2010-04-22 22:50 dhx Changeset attached => MantisBT master-1.2.x 7f68bdba
2010-04-23 14:30 jreese Status resolved => closed
2012-12-28 17:11 dregad Relationship added related to 0013298
+ Issue History