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

modified_date/time filters should not use global post #1336

Closed
herrvigg opened this issue May 1, 2023 · 1 comment
Closed

modified_date/time filters should not use global post #1336

herrvigg opened this issue May 1, 2023 · 1 comment
Labels
bug Something isn't working, reproducible severity: minor Minor functionality

Comments

@herrvigg
Copy link
Collaborator

herrvigg commented May 1, 2023

Spotted when fixing other date/time type issues with #1335, the global post is used with these filters:

  1. get_the_modified_date: the post is passed by the filter but it's ignored by the callback.
  2. get_post_modified_time: more problematic, the post is not given by the filter.

These filters work as long as they are used with the current post stored as global. However the two related functions can be called for a specific post other than the global one, so the filters are broken in such cases.

@herrvigg herrvigg added bug Something isn't working, reproducible severity: minor Minor functionality labels May 1, 2023
herrvigg added a commit that referenced this issue May 1, 2023
Using the global post is wrong as the user may ask for a post ID.

1) Fix `get_the_modified_date` properly using the given Post object.

2) Unfortunately `get_post_modified_time` cannot be fixed due to the
lack of Post object in the WordPress filter :(
Better to use the time given by WP instead of using a wrong post ID.
@herrvigg
Copy link
Collaborator Author

herrvigg commented May 1, 2023

Fix released in 3.15.1.

@herrvigg herrvigg closed this as completed May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working, reproducible severity: minor Minor functionality
Projects
None yet
Development

No branches or pull requests

1 participant