diff --git a/classes/ComicPressAdmin.inc b/classes/ComicPressAdmin.inc index b223114..a9a5e2e 100644 --- a/classes/ComicPressAdmin.inc +++ b/classes/ComicPressAdmin.inc @@ -215,8 +215,10 @@ class ComicPressAdmin { foreach ($_POST['attachments'] as $post_id => $settings) { if (isset($settings['comicpress_management'])) { $media_post = get_post($post_id); - $media_post->post_parent = $settings['post_parent']; - wp_update_post($media_post); + if (isset($media_post->post_parent)) { + $media_post->post_parent = $settings['post_parent']; + wp_update_post($media_post); + } } update_post_meta($post_id, 'comicpress', array( 'managed' => isset($settings['comicpress_management'] diff --git a/classes/ComicPressStoryline.inc b/classes/ComicPressStoryline.inc index 0ad8bce..d68f5e8 100644 --- a/classes/ComicPressStoryline.inc +++ b/classes/ComicPressStoryline.inc @@ -156,13 +156,16 @@ class ComicPressStoryline { if (isset($this->_structure[$id])) { $all_adjacent = array(); do { - $new_id = $this->_structure[$id][$direction]; - $has_adjacent = false; - if (!in_array($new_id, $all_adjacent)) { - if ($has_adjacent = isset($this->_structure[$id][$direction])) { - $all_adjacent[] = $new_id; - $id = $new_id; + + if (isset($this->_structure[$id][$direction])) { + $new_id = $this->_structure[$id][$direction]; + + if (!in_array($new_id, $all_adjacent)) { + if ($has_adjacent = isset($this->_structure[$id][$direction])) { + $all_adjacent[] = $new_id; + $id = $new_id; + } } } } while ($has_adjacent); diff --git a/classes/backends/ComicPressBackendAttachment.inc b/classes/backends/ComicPressBackendAttachment.inc index 5bed84f..e1f25f6 100644 --- a/classes/backends/ComicPressBackendAttachment.inc +++ b/classes/backends/ComicPressBackendAttachment.inc @@ -18,8 +18,10 @@ class ComicPressBackendAttachment extends ComicPressBackend { if (!empty($children)) { foreach ($children as $child) { $meta = get_post_meta($child->ID, 'comicpress', true); - if ($meta['managed']) { - $result[] = new ComicPressBackendAttachment($child); + if (isset($meta['managed'])) { + if ($meta['managed']) { + $result[] = new ComicPressBackendAttachment($child); + } } } } diff --git a/phpunit.xml b/phpunit.xml index 11fbdd5..97e1e24 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,2 +1,6 @@ - \ No newline at end of file + + + + + \ No newline at end of file