Build/Test Tools: Ignore "null to nullable" deprecations for select tests.

Adds an expectation for PHP 8.1 "passing null to non-nullable" deprecation notice to select tests where the deprecation is generated by one of the functions in the `wp-includes/formatting.php` file, either via a filter hook callback or by a direct call.

Instead of haphazardly fixing these issues exposed by the tests, a more structural and all-encompassing solution for input validation should be architected and implemented as otherwise, we'll keep running into similar issues time and again with each new PHP version.

To discourage people from "fixing" these issues now anyway, this commit "hides" nearly all of these issues from the test runs.

Once a more structural solution is designed, these tests and the underlying functions causing the deprecation notices should be revisited and the structural solution put in place.

Includes a few minor other tweaks to select tests:
* Removing a stray `return` (twice) from assertion statements.
* Removing calls to `ob_*()` functions in favour of letting PHPUnit manage the output catching. This prevents warnings along the lines of `Test code or tested code did not (only) close its own output buffers`.

Props jrf, hellofromTonya.
See .

git-svn-id: https://develop.svn.wordpress.org/trunk@51968 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork 2021-11-01 22:22:49 +00:00
parent 162fda69c8
commit 400982add8
14 changed files with 589 additions and 10 deletions

@ -185,6 +185,16 @@ class Tests_Admin_IncludesListTable extends WP_UnitTestCase {
* @param array $expected_ids Expected IDs of pages returned.
*/
protected function _test_list_hierarchical_page( array $args, array $expected_ids ) {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$matches = array();
$_REQUEST['paged'] = $args['paged'];
@ -205,12 +215,14 @@ class Tests_Admin_IncludesListTable extends WP_UnitTestCase {
$args['posts_per_archive_page'] = -1;
}
// Effectively ignore the output until retrieving it later via `getActualOutput()`.
$this->expectOutputRegex( '`.`' );
$pages = new WP_Query( $args );
ob_start();
$this->table->set_hierarchical_display( true );
$this->table->display_rows( $pages->posts );
$output = ob_get_clean();
$output = $this->getActualOutput();
// Clean up.
unset( $_REQUEST['paged'] );

@ -876,6 +876,16 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
* @ticket 37406
*/
public function test_post_exists_should_support_post_type() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$title = 'Foo Bar';
$post_type = 'page';
$post_id = self::factory()->post->create(
@ -893,6 +903,16 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
* @ticket 37406
*/
public function test_post_exists_should_not_match_a_page_for_post() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$title = 'Foo Bar';
$post_type = 'page';
$post_id = self::factory()->post->create(
@ -910,6 +930,16 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
* @ticket 34012
*/
public function test_post_exists_should_support_post_status() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$title = 'Foo Bar';
$post_type = 'post';
$post_status = 'publish';
@ -930,6 +960,16 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
* @ticket 34012
*/
public function test_post_exists_should_support_post_type_status_combined() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$title = 'Foo Bar';
$post_type = 'post';
$post_status = 'publish';
@ -949,6 +989,16 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
* @ticket 34012
*/
public function test_post_exists_should_only_match_correct_post_status() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$title = 'Foo Bar';
$post_type = 'post';
$post_status = 'draft';
@ -968,6 +1018,16 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
* @ticket 34012
*/
public function test_post_exists_should_not_match_invalid_post_type_and_status_combined() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$title = 'Foo Bar';
$post_type = 'post';
$post_status = 'publish';

@ -200,6 +200,15 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
}
public function test_submitting_comment_to_password_protected_post_succeeds() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$password = 'password';
$hasher = new PasswordHash( 8, true );
@ -282,6 +291,15 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
* @group slashes
*/
public function test_submitting_comment_handles_slashes_correctly_handles_slashes() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$data = array(
'comment_post_ID' => self::$post->ID,
@ -429,6 +447,15 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
}
public function test_anonymous_user_cannot_comment_unfiltered_html() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$data = array(
'comment_post_ID' => self::$post->ID,
@ -719,6 +746,16 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
* @ticket 49236
*/
public function test_submitting_comment_with_empty_type_results_in_correct_type() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$data = array(
'comment_post_ID' => self::$post->ID,
'comment' => 'Comment',
@ -802,6 +839,16 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
* @ticket 36901
*/
public function test_submitting_duplicate_comments() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$data = array(
'comment_post_ID' => self::$post->ID,
'comment' => 'Did I say that?',
@ -818,6 +865,16 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
* @ticket 36901
*/
public function test_comments_flood() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$data = array(
'comment_post_ID' => self::$post->ID,
'comment' => 'Did I say that?',

@ -14,6 +14,16 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
* @covers wp_xmlrpc_server::mw_newPost
*/
public function test_date_new_post() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$timezone = 'Europe/Kiev';
update_option( 'timezone_string', $timezone );

@ -721,6 +721,16 @@ JS;
$wp_scripts->base_url = '';
$wp_scripts->do_concat = true;
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$ver = get_bloginfo( 'version' );
$suffix = wp_scripts_get_suffix();
$expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5Bchunk_0%5D=jquery-core,jquery-migrate,regenerator-runtime,wp-polyfill,wp-dom-ready,wp-hooks&amp;ver={$ver}'></script>\n";
@ -746,8 +756,12 @@ JS;
wp_enqueue_script( 'test-example2', 'http://example2.com', array( 'wp-a11y' ), null );
wp_add_inline_script( 'test-example2', 'console.log("after");', 'after' );
$print_scripts = get_echo( 'wp_print_scripts' );
$print_scripts .= get_echo( '_print_scripts' );
// Effectively ignore the output until retrieving it later via `getActualOutput()`.
$this->expectOutputRegex( '`.`' );
wp_print_scripts();
_print_scripts();
$print_scripts = $this->getActualOutput();
/*
* We've replaced wp-a11y.js with @wordpress/a11y package (see #45066),
@ -776,6 +790,16 @@ JS;
$wp_scripts->base_url = '';
$wp_scripts->do_concat = true;
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$expected_tail = "<script type='text/javascript' src='/customize-dependency.js' id='customize-dependency-js'></script>\n";
$expected_tail .= "<script type='text/javascript' id='customize-dependency-js-after'>\n";
$expected_tail .= "tryCustomizeDependency()\n";
@ -785,8 +809,12 @@ JS;
wp_enqueue_script( $handle, '/customize-dependency.js', array( 'customize-controls' ), null );
wp_add_inline_script( $handle, 'tryCustomizeDependency()' );
$print_scripts = get_echo( 'wp_print_scripts' );
$print_scripts .= get_echo( '_print_scripts' );
// Effectively ignore the output until retrieving it later via `getActualOutput()`.
$this->expectOutputRegex( '`.`' );
wp_print_scripts();
_print_scripts();
$print_scripts = $this->getActualOutput();
$tail = substr( $print_scripts, strrpos( $print_scripts, "<script type='text/javascript' src='/customize-dependency.js' id='customize-dependency-js'>" ) );
$this->assertSame( $expected_tail, $tail );

@ -9,6 +9,16 @@ class Tests_Formatting_wpRelNofollow extends WP_UnitTestCase {
* @ticket 9959
*/
public function test_add_no_follow() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$content = '<p>This is some cool <a href="/">Code</a></p>';
$expected = '<p>This is some cool <a href=\"/\" rel=\"nofollow\">Code</a></p>';
$this->assertSame( $expected, wp_rel_nofollow( $content ) );
@ -18,6 +28,16 @@ class Tests_Formatting_wpRelNofollow extends WP_UnitTestCase {
* @ticket 9959
*/
public function test_convert_no_follow() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$content = '<p>This is some cool <a href="/" rel="weird">Code</a></p>';
$expected = '<p>This is some cool <a href=\"/\" rel=\"weird nofollow\">Code</a></p>';
$this->assertSame( $expected, wp_rel_nofollow( $content ) );
@ -27,8 +47,18 @@ class Tests_Formatting_wpRelNofollow extends WP_UnitTestCase {
* @ticket 11360
* @dataProvider data_wp_rel_nofollow
*/
public function test_wp_rel_nofollow( $input, $output ) {
return $this->assertSame( wp_slash( $output ), wp_rel_nofollow( $input ) );
public function test_wp_rel_nofollow( $input, $output, $expect_deprecation = false ) {
if ( true === $expect_deprecation && PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->assertSame( wp_slash( $output ), wp_rel_nofollow( $input ) );
}
public function data_wp_rel_nofollow() {
@ -39,6 +69,7 @@ class Tests_Formatting_wpRelNofollow extends WP_UnitTestCase {
array(
'<a href="">Double Quotes</a>',
'<a href="" rel="nofollow">Double Quotes</a>',
true,
),
array(
'<a href="https://wordpress.org">Double Quotes</a>',
@ -76,6 +107,16 @@ class Tests_Formatting_wpRelNofollow extends WP_UnitTestCase {
}
public function test_append_no_follow_with_valueless_attribute() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$content = '<p>This is some cool <a href="demo.com" download rel="hola">Code</a></p>';
$expected = '<p>This is some cool <a href=\"demo.com\" download rel=\"hola nofollow\">Code</a></p>';
$this->assertSame( $expected, wp_rel_nofollow( $content ) );

@ -9,6 +9,16 @@ class Tests_Formatting_wpRelUgc extends WP_UnitTestCase {
* @ticket 48022
*/
public function test_add_ugc() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$content = '<p>This is some cool <a href="/">Code</a></p>';
$expected = '<p>This is some cool <a href=\"/\" rel=\"nofollow ugc\">Code</a></p>';
$this->assertSame( $expected, wp_rel_ugc( $content ) );
@ -18,6 +28,16 @@ class Tests_Formatting_wpRelUgc extends WP_UnitTestCase {
* @ticket 48022
*/
public function test_convert_ugc() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$content = '<p>This is some cool <a href="/" rel="weird">Code</a></p>';
$expected = '<p>This is some cool <a href=\"/\" rel=\"weird nofollow ugc\">Code</a></p>';
$this->assertSame( $expected, wp_rel_ugc( $content ) );
@ -27,8 +47,18 @@ class Tests_Formatting_wpRelUgc extends WP_UnitTestCase {
* @ticket 48022
* @dataProvider data_wp_rel_ugc
*/
public function test_wp_rel_ugc( $input, $output ) {
return $this->assertSame( wp_slash( $output ), wp_rel_ugc( $input ) );
public function test_wp_rel_ugc( $input, $output, $expect_deprecation = false ) {
if ( true === $expect_deprecation && PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->assertSame( wp_slash( $output ), wp_rel_ugc( $input ) );
}
public function data_wp_rel_ugc() {
@ -39,6 +69,7 @@ class Tests_Formatting_wpRelUgc extends WP_UnitTestCase {
array(
'<a href="">Double Quotes</a>',
'<a href="" rel="nofollow ugc">Double Quotes</a>',
true,
),
array(
'<a href="https://wordpress.org">Double Quotes</a>',
@ -76,6 +107,16 @@ class Tests_Formatting_wpRelUgc extends WP_UnitTestCase {
}
public function test_append_ugc_with_valueless_attribute() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$content = '<p>This is some cool <a href="demo.com" download rel="hola">Code</a></p>';
$expected = '<p>This is some cool <a href=\"demo.com\" download rel=\"hola nofollow ugc\">Code</a></p>';
$this->assertSame( $expected, wp_rel_ugc( $content ) );

@ -71,6 +71,16 @@ class Tests_Formatting_wpTrimExcerpt extends WP_UnitTestCase {
* @ticket 51042
*/
public function test_should_generate_excerpt_for_empty_values() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$post = self::factory()->post->create(
array(
'post_content' => 'Post content',

@ -263,6 +263,16 @@ class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase {
* @ticket 5172
*/
public function test_should_include_tag_link_position_class() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
register_taxonomy( 'wptests_tax', 'post' );
$term_ids = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );

@ -301,6 +301,16 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase {
* @ticket 35874
*/
function test_draft_not_prematurely_published() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$editor_id = $this->make_user_by_role( 'editor' );
$post = array(

@ -22,6 +22,16 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_no_content() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'author' );
$post = array();
@ -32,6 +42,16 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_basic_content() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'author' );
$post = array( 'title' => 'Test' );
@ -41,6 +61,16 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_ignore_id() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'author' );
$post = array(
@ -53,6 +83,16 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_capable_publish() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'author' );
$post = array(
@ -76,6 +116,16 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_capable_other_author() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'editor' );
$other_author_id = $this->make_user_by_role( 'author' );
@ -116,6 +166,16 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_empty_author() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$my_author_id = $this->make_user_by_role( 'author' );
$post = array( 'title' => 'Test' );
@ -164,6 +224,16 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_capable_set_post_type_as_page() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'editor' );
$post = array(
@ -184,6 +254,16 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase {
* @ticket 16985
*/
function test_draft_post_date() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'editor' );
$post = array(

@ -468,6 +468,16 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
* @ticket 35874
*/
function test_draft_not_prematurely_published() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$editor_id = $this->make_user_by_role( 'editor' );
/**
@ -504,6 +514,16 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
* @ticket 45322
*/
function test_draft_not_assigned_published_date() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$editor_id = $this->make_user_by_role( 'editor' );
// Start with a draft post, confirming its post_date_gmt is "zero".

@ -60,6 +60,16 @@ class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase {
* @ticket 22687
*/
function test_revision_count_for_auto_draft_post_creation() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'editor' );
$post_id = $this->myxmlrpcserver->wp_newPost(

@ -20,6 +20,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_no_content() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'author' );
$result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', array() ) );
@ -29,6 +39,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_basic_content() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'author' );
$post = array( 'post_title' => 'Test' );
@ -38,6 +58,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_ignore_id() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'author' );
$post = array(
@ -50,6 +80,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_capable_publish() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'author' );
$post = array(
@ -73,6 +113,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_capable_private() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'editor' );
$post = array(
@ -96,6 +146,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_capable_other_author() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$other_author_id = $this->make_user_by_role( 'author' );
$this->make_user_by_role( 'editor' );
@ -133,6 +193,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_empty_author() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$my_author_id = $this->make_user_by_role( 'author' );
$post = array( 'post_title' => 'Test' );
@ -169,6 +239,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_invalid_post_status() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'author' );
$post = array(
@ -193,6 +273,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_capable_sticky() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'editor' );
$post = array(
@ -218,6 +308,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_post_format() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'editor' );
$post = array(
@ -230,6 +330,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_invalid_post_format() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'editor' );
$post = array(
@ -280,6 +390,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_terms() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'editor' );
$tag1 = wp_create_tag( 'tag1' );
@ -305,6 +425,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
}
function test_terms_names() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'editor' );
$ambiguous_name = 'foo';
@ -348,6 +478,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
* @ticket 28601
*/
function test_invalid_post_date_does_not_fatal() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'author' );
$date_string = 'invalid_date';
$post = array(
@ -365,6 +505,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
* @ticket 28601
*/
function test_invalid_post_date_gmt_does_not_fatal() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'author' );
$date_string = 'invalid_date';
$post = array(
@ -382,6 +532,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
* @ticket 28601
*/
function test_valid_string_post_date() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'author' );
$date_string = '1984-01-11 05:00:00';
$post = array(
@ -399,6 +559,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
* @ticket 28601
*/
function test_valid_string_post_date_gmt() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'author' );
$date_string = '1984-01-11 05:00:00';
$post = array(
@ -416,6 +586,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
* @ticket 28601
*/
function test_valid_IXR_post_date() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'author' );
$date_string = '1984-01-11 05:00:00';
$post = array(
@ -433,6 +613,16 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
* @ticket 28601
*/
function test_valid_IXR_post_date_gmt() {
if ( PHP_VERSION_ID >= 80100 ) {
/*
* For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
* via hooked in filter functions until a more structural solution to the
* "missing input validation" conundrum has been architected and implemented.
*/
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$this->make_user_by_role( 'author' );
$date_string = '1984-01-11 05:00:00';
$post = array(