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

Fix/1222 log post author change #1549

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

tharsheblows
Copy link
Contributor

@tharsheblows tharsheblows commented Aug 8, 2024

Fixes #1222

This changes the hook used for watching for post updates to post_updated and uses set_object_terms to watch for term changes. The idea is that everything which triggered or should have triggered a log previously still triggers a log but with more information.

The strings in the summary are built separately and then the data itself is stored in an associative array in the meta table. (nb: this should be a JSON object for cross language portability I think)

Currently tests are failing as I'm not convinced this is completely the right approach.

Checklist

  • Project documentation has been updated to reflect the changes in this pull request, if applicable.
  • I have tested the changes in the local development environment (see contributing.md).
  • I have added phpunit tests.

Release Changelog

'deleted_post',
'post_updated',
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 thought: I believe this will not log new posts creation because post_updated is only called for existing posts.

It may be a good thing because I think we don't need to log e.g. a post_title change for a new post. However, without transition_post_status callback we no longer log new posts creation. I guess we could use e.g. save_post action or bring back transition_post_status but limit its scope to only log transitions to the publish status.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@delawski $update is a check on whether or not the data has a post_id which gets set immediately in the editor but ... if someone is using wp_insert_post() directly to add a post then it won't so I need to add that in, thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@delawski I've changed this to use wp_after_insert_post -- it's noisier but because of the orders of the filters in the REST API, it's the one that works there as well as in the Quick Edit section.

I still need to test and add automated tests though!

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.

Change of post author is not recorded
2 participants