diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index ccd52008928a2..ddcf942346917 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -72,7 +72,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-24.04 ] - php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ] + php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ] db-type: [ 'mysql' ] db-version: [ '5.7', '8.0', '8.4' ] tests-domain: [ 'example.org' ] diff --git a/src/wp-includes/class-wp-block-bindings-registry.php b/src/wp-includes/class-wp-block-bindings-registry.php index dc065356c5ce4..519453d22ba92 100644 --- a/src/wp-includes/class-wp-block-bindings-registry.php +++ b/src/wp-includes/class-wp-block-bindings-registry.php @@ -249,11 +249,11 @@ public function get_registered( string $source_name ) { * * @since 6.5.0 * - * @param string $source_name The name of the source. + * @param string|null $source_name The name of the source. * @return bool `true` if the block bindings source is registered, `false` otherwise. */ public function is_registered( $source_name ) { - return isset( $this->sources[ $source_name ] ); + return isset( $source_name, $this->sources[ $source_name ] ); } /** diff --git a/src/wp-includes/class-wp-block-pattern-categories-registry.php b/src/wp-includes/class-wp-block-pattern-categories-registry.php index 2d5fbcf2fe10f..05ddce8af0547 100644 --- a/src/wp-includes/class-wp-block-pattern-categories-registry.php +++ b/src/wp-includes/class-wp-block-pattern-categories-registry.php @@ -138,11 +138,11 @@ public function get_all_registered( $outside_init_only = false ) { * * @since 5.5.0 * - * @param string $category_name Pattern category name including namespace. + * @param string|null $category_name Pattern category name including namespace. * @return bool True if the pattern category is registered, false otherwise. */ public function is_registered( $category_name ) { - return isset( $this->registered_categories[ $category_name ] ); + return isset( $category_name, $this->registered_categories[ $category_name ] ); } /** diff --git a/src/wp-includes/class-wp-block-patterns-registry.php b/src/wp-includes/class-wp-block-patterns-registry.php index 2afa8a853f1b9..4667979fc72b5 100644 --- a/src/wp-includes/class-wp-block-patterns-registry.php +++ b/src/wp-includes/class-wp-block-patterns-registry.php @@ -238,11 +238,11 @@ public function get_all_registered( $outside_init_only = false ) { * * @since 5.5.0 * - * @param string $pattern_name Block pattern name including namespace. + * @param string|null $pattern_name Block pattern name including namespace. * @return bool True if the pattern is registered, false otherwise. */ public function is_registered( $pattern_name ) { - return isset( $this->registered_patterns[ $pattern_name ] ); + return isset( $pattern_name, $this->registered_patterns[ $pattern_name ] ); } public function __wakeup() { diff --git a/src/wp-includes/class-wp-block-styles-registry.php b/src/wp-includes/class-wp-block-styles-registry.php index 8fb5e2eb23820..60c799898580a 100644 --- a/src/wp-includes/class-wp-block-styles-registry.php +++ b/src/wp-includes/class-wp-block-styles-registry.php @@ -181,12 +181,12 @@ public function get_registered_styles_for_block( $block_name ) { * * @since 5.3.0 * - * @param string $block_name Block type name including namespace. - * @param string $block_style_name Block style name. + * @param string|null $block_name Block type name including namespace. + * @param string|null $block_style_name Block style name. * @return bool True if the block style is registered, false otherwise. */ public function is_registered( $block_name, $block_style_name ) { - return isset( $this->registered_block_styles[ $block_name ][ $block_style_name ] ); + return isset( $block_name, $block_style_name, $this->registered_block_styles[ $block_name ][ $block_style_name ] ); } /** diff --git a/src/wp-includes/class-wp-block-templates-registry.php b/src/wp-includes/class-wp-block-templates-registry.php index 1a1c259dba1dc..966eb1e65bfc7 100644 --- a/src/wp-includes/class-wp-block-templates-registry.php +++ b/src/wp-includes/class-wp-block-templates-registry.php @@ -204,11 +204,11 @@ public function get_by_query( $query = array() ) { * * @since 6.7.0 * - * @param string $template_name Template name. + * @param string|null $template_name Template name. * @return bool True if the template is registered, false otherwise. */ public function is_registered( $template_name ) { - return isset( $this->registered_templates[ $template_name ] ); + return isset( $template_name, $this->registered_templates[ $template_name ] ); } /** diff --git a/tests/phpunit/tests/block-bindings/wpBlockBindingsRegistry.php b/tests/phpunit/tests/block-bindings/wpBlockBindingsRegistry.php index 9beebaa2c3108..9ea0933a9c299 100644 --- a/tests/phpunit/tests/block-bindings/wpBlockBindingsRegistry.php +++ b/tests/phpunit/tests/block-bindings/wpBlockBindingsRegistry.php @@ -344,4 +344,16 @@ public function test_is_registered_for_known_source() { $result = $this->registry->is_registered( self::$test_source_name ); $this->assertTrue( $result ); } + + /** + * Should return false when checking registration with a null source name. + * + * @ticket 63957 + * + * @covers WP_Block_Bindings_Registry::is_registered + */ + public function test_is_registered_with_null_source_name() { + $result = $this->registry->is_registered( null ); + $this->assertFalse( $result ); + } } diff --git a/tests/phpunit/tests/block-pattern/wpBlockPatternCategoriesRegistry.php b/tests/phpunit/tests/block-pattern/wpBlockPatternCategoriesRegistry.php new file mode 100644 index 0000000000000..8a6700d69db41 --- /dev/null +++ b/tests/phpunit/tests/block-pattern/wpBlockPatternCategoriesRegistry.php @@ -0,0 +1,22 @@ +assertFalse( $registry->is_registered( null ) ); + } +} diff --git a/tests/phpunit/tests/block-templates/WpBlockTemplatesRegistry.php b/tests/phpunit/tests/block-templates/WpBlockTemplatesRegistry.php index a2b1d16eef618..e4675ad210751 100644 --- a/tests/phpunit/tests/block-templates/WpBlockTemplatesRegistry.php +++ b/tests/phpunit/tests/block-templates/WpBlockTemplatesRegistry.php @@ -247,6 +247,15 @@ public function test_is_registered() { self::$registry->unregister( $template_name ); } + /** + * @ticket 63957 + * + * @covers ::is_registered + */ + public function test_is_registered_with_null_template_name() { + $this->assertFalse( self::$registry->is_registered( null ) ); + } + /** * Tests that unregister() correctly unregisters a registered template. * diff --git a/tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php b/tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php index 378789c231b7f..738d086f4a30e 100644 --- a/tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php +++ b/tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php @@ -695,4 +695,11 @@ private function set_registered_patterns_variable_value( $value ) { $property->setAccessible( false ); } } + + /** + * @ticket 63957 + */ + public function test_is_registered_with_null_pattern_name() { + $this->assertFalse( $this->registry->is_registered( null ) ); + } } diff --git a/tests/phpunit/tests/blocks/wpBlockStylesRegistry.php b/tests/phpunit/tests/blocks/wpBlockStylesRegistry.php index f73ba67ba1619..6d3ff4e54a42e 100644 --- a/tests/phpunit/tests/blocks/wpBlockStylesRegistry.php +++ b/tests/phpunit/tests/blocks/wpBlockStylesRegistry.php @@ -66,4 +66,36 @@ public function test_register_block_style_with_array_of_block_names() { $this->assertTrue( $this->registry->is_registered( 'core/paragraph', 'plain' ) ); $this->assertTrue( $this->registry->is_registered( 'core/group', 'plain' ) ); } + + /** + * @ticket 63957 + */ + public function test_is_registered_returns_false_for_null_block_name() { + $style_name = 'fancy-style'; + $this->assertFalse( + $this->registry->is_registered( null, $style_name ), + 'Empty block name should return false.' + ); + } + + /** + * @ticket 63957 + */ + public function test_is_registered_returns_false_for_null_style_name() { + $block_name = 'core/paragraph'; + $this->assertFalse( + $this->registry->is_registered( $block_name, null ), + 'Empty style name should return false.' + ); + } + + /** + * @ticket 63957 + */ + public function test_is_registered_returns_false_for_both_null_params() { + $this->assertFalse( + $this->registry->is_registered( null, null ), + 'Both empty block and style name should return false.' + ); + } }