#54736 closed defect (bug) (fixed)
get_sample_permalink unsets $post->filter even though this is a public property.
Reported by: | herregroen | Owned by: | hellofromTonya |
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | 2.7.1 |
Component: | Posts, Post Types | Keywords: | has-patch needs-unit-tests |
Focuses: | Cc: |
Description
The property should be set to null
rather than being unset
.
Unsetting it removes it entirely which means if it's later requested ( such as in WP_Post::__get
) this causes a notice to be thrown that the property doesn't exist.
Attachments (2)
Change History (15)
#2
@
3 years ago
- Component changed from General to Posts, Post Types
- Keywords has-patch needs-unit-tests added
- Milestone changed from Awaiting Review to 6.0
- Version changed from trunk to 2.7.1
Hello @herregroen,
Welcome back to WordPress Core's Trac! Thanks for opening this ticket :)
The unset( $post->filter )
was introduced in #8526 [10213].
Here's an example in action https://3v4l.org/66Nvl.
- In < PHP 8, it throws a
Notice: Undefined property: WP_Post::$filter
. - In PHP 8, it throws a
Warning: Undefined property: WP_Post::$filter
.
Moving this ticket into 6.0.
This ticket was mentioned in Slack in #core-test by hellofromtonya. View the logs.
3 years ago
#5
@
3 years ago
- Owner set to hellofromTonya
- Status changed from new to assigned
Assigning to me for review and unit tests.
This ticket was mentioned in PR #2626 on WordPress/wordpress-develop by peterwilsoncc.
2 years ago
#6
#7
@
2 years ago
I've created an initial patch in the linked pull request:
- The original
filter
value is stored early in the function - This value is then restored after been replaced with
sample
In [53042] it was ensured that the filter was always set in post objects, this is why I am restoring it rather than null
ing it.
No tests at present but feel free to push them to the branch on my repo.
#8
@
2 years ago
Hello @peterwilsoncc & @hellofromTonya can I start writing PHPUnit test for the changes made on this PR(https://github.com/WordPress/wordpress-develop/pull/2626).
#9
@
2 years ago
- Milestone changed from 6.0 to 6.1
With 6.0 RC1 tomorrow and this issue not introduced in the 6.0 cycle, moving this ticket and ongoing work to 6.1.
#10
@
2 years ago
@niravsherasiya7707: Absolutely! As Peter mentioned, you could submit unit tests through a PR to Peter's branch, or fork PR 2626 directly and add the tests to your own branch.
Props will pick up Peter's original PR, but if you end up forking the original, it's always nice to mention where it started 🙌🏻
#11
@
2 years ago
@peterwilsoncc I've created a PR adding tests: https://github.com/peterwilsoncc/wordpress-develop/pull/9
Other than that, it's necessary to fix a typo
Added an alternative patch which restores the original filter.