From fa64f7773843c5e1332930e560873e24d70605a1 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sat, 22 Aug 2009 18:31:10 -0400 Subject: [PATCH] fix bug in post normailzation --- classes/ComicPressComicPost.inc | 12 +++++++++--- test/ComicPressComicPostTest.php | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/classes/ComicPressComicPost.inc b/classes/ComicPressComicPost.inc index 5e458c3..6bb91a8 100644 --- a/classes/ComicPressComicPost.inc +++ b/classes/ComicPressComicPost.inc @@ -170,10 +170,16 @@ class ComicPressComicPost { usort($remaining_posts_to_sort[$type], array(&$this, 'sort_remaining_comic_images')); } - $result = array_merge($comic_image_ordering, $remaining_posts_to_sort); + foreach ($remaining_posts_to_sort as $type => $posts) { + if (is_array($comic_image_ordering[$type])) { + $comic_image_ordering[$type] = array_merge($comic_image_ordering[$type], $posts); + } else { + $comic_image_ordering[$type] = $posts; + } + } - update_post_meta($this->post->ID, 'comic_ordering', $this->build_comic_ordering_string($result)); - return $result; + update_post_meta($this->post->ID, 'comic_ordering', $this->build_comic_ordering_string($comic_image_ordering)); + return $comic_image_ordering; } } diff --git a/test/ComicPressComicPostTest.php b/test/ComicPressComicPostTest.php index 286ca56..da35d04 100644 --- a/test/ComicPressComicPostTest.php +++ b/test/ComicPressComicPostTest.php @@ -151,7 +151,7 @@ class ComicPressComicPostTest extends PHPUnit_Framework_TestCase { $p->expects($this->any())->method('get_comic_image_attachments')->will($this->returnValue($attachments)); wp_insert_post((object)array('ID' => 1)); - update_post_meta(1, 'comic_ordering', "comic:3,2"); + update_post_meta(1, 'comic_ordering', "comic:3"); $p->post = (object)array('ID' => 1);