This is kind of similar to http://drupal.org/node/1089816.

On arrays that are part indexed and part associative, ksort is returning different values back, which is causing false overrides. I know these can be avoided but it would be nice if the Feature showed as DEFAULT.

Example (0 index is throwing ksort for a loop):

$a = array(
  'meta_name' => 'description',
  0 => 'meta_name',
  'test_key' => 'test_val'
);
ksort($a);
/*
Array
(
    [test_key] => test_val
    [0] => meta_name
    [meta_name] => description
)
*/

$b = array(
  0 => 'meta_name',
  'meta_name' => 'description',
  'test_key' => 'test_val'
);
ksort($b);
/*
Array
(
    [0] => meta_name
    [meta_name] => description
    [test_key] => test_val
)
*/

What do you think about adding a sort_flag, i.e.
864 ksort($array);
to
864 ksort($array, SORT_STRING);

This will alter how indexed arrays return back, i.e. 11 before 2, but that shouldn't be an issue as this is just trying to normalize 2 arrays for comparative purposes.

Thanks

CommentFileSizeAuthor
#1 features_sanitize_sort-1760734-1.patch414 bytesmpotter

Comments

mlee11111’s picture

Issue summary: View changes

Added code tags.

mlee11111’s picture

Issue summary: View changes

Made easier to read.

mpotter’s picture

Status: Needs work » Needs review
StatusFileSize
new414 bytes

Interesting. I think this is reasonable. Some quick testing doesn't show any side effects so far. Here is an actual patch for review.

mlee11111’s picture

Sorry I didn't submit a patch file, but that's exactly what I had.

PHP 5.4 has a SORT_NATURAL which would make the sort even nicer, but SORT_STRING does the trick for now.

Seems to bring my features into full synchronization with no noticeable effects.

Thanks for the quick response.

alexander allen’s picture

Status: Needs review » Active

Tested, works. All the false overrides I had due to 'meta_name' => 'description' are now gone. This is great, thank you very much!

alexander allen’s picture

Status: Active » Needs review

Accidentally changed status.

roderik’s picture

Version: 7.x-1.0 » 7.x-2.0-alpha2
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Grammer fix.