Skip to content

Commit 70f556e

Browse files
committed
Add additional debug information when failing to copy story
1 parent 47e355f commit 70f556e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

shorthand_connect/includes/api.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,17 @@ function sh_copy_story($post_id, $story_id) {
118118
$unzipfile = unzip_file( $zipfile, $destination_path);
119119
if ( $unzipfile ) {
120120
$story['path'] = $destination_path;
121+
} else {
122+
$story['error'] = array(
123+
'pretty' => 'Could not unzip file'
124+
);
121125
}
126+
} else {
127+
$story['error'] = array(
128+
'pretty' => 'Could not upload file',
129+
'error' => curl_error($ch),
130+
'response' => $response
131+
);
122132
}
123133
}
124134
return $story;

shorthand_connect/shorthand_connect.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,12 @@ function save_shorthand_story( $post_id, $post, $update ) {
211211

212212
if (isset($_REQUEST['story_id'])) {
213213
update_post_meta( $post_id, 'story_id', sanitize_text_field( $_REQUEST['story_id'] ) );
214-
sh_copy_story($post_id, $_REQUEST['story_id']);
214+
$err = sh_copy_story($post_id, $_REQUEST['story_id']);
215215
$story_path = sh_get_story_path($post_id, $_REQUEST['story_id']);
216216

217217
//Sometimes the story needs to be gotten twice
218218
if(!isset($story_path)) {
219-
sh_copy_story($post_id, $_REQUEST['story_id']);
219+
$err = sh_copy_story($post_id, $_REQUEST['story_id']);
220220
$story_path = sh_get_story_path($post_id, $_REQUEST['story_id']);
221221
}
222222

@@ -245,6 +245,7 @@ function save_shorthand_story( $post_id, $post, $update ) {
245245
add_action( 'save_post', 'save_shorthand_story', 10, 3);
246246
} else {
247247
echo 'Something went wrong, please try again';
248+
print_r($err);
248249
die();
249250
}
250251
}

0 commit comments

Comments
 (0)