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
Conversation
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.
src/Mutation/PostObjectCreate.php
Outdated
* | ||
* 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']) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
Ah, maybe the inline github editor os t best after all due to copy paste.
Ill fix it up and resub monday.
…On Fri, May 10, 2019 at 5:57 PM Jason Bahl ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/Mutation/PostObjectCreate.php
<#838 (comment)>:
> @@ -211,8 +212,16 @@ public static function mutate_and_get_payload( $post_type_object, $mutation_name
/**
* 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 ) ) {
+ *
+ *
+ * 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'])
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
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#838 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKXFTEZQNMKEGFIDVRVEZK3PUXVS3ANCNFSM4HJYMBWA>
.
|
There was a problem hiding this 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']); |
There was a problem hiding this comment.
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']; |
There was a problem hiding this comment.
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'])) { |
There was a problem hiding this comment.
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 ) ) { |
There was a problem hiding this comment.
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:
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 ) | |
) { |
need to re add it from my actual IDE. I've actually already refactored a lot as you've mentioned. |
@CodeProKid is alive! |
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.
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: …