From cd9c75d26d2997f57ef04ac5885b6070f5c7f5fa Mon Sep 17 00:00:00 2001 From: prcdevgitbot Date: Wed, 9 Oct 2024 21:29:15 +0000 Subject: [PATCH] See https://github.com/pewresearch/prc-platform/commit/fe396b17cd7839d852eb0e9c85aa5776e6b7377e from refs/tags/v1.0.18-beta --- .../post-publish-pipeline/class-post-publish-pipeline.php | 8 ++++---- .../post-report-package/class-post-report-package.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/includes/post-publish-pipeline/class-post-publish-pipeline.php b/includes/post-publish-pipeline/class-post-publish-pipeline.php index 86c80df..30481f1 100644 --- a/includes/post-publish-pipeline/class-post-publish-pipeline.php +++ b/includes/post-publish-pipeline/class-post-publish-pipeline.php @@ -79,7 +79,7 @@ public function init($loader = null) { /** * @uses prc_platform_on_incremental_save */ - $loader->add_action( 'save_post', $this, 'post_incremental_save_hook', 10, 3 ); + $loader->add_action( 'save_post', $this, 'restful_post_incremental_save_hook', 10, 3 ); /** * @uses prc_platform_on_post_init */ @@ -314,7 +314,7 @@ public function apply_extra_wp_post_object_fields( $ref_post ) { * @param mixed $update * @return void */ - public function post_incremental_save_hook( $post_id, $post, $update ) { + public function restful_post_incremental_save_hook( $post_id, $post, $update ) { if ( true === $this->is_cli ) { return; } @@ -322,7 +322,7 @@ public function post_incremental_save_hook( $post_id, $post, $update ) { return; } // This will make sure this doesnt run twice on Gutenberg editor. - if ( defined( 'REST_REQUEST' ) && true === REST_REQUEST ) { + if ( !defined( 'REST_REQUEST' ) || true !== REST_REQUEST ) { return; } if ( ! in_array( $post->post_status, array( 'draft', 'publish' ) ) ) { @@ -340,7 +340,7 @@ public function post_incremental_save_hook( $post_id, $post, $update ) { if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) { return; } - if ( doing_action( 'prc_platform_on_incremental_save' ) ) { + if ( doing_action( 'prc_platform_on_incremental_save' ) || doing_action( 'prc_platform_on_rest_publish' ) || doing_action( 'prc_platform_on_rest_update' )) { return; } diff --git a/includes/post-report-package/class-post-report-package.php b/includes/post-report-package/class-post-report-package.php index 5381302..0405c2d 100644 --- a/includes/post-report-package/class-post-report-package.php +++ b/includes/post-report-package/class-post-report-package.php @@ -332,12 +332,12 @@ public function update_children( $post ) { } if ( is_wp_error( $child_updated ) ) { - $errors[] = new WP_Error( '409', 'Failed to update child post state.', $child_updated ); + $errors[] = new WP_Error( 'post-report-package::failed-to-update-child-post-state', 'Failed to update child post state.', $child_updated ); } else { $success[] = $child_updated; } if ( is_wp_error( $terms_updated ) ) { - $errors[] = new WP_Error( '409', 'Failed to update child post terms.', $terms_updated ); + $errors[] = new WP_Error( 'post-report-package::failed-to-update-child-post-terms', 'Failed to update child post terms.', $terms_updated ); } } @@ -355,7 +355,7 @@ public function assign_child_to_parent($child_post_id, $parent_post_id) { 'post_parent' => $parent_post_id, ), true ); if ( is_wp_error( $updated ) ) { - return new WP_Error( '412', 'Failed to assign child post to parent.', $updated ); + return new WP_Error( 'post-report-package::failed-to-assign-child', 'Failed to assign child post to parent.', $updated ); } return $updated; } @@ -900,7 +900,7 @@ public function register_rest_endpoint($endpoints) { public function restfully_regenerate_toc(\WP_REST_Request $request) { $post_id = $request->get_param('post_id'); if ( empty($post_id) ) { - return new WP_Error('400', 'Missing post_id parameter.'); + return new WP_Error('post-report-package::missing-post-id', 'Missing post_id parameter.'); } return $this->construct_toc( $post_id ); }