Skip to content

Feat/user object mutation id inputs#2337

Merged
jasonbahl merged 10 commits intowp-graphql:developfrom
justlevine:feat/user-object-mutation-id-inputs
May 16, 2022
Merged

Feat/user object mutation id inputs#2337
jasonbahl merged 10 commits intowp-graphql:developfrom
justlevine:feat/user-object-mutation-id-inputs

Conversation

@justlevine
Copy link
Copy Markdown
Collaborator

@justlevine justlevine commented Apr 9, 2022

What does this implement/fix? Explain your changes.

This PR enables users to supply either a database ID or a global ID to user mutation inputs of type ID. Part of #998

Does this close any currently open issues?

#2194

Any other comments?

Where has this been tested?

Operating System: Ubuntu 20.04 (wsl2 + devilbox + php8.0.15)

WordPress Version: 5.9.2

@justlevine justlevine added type: enhancement Improvements to existing functionality needs: reviewer response This needs the attention of a codeowner or maintainer component: mutations Relating to GraphQL Mutations scope: api Issues related to access functions, actions, and filters labels Apr 9, 2022
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 9, 2022

Coverage Status

Coverage increased (+0.05%) to 79.867% when pulling ae5c89e on justlevine:feat/user-object-mutation-id-inputs into bcee697 on wp-graphql:develop.

@justlevine justlevine added the status: in review Awaiting review before merging or closing label Apr 25, 2022
@justlevine justlevine force-pushed the feat/user-object-mutation-id-inputs branch from 063041d to f4351e8 Compare May 3, 2022 23:37
@justlevine justlevine mentioned this pull request May 16, 2022
jasonbahl
jasonbahl previously approved these changes May 16, 2022
jasonbahl
jasonbahl previously approved these changes May 16, 2022
@justlevine
Copy link
Copy Markdown
Collaborator Author

justlevine commented May 16, 2022

  1. It seems all the tests are triggering positive for is_multisite().
  2. wpmu_delete_user doesnt support reassigning, which is why the test fails on multisite. I think we can use remove_user_from_blog() to keep feature parity.

It's 1:00AM and im not by my pc, but if you dont figure it out before I come back online, i'll dig deeper and tackle the fix then 💤

@jasonbahl
Copy link
Copy Markdown
Collaborator

jasonbahl commented May 16, 2022

@justlevine so you can change your env variable to make multisite tests run or not

MULTISTE=0 means the tests will run in non-multisite
MULTISITE=1 means they will run in multisite

I tend to run tests locally outside of docker (faster for me) so I can run them like so: MULTISITE=true vendor/bin/codecept run wpunit or MULTISITE=false vendor/bin/codecept run wpunit

From what I can tell, they're running as expected.

@justlevine
Copy link
Copy Markdown
Collaborator Author

From what I can tell, they're running as expected.

I'm not by my computer, but that's the only reason I can think that the reassign test is failing now with a bad reassign, on all the tests (and not just 5.9 MU). Can be confirmed if you a put a codecept_debug in the is_multisite() conditional in that test. Not sure why that would be, though

…from_blog()` prior to calling `wpmu_delete_user()`
Copy link
Copy Markdown
Collaborator Author

@justlevine justlevine left a comment

Choose a reason for hiding this comment

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

Should this be in the is_multisite() check, or am I guilty of premature optimization?

if ( ! function_exists( 'wpmu_delete_user' ) ) {
require_once ABSPATH . 'wp-admin/includes/ms.php';
}
if ( ! function_exists( 'remove_user_from_blog' ) ) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Should this be in the is_multisite() check, or am I guilty of premature optimization?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nope, I was moving this already! The test actually didn't like it outside the is_multisite() call! So good suggestion 😄

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

just pushed this change 😄

@jasonbahl
Copy link
Copy Markdown
Collaborator

@justlevine I mistyped. instead of MULTISITE=false vendor/bin/codecept run wpunit it needs to be MULTISITE=0 vendor/bin/codecept run wpunit

I can verify now by placing this inside the mutate_and_get_payload function in the UserDelete.php file and running the test command.

MULTISITE=0 vendor/bin/codecept run tests/wpunit/UserObjectMutationsTest.php:testDeleteUserWithReassign --debug

CleanShot 2022-05-16 at 16 56 23

MULTISITE=1 vendor/bin/codecept run tests/wpunit/UserObjectMutationsTest.php:testDeleteUserWithReassign --debug

CleanShot 2022-05-16 at 16 57 16

@qlty-cloud-legacy
Copy link
Copy Markdown

Code Climate has analyzed commit ae5c89e and detected 1 issue on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1

View more on Code Climate.

@jasonbahl jasonbahl merged commit 2054b01 into wp-graphql:develop May 16, 2022
@justlevine justlevine deleted the feat/user-object-mutation-id-inputs branch May 16, 2022 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: mutations Relating to GraphQL Mutations needs: reviewer response This needs the attention of a codeowner or maintainer scope: api Issues related to access functions, actions, and filters status: in review Awaiting review before merging or closing type: enhancement Improvements to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants