wordpress-develop/tests/phpunit/tests/link
Tonya Mork f0a1369441 Code Modernization: Fix "passing null to non-nullable" deprecation from next_posts().
The `esc_url()` function expects to a string for `$url` parameter. There is no input validation within that function. The function contains a `ltrim()` which also expects a string. Passing `null` to this parameter results in `Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated` notice on PHP 8.1+.

Tracing the stack back, a `null` is being passed to it within `next_posts()` when `get_next_posts_page_link()` returns `null` (it can return a string or `null`).

On PHP 7.0 to PHP 8.x, an empty string is returned from `esc_url()` when `null` is passed to it. The change in this changeset avoids the deprecation notice by not invoking `esc_url()` when `get_next_posts_page_link()` returns `null` and instead sets the `$output` to an empty string, thus maintain the same behavior as before (minus the deprecation notice).

Adds a test to validate an empty string is returned and the absence of the deprecation (when running on PHP 8.1+).

Follow-up to [11383], [9632].

Props codersantosh, nihar007, hellofromTonya, mukesh27, oglekler, rajinsharwar.
Fixes #59154.

git-svn-id: https://develop.svn.wordpress.org/trunk@56740 602fd350-edb4-49c9-b593-d223f7449a82
2023-09-28 21:24:35 +00:00
..
editTermLink.php Coding Standards: Include one space after function keyword for closures. 2023-09-12 15:21:02 +00:00
getAdjacentPost.php Posts, Post Types: Use persistent caching in get_adjacent_post function. 2023-01-18 11:18:36 +00:00
getAdjacentPostLink.php Build/Test Tools: Implement use of the void solution. 2021-08-07 10:29:41 +00:00
getDashboardUrl.php Tests: Add missing @covers tags for files in phpunit/tests/link/. 2021-02-28 17:09:39 +00:00
getEditPostLink.php Editor: fix post edit navigation link. 2023-06-27 06:00:59 +00:00
getEditTermLink.php Coding Standards: Include one space after function keyword for closures. 2023-09-12 15:21:02 +00:00
getFeedLink.php Feeds: Fix the URL returned by get_feed_link() when pretty permalinks are not in use. 2021-02-16 17:32:58 +00:00
getNextCommentsLink.php Coding Standards: Remove superfluous blank lines at the end of various classes. 2023-09-08 09:30:38 +00:00
getNextPostsLink.php Tests: Add unit tests for get_next_posts_link() and get_previous_posts_link(). 2023-03-01 14:43:27 +00:00
getPostCommentsFeedLink.php Feeds: Avoid notices in get_post_comments_feed_link(). 2021-06-08 22:59:19 +00:00
getPostPermalink.php Coding Standards: Remove superfluous blank lines at the end of various classes. 2023-09-08 09:30:38 +00:00
getPostTypeArchiveLink.php Tests: Use the factory method instead of the property. 2022-09-06 22:09:49 +00:00
getPreviewPostLink.php Coding Standards: Remove superfluous blank lines at the end of various classes. 2023-09-08 09:30:38 +00:00
getPreviousCommentsLink.php Coding Standards: Remove superfluous blank lines at the end of various classes. 2023-09-08 09:30:38 +00:00
getPreviousPostsLink.php Tests: Add unit tests for get_next_posts_link() and get_previous_posts_link(). 2023-03-01 14:43:27 +00:00
getThePostsNavigation.php Coding Standards: Remove superfluous blank lines at the end of various classes. 2023-09-08 09:30:38 +00:00
getThePrivacyPolicyLink.php Tests: Second pass at merging file-level and class-level DocBlocks in various unit test files. 2023-03-03 14:42:42 +00:00
nextPosts.php Code Modernization: Fix "passing null to non-nullable" deprecation from next_posts(). 2023-09-28 21:24:35 +00:00
selfAdminUrl.php Tests: Add missing @covers tags for files in phpunit/tests/link/. 2021-02-28 17:09:39 +00:00
themeFile.php Coding Standards: Remove superfluous blank lines at the end of various functions. 2023-09-08 10:01:14 +00:00
wpGetCanonicalUrl.php Permalinks: Revert the changes stemming from pagination limits. 2021-06-08 23:31:46 +00:00