[wp-trac] [WordPress Trac] #22957: get_boundary_post Only works from a single page
WordPress Trac
noreply at wordpress.org
Sat Jun 21 23:39:41 UTC 2025
#22957: get_boundary_post Only works from a single page
-------------------------------------+-----------------------
Reporter: pathawks | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone:
Component: Posts, Post Types | Version: 2.8
Severity: normal | Resolution:
Keywords: has-patch has-test-info | Focuses: template
-------------------------------------+-----------------------
Changes (by SirLouen):
* keywords: has-patch needs-testing => has-patch has-test-info
Comment:
== Test Report
=== Description
✅ This report validates that the indicated patch works as expected.
Patch tested: https://github.com/WordPress/wordpress-
develop/pull/9040.diff
=== Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.28
- Server: nginx/1.27.5
- Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
- Browser: Chrome 137.0.0.0
- OS: Windows 10/11
- Theme: Twenty Twenty-Five 1.2
- MU Plugins: None activated
- Plugins:
* Boundary Tester 1.0.0
* Test Reports 1.2.0
=== Testing Instructions
1. I'm providing, in the Artifacts, the code to test. Use this in a
plugin, theme's functions.php, or wherever you can execute code
2. Add a couple of posts
3. Go to the Home page, check the footer
4. 🐞 Null result
[[Image(https://i.imgur.com/XZCBrrL.png)]]
=== Expected Results
1. First and last post should be shown in the homepage.
=== Actual Results
1. ✅ Issue resolved with patch.
=== Additional Notes
- I have refreshed the patch for testing, not updating the deprecated
function.
- Some Unit Test for `get_boundary_post` could be useful in
`tests/phpunit/tests/link/getAdjacentPost.php` testing for the cases
commented in this report (homepage)
By removing this:
{{{
! $post || ! is_single() || is_attachment()
}}}
I wondered if there could be a location, where it should not be displayed,
that could cause a regression. As @SergeyBiryukov has pointed out, this
was born like this in [10815] with not many explanations from #8703. So
basically can say that this has been historically a bug.
=== Supplemental Artifacts
Code for testing
{{{#!php
add_action('wp_footer', 'test_boundary_posts');
function test_boundary_posts() {
$first_post_array = get_boundary_post(true, '', true);
$last_post_array = get_boundary_post(true, '', false);
echo '<div style="padding: 20px;">';
echo '<h3>Boundary Post Test</h3>';
if ( ! empty($first_post_array)) {
$first_post = $first_post_array[0];
echo '<p>First Post:' . $first_post->post_title . '</p>';
} else {
echo '<p>First post not found (NULL or empty result
returned).</p>';
}
if ( ! empty($last_post_array)) {
$last_post = $last_post_array[0];
echo '<p>Last Post:' . $last_post->post_title . '</p>';
} else {
echo '<p>Last post not found (NULL or empty result
returned).</p>';
}
echo '</div>';
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/22957#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list