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

WPGatsby Stability #74

Merged
merged 27 commits into from
Dec 15, 2020
Merged

WPGatsby Stability #74

merged 27 commits into from
Dec 15, 2020

Conversation

jasonbahl
Copy link
Contributor

This Pull Request works toward getting the plugin more stable by doing the following:

  • TESTS: This PR adds a LOT of tests for the Action Monitor.
  • Refactored Action Monitors: Instead of one file that tries to track all actions, we now have many files with their own Monitor classes dedicated to tracking specific actions of specific types of data.
  • JWT Secret Set once: Now, instead of re-generating the JWT Secret until WPGatsby settings are saved, this generates it only if it's not yet been saved once, and saves it.

This PR addresses the following issues:

# Conflicts:
#	src/ActionMonitor/ActionMonitor.php
…expensive-meta-queries

# Conflicts:
#	src/ActionMonitor/ActionMonitor.php
- add support for create, update, delete of Media, Nav Menus, Nav Menu Items, Posts (of all tracked post types), Terms (of all tracked taxonomies), Post Type/Taxonomy registry changes, and Users.
- Fixed `preview_jwt_secret` setting to save once if it doesn't yet exist.
Copy link
Contributor

@TylerBarnes TylerBarnes left a comment

Choose a reason for hiding this comment

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

Overall this is incredible and such a valuable PR! There are just a couple small things I noticed

Thing 1:

The user isn't updated when saving a post anymore. We need the user node to update so it has the correct list of child pages/posts/cpts attached to it.

On the first save of a post I saw that it tried to delete a post as a user:

Screen Shot 2020-12-09 at 4 06 07 PM

I'm not sure where "A published post" came from because I don't have a post or user called that

On further updates I don't see that anymore but I don't see the author being updated either:

Screen Shot 2020-12-09 at 4 06 47 PM

Thing 2:

The title is displayed in the terminal output so we want to adjust the action monitor titles to account for that for all the different node types:

Screen Shot 2020-12-09 at 4 18 42 PM

Ideally it'd still say "create page New page 2" instead of "create page CREATE New page 2". Same for other types. Generally the action monitor title should be the title of the thing being changed.

We could change it on the source plugin side so it shows the action monitor title instead of building a string out of the action type, name, and type, but that would be a breaking change 🤔 it's probably easier to keep the action monitor titles the same as the thing they're tracking.

For any reference fields it might be nicer to return null instead of "none" to make it more gql-like :)

Screen Shot 2020-12-09 at 4 25 58 PM

Holy crap, updating the homepage works!! 💜 🔥 🔥 that's so awesome!
And settings! 🚀 🚀 🚀

The post type stuff is amazing 😱 this is all amazing!

@TylerBarnes
Copy link
Contributor

Oo 2 more small things. 1: I think we need to merge master in here. I merged it locally but I'm not sure if I resolved the conflict properly. 2: Could you add an ## Upcoming section to the changelog.md so it'll be easier to release once we merge. Thanks!

…wer versions of phpunit have a breaking change

- update titles of actions, per code review
- update post monitor to log user action when post authors are changed
- add test for changing authors on a post, to ensure it creates actions for the post and the previous and new author
- remove unused insertNewAction function from ActionMonitor.php
…wpgatsby-stability

# Conflicts:
#	CHANGELOG.md
#	src/ActionMonitor/ActionMonitor.php
#	src/Admin/Preview.php
- run php-cs to update code style
Copy link
Contributor

@acao acao left a comment

Choose a reason for hiding this comment

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

tested these changes locally with the latest source plugin, and not only do they fix some issues with the latest release of wpgatsby, the schema seems to be resolving more quickly. great work!

- update test for re-assigning authors. This will be a breaking test now.
@TylerBarnes TylerBarnes self-requested a review December 11, 2020 23:19
Copy link
Contributor

@TylerBarnes TylerBarnes left a comment

Choose a reason for hiding this comment

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

Jason and I just spent 5 hours reviewing this whole thing 😱 and it's ready to merge and release! :D

We're waiting until Monday because we need to make a new source plugin release at the same time since this is a breaking change.

@acao
Copy link
Contributor

acao commented Dec 12, 2020

awesome work! yeah all the tests are passing with this branch against the source plugin primary branch.

- Update UserMonitor to track posts that need to be re-assigned and log the action for each post
- Update ActionMonitorTest to properly test reassigning posts after a user is deleted
- Add test for deleting menus
@TylerBarnes TylerBarnes self-requested a review December 15, 2020 01:44
Copy link
Contributor

@TylerBarnes TylerBarnes left a comment

Choose a reason for hiding this comment

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

Just a couple more changes!

src/ActionMonitor/Monitors/NavMenuMonitor.php Outdated Show resolved Hide resolved
/**
* Initialize UserMonitor Actions
*
* @return mixed|void
*/
public function init() {
public function init() {if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the formatting is a bit weird here. And where does $post_ids come from? Is that a global?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😱 this was some funky copy-pasta.

src/ActionMonitor/Monitors/UserMonitor.php Outdated Show resolved Hide resolved
… of the name "Menu" as a prefix

- Update code formatting in PostMonitor.php
- remove copy-pasta from UserMonitor.php
- Update action log for delete and re-assign to only log actions for published posts that are being re-assigned
@TylerBarnes
Copy link
Contributor

@jasonbahl is this ready?

@jasonbahl
Copy link
Contributor Author

@TylerBarnes I think so!

@TylerBarnes TylerBarnes self-requested a review December 15, 2020 19:32
@TylerBarnes
Copy link
Contributor

Looks and works great :D again, amazing work @jasonbahl , so stoked about this! I'll merge and release shortly

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.

3 participants