Skip to content

Don't cast wp_error object to int on failure#471

Closed
superbuggy wants to merge 1 commit into10up:developfrom
superbuggy:master
Closed

Don't cast wp_error object to int on failure#471
superbuggy wants to merge 1 commit into10up:developfrom
superbuggy:master

Conversation

@superbuggy
Copy link
Copy Markdown

Description of the Change

Avoid casting an error into an int (1) and labeling it as a post_id.

Alternate Designs

n/a

Benefits

Clear information about the failure rather than an arbitrary value coercion.

Possible Drawbacks

None come to mind.

Verification Process

Test failing push.

Checklist:

  • [ x ] I have read the CONTRIBUTING document.
  • [ x ] My code follows the code style of this project.
  • [ x ] My change requires a change to the documentation.
  • [ x ] I have updated the documentation accordingly.
  • [ x ] I have added tests to cover my change.
  • [ x ] All new and existing tests passed.

@adamsilverstein
Copy link
Copy Markdown

Hi @superbuggy! Thanks for opening this PR. I can see how the int cast could cause buggy behavior.

As @helen pointed out elsewhere, this feels like part of a larger issue we have with the plugin we plan to address in an upcoming release: that a lot of failures have little to no messaging about them.

Can you describe the issue you are trying to resolve with this change or the bug you experienced? If you have time, can you please create an Issue (https://github.com/10up/distributor/issues/new/choose) describing the bug you are seeing, then we can discuss a plan to resolve there.

Comment on lines +554 to +555
$post_id = intval( $_POST['postId'] );
$remote_id = $external_connection->push( $post_id, $push_args ); No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

were these lines left by accident?

} else {
$external_push_results[ (int) $connection['id'] ] = array(
'post_id' => (int) $remote_id,
'post_id' => $post_id,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add an error attribute here with the (error) results from $external_connection->push? That will set us up for displaying the error on the front end.

@jeffpaul jeffpaul added type:bug Something isn't working. needs:feedback This requires reporter feedback to better understand the request. labels Dec 18, 2019
@jeffpaul jeffpaul added this to the Future Release milestone Dec 18, 2019
@dkotter
Copy link
Copy Markdown
Collaborator

dkotter commented Jan 27, 2020

@superbuggy Thanks for this PR. Wondering if you've had a chance to review the feedback @adamsilverstein left here or if you're looking for more direction on this PR? Thanks!

@jeffpaul
Copy link
Copy Markdown
Member

@superbuggy are you able to respond to the feedback on this PR?

@jeffpaul jeffpaul changed the base branch from master to develop June 30, 2020 02:19
@jeffpaul jeffpaul modified the milestones: Future Release, 1.7.0 Jan 15, 2021
@jeffpaul jeffpaul requested a review from dinhtungdu April 27, 2021 20:27
@dinhtungdu
Copy link
Copy Markdown
Contributor

Hi @superbuggy, in #630 we update the error reporting system, so I'm closing this PR.

Thanks again for your contribution! If you have any questions or updates, feel free to comment/open this PR again.

@dinhtungdu dinhtungdu closed this May 5, 2021
@jeffpaul jeffpaul removed this from the 1.7.0 milestone Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:feedback This requires reporter feedback to better understand the request. type:bug Something isn't working.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants