Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored Bug fix. failed if it was user id in string format #838

Closed
wants to merge 2 commits into from

Conversation

joseffb-mla
Copy link

Bug Fix: ID failed if it was user id in string format i.e. '120029. Need to account for Hash/Gloabl ID's as well as numeric.

Your checklist for this pull request

Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.

🚨Please review the guidelines for contributing to this repository.

  • Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
  • Make sure you are requesting to pull request from a topic/feature/bugfix branch (right side). Don't pull request from your master!

What does this implement/fix? Explain your changes.

Does this close any currently open issues?

Any relevant logs, error output, GraphiQL screenshots, etc?

(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

Any other comments?

Where has this been tested?

Operating System:

WordPress Version:

Bug Fix: ID failed if it was user id in string format i.e. '120029. Need to account for Hash/Gloabl ID's as well as numeric.
*
* Bug Fix: ID failed if it was user id in string format i.e. '120029. Need to account for Hash/Gloabl ID's as well as numeric.
*/
$authorID = absint($input['authorId'])
Copy link
Collaborator

Choose a reason for hiding this comment

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

looks like there's a syntax error in here causing all tests to fail.

I think the missing ; on line 219 is an issue for sure

Then spacing on line 220 also needs adjusted

Copy link
Collaborator

Choose a reason for hiding this comment

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

@joseffb-mla (mentioning you to make sure you get notified)

@joseffb-mla
Copy link
Author

joseffb-mla commented May 10, 2019 via email

Copy link
Member

@CodeProKid CodeProKid left a comment

Choose a reason for hiding this comment

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

Some feedback on code styling here

* If the post being created is being assigned to another user that's not the current user, make sure
* the current user has permission to edit others posts for this post_type
*/
if ( ! empty( $input['authorId'] ) && get_current_user_id() !== $input['authorId'] && ! current_user_can( $post_type_object->cap->edit_others_posts ) ) {
$authorID = absint($input['authorId']);
Copy link
Member

Choose a reason for hiding this comment

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

spacing around () needed

if ( ! empty( $input['authorId'] ) && get_current_user_id() !== $input['authorId'] && ! current_user_can( $post_type_object->cap->edit_others_posts ) ) {
$authorID = absint($input['authorId']);
if ($id_components = Relay::fromGlobalId ( $input['authorId'] ) && is_array( $id_components ) && ! empty( $id_components['id'])) {
$authorID = $id_components['id'];
Copy link
Member

Choose a reason for hiding this comment

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

Need to use tabs instead of spaces all over here.

* If the post being created is being assigned to another user that's not the current user, make sure
* the current user has permission to edit others posts for this post_type
*/
if ( ! empty( $input['authorId'] ) && get_current_user_id() !== $input['authorId'] && ! current_user_can( $post_type_object->cap->edit_others_posts ) ) {
$authorID = absint($input['authorId']);
if ($id_components = Relay::fromGlobalId ( $input['authorId'] ) && is_array( $id_components ) && ! empty( $id_components['id'])) {
Copy link
Member

Choose a reason for hiding this comment

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

some inconsistent spacing inside () here.

$authorID = $id_components['id'];
}

if ( ! empty( $authorID ) && get_current_user_id() !== $authorID && ! current_user_can( $post_type_object->cap->edit_others_posts ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

Please break up each of these checks on their own line to make this more readable. Like:

Suggested change
if ( ! empty( $authorID ) && get_current_user_id() !== $authorID && ! current_user_can( $post_type_object->cap->edit_others_posts ) ) {
if ( ! empty( $authorID ) &&
get_current_user_id() !== $authorID &&
! current_user_can( $post_type_object->cap->edit_others_posts )
) {

@joseffb-mla
Copy link
Author

need to re add it from my actual IDE. I've actually already refactored a lot as you've mentioned.

@jasonbahl
Copy link
Collaborator

@CodeProKid is alive!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants