View Issue Details

IDProjectCategoryView StatusLast Update
0009455mantisbtadministrationpublic2009-06-26 12:05
Reporterjblanchon Assigned Tojreese  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version1.1.2 
Summary0009455: Database configuration does not correctly deal with array
Description

In the database configuration page, since 1.1.2 version, it is not possible to set a configuration option which is of type array. Mantis always consider it as a string.

Running the adm_config_report.php page and setting a configuration option which is an array

Steps To Reproduce
  • Run the adm_config_report.php
  • Set a configuration option which is an array

For instance :

Type : Complex
Value : array ( 'id', 'summary', 'date_submitted' )

The value is the considered as a string :

Type : String
Value : 'array ( 'id', 'summary', 'date_submitted' )'

TagsNo tags attached.

Relationships

duplicate of 0009426 closedgiallu Creating the view_issues_page_columns creates a string 

Activities

jreese

jreese

2008-07-30 10:51

reporter   ~0018926

This is already fixed in SVN r5420 (1.1.x) and r5421 (trunk).

seweso

seweso

2009-01-12 04:32

reporter   ~0020585

This still doesn't work (in 1.1.5)

jreese

jreese

2009-01-13 11:26

reporter   ~0020609

Reminder sent to: giallu

IIRC, the way complex types needed to be specified changed at this point. Giallu, can you help him?

The documentation in the code specifies:

We support these kind of variables here:

    # 1. constant values (like the ON/OFF switches): they are defined as constants mapping to numeric values
    # 2. simple arrays with the form: array( a, b, c, d )
    # 3. associative arrays with the form: array( a=>1, b=>2, c=>3, d=>4 )

giallu

giallu

2009-01-13 16:32

reporter   ~0020614

seweso, if you have problems in setting an option in the interface (anyway, I'd still suggest storing it in the config_inc.php file), please detail what are you doing and what do you get.

For this purpose, it is preferred to use the mailing list mantisbt-help@lists.sourceforge.net or our forums http://www.mantisbt.org/forums.

karotos

karotos

2009-01-30 10:46

reporter   ~0020756

Last edited: 2009-01-30 10:47

It works just fine when you use it as jreese wrote.
The problem is that it is very selective:
array( a=>1, b=>2, c=>3, d=>4 )
is ok, but the following, very common ways to represent an array, are not.
array(
a=>1,
b=>2,
c=>3,
d=>4
)
or
array( a=>"1", b=>"2", c=>"3", d=>"4" )

I had a lot of trouble with this one because the easy way to introduce new entries is to copy the existing ones from the view and alter them (which doesn't work since quotation is not allowed, neither are line breaks)

Maybe adding some help right on the configuration admin screen would be a good idea

giallu

giallu

2009-01-30 11:18

reporter   ~0020757

yeas, unfortunately, the strictness is a side effect of the fix for the security issue detailed in 0008976.

It would be nice to have an improved system for editing the configuration options, ideas are welcome on the mantisbt-devel mailing list.

anthropic

anthropic

2009-05-21 02:51

reporter   ~0021868

I changed mine to the following which worked for me, sorry I don't use git so I can't make a patch for it, but can anyone see any reason why this isn't ok?

adm_config_set.php line 84

if ( preg_match('/array[\s]*\(([\s\S]*)\)/', $t_full_string, $t_match ) === 1 ) {
        // we have an array here
        $t_values = preg_split("/,[\s]+/", trim( $t_match[1] ) );
        foreach ( $t_values as $key => $value ) {
            $t_split = preg_split( "/[\s]*=>[\s]*/",  $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_new_value = ereg_replace("'?([^\']+)'?,?", '\\1', $t_new_value);
                $t_value[ $t_new_key ] = $t_new_value;
            }
anthropic

anthropic

2009-05-21 02:52

reporter   ~0021869

It allows me to cut & paste previous values and edit them, I haven't tested with all array types admittedly, but I haven't needed them at all so don't have time to do that sorry.

anthropic

anthropic

2009-05-21 03:29

reporter   ~0021870

The last ereg_replace should have '"' included also perhaps but I think as long as one format works people can be happy enough with it.
\"?'?([^\"']+)\"?'?,?

Related Changesets

MantisBT: master c6393d1d

2008-07-25 12:37

giallu


Details Diff
Loosen regexp matching as suggested in bug 0009426

git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@5421 <a class="text" href="/?p=mantisbt.git;a=object;h=f5dc347c">f5dc347c</a>-c33d-0410-90a0-b07cc1902cb9
Affected Issues
0009426, 0009455
mod - adm_config_set.php Diff File