WordPress.org

Make WordPress Core

Ticket #53635: 53635-08-null-to-non-nullable-in-testcode.patch

File 53635-08-null-to-non-nullable-in-testcode.patch, 1.4 KB (added by jrf, 5 months ago)

PHP 8.1 | Tests: fix bug in Tests_Admin_IncludesPlugin::test_get_plugin_files_folder() The Tests_Admin_IncludesPlugin::_create_plugin() expects the first parameter to be a text string to be written to a plugin file using fwrite(). Passing null causes a fwrite(): Passing null to parameter #2 ($data) of type string is deprecated notice. Ref: https://www.php.net/manual/en/function.fwrite

  • tests/phpunit/tests/admin/includesPlugin.php

    From 872ee114d5297050cb348dc3ae35e3d36401ba8c Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Fri, 27 Aug 2021 23:53:36 +0200
    Subject: [PATCH] PHP 8.1 | Tests: fix bug in
     Tests_Admin_IncludesPlugin::test_get_plugin_files_folder()
    
     The `Tests_Admin_IncludesPlugin::_create_plugin()` expects the first parameter to be a text string to be written to a plugin file using `fwrite()`.
    
    Passing null causes a `fwrite(): Passing null to parameter #2 ($data) of type string is deprecated` notice.
    
    Ref: https://www.php.net/manual/en/function.fwrite
    ---
     tests/phpunit/tests/admin/includesPlugin.php | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/tests/phpunit/tests/admin/includesPlugin.php b/tests/phpunit/tests/admin/includesPlugin.php
    index 6ba4cb33e0..7542db6b59 100644
    a b class Tests_Admin_IncludesPlugin extends WP_UnitTestCase { 
    366366        public function test_get_plugin_files_folder() {
    367367                $plugin_dir = WP_PLUGIN_DIR . '/list_files_test_plugin';
    368368                @mkdir( $plugin_dir );
    369                 $plugin = $this->_create_plugin( null, 'list_files_test_plugin.php', $plugin_dir );
     369                $plugin = $this->_create_plugin( '', 'list_files_test_plugin.php', $plugin_dir );
    370370
    371371                $sub_dir = trailingslashit( dirname( $plugin[1] ) ) . 'subdir';
    372372                mkdir( $sub_dir );