diff --git a/.github/workflows/callable-test-core-build-process.yml b/.github/workflows/callable-test-core-build-process.yml index a9523ec34300a..bf566e7782241 100644 --- a/.github/workflows/callable-test-core-build-process.yml +++ b/.github/workflows/callable-test-core-build-process.yml @@ -58,7 +58,6 @@ jobs: node --version curl --version git --version - svn --version - name: Install npm Dependencies run: npm ci diff --git a/.github/workflows/callable-test-gutenberg-build-process.yml b/.github/workflows/callable-test-gutenberg-build-process.yml index ef41cff56ed75..ed45a4f2ac032 100644 --- a/.github/workflows/callable-test-gutenberg-build-process.yml +++ b/.github/workflows/callable-test-gutenberg-build-process.yml @@ -20,6 +20,7 @@ on: env: GUTENBERG_DIRECTORY: ${{ inputs.directory == 'build' && 'build' || 'src' }}/wp-content/plugins/gutenberg PUPPETEER_SKIP_DOWNLOAD: ${{ true }} + NODE_OPTIONS: '--max-old-space-size=8192' jobs: # Verifies that installing npm dependencies and building the Gutenberg plugin works as expected. @@ -69,7 +70,6 @@ jobs: node --version curl --version git --version - svn --version - name: Install Core Dependencies run: npm ci diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index c09703167f1cd..393c7d1d7b013 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -162,7 +162,6 @@ jobs: npm --version node --version git --version - svn --version - name: Install npm Dependencies run: npm ci diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml index 25f37b5d4b046..344201d2572d5 100644 --- a/.github/workflows/end-to-end-tests.yml +++ b/.github/workflows/end-to-end-tests.yml @@ -87,7 +87,6 @@ jobs: node --version curl --version git --version - svn --version locale -a - name: Install npm Dependencies diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml index ce3536b84f796..1826b03041b9d 100644 --- a/.github/workflows/javascript-tests.yml +++ b/.github/workflows/javascript-tests.yml @@ -77,7 +77,6 @@ jobs: npm --version node --version git --version - svn --version - name: Install npm Dependencies run: npm ci diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index 356d5f77244e5..900b77417b400 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -121,7 +121,6 @@ jobs: node --version curl --version git --version - svn --version locale -a - name: Install npm dependencies diff --git a/.github/workflows/phpunit-tests-run.yml b/.github/workflows/phpunit-tests-run.yml index d47db28696382..bebd1e3a29d23 100644 --- a/.github/workflows/phpunit-tests-run.yml +++ b/.github/workflows/phpunit-tests-run.yml @@ -124,7 +124,6 @@ jobs: node --version curl --version git --version - svn --version composer --version locale -a diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml index 82449a8f0e374..5d1e6b2f2af85 100644 --- a/.github/workflows/test-coverage.yml +++ b/.github/workflows/test-coverage.yml @@ -117,7 +117,6 @@ jobs: node --version curl --version git --version - svn --version composer --version locale -a diff --git a/src/js/_enqueues/admin/post.js b/src/js/_enqueues/admin/post.js index eb577013d5ad3..bba9c17358df6 100644 --- a/src/js/_enqueues/admin/post.js +++ b/src/js/_enqueues/admin/post.js @@ -1173,7 +1173,7 @@ jQuery( function($) { } /** - * When the dragging stopped make sure we return focus and do a sanity check on the height. + * When the dragging stopped make sure we return focus and do a confidence check on the height. */ function endDrag() { var height, toolbarHeight; @@ -1198,7 +1198,7 @@ jQuery( function($) { $document.off( '.wp-editor-resize' ); - // Sanity check: normalize height to stay within acceptable ranges. + // Confidence check: normalize height to stay within acceptable ranges. if ( height && height > 50 && height < 5000 ) { setUserSetting( 'ed_size', height ); } diff --git a/src/js/_enqueues/vendor/tinymce/utils/form_utils.js b/src/js/_enqueues/vendor/tinymce/utils/form_utils.js index 358ad60a9a364..8f8a234c953b1 100644 --- a/src/js/_enqueues/vendor/tinymce/utils/form_utils.js +++ b/src/js/_enqueues/vendor/tinymce/utils/form_utils.js @@ -199,7 +199,7 @@ function getCSSSize(size) { if (/^[0-9]+$/.test(size)) { size += 'px'; } - // Sanity check, IE doesn't like broken values + // Confidence check, IE doesn't like broken values else if (!(/^[0-9\.]+(px|%|in|cm|mm|em|ex|pt|pc)$/i.test(size))) { return ""; } diff --git a/src/js/_enqueues/wp/theme.js b/src/js/_enqueues/wp/theme.js index 5daf04f7d7b55..13ed5aab4e8d2 100644 --- a/src/js/_enqueues/wp/theme.js +++ b/src/js/_enqueues/wp/theme.js @@ -1300,7 +1300,7 @@ themes.view.Themes = wp.Backbone.View.extend({ // Find the next model within the collection. nextModel = self.collection.at( self.collection.indexOf( model ) + 1 ); - // Sanity check which also serves as a boundary test. + // Confidence check which also serves as a boundary test. if ( nextModel !== undefined ) { // We have a new theme... diff --git a/src/wp-admin/includes/class-pclzip.php b/src/wp-admin/includes/class-pclzip.php index 3fdade5dd11f2..963f31178c1b6 100644 --- a/src/wp-admin/includes/class-pclzip.php +++ b/src/wp-admin/includes/class-pclzip.php @@ -1854,7 +1854,7 @@ function privOptionDefaultThreshold(&$p_options) $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit_int*PCLZIP_TEMPORARY_FILE_RATIO); - // ----- Sanity check : No threshold if value lower than 1M + // ----- Confidence check : No threshold if value lower than 1M if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) { unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]); } diff --git a/src/wp-admin/includes/class-plugin-upgrader.php b/src/wp-admin/includes/class-plugin-upgrader.php index 02743f64561e9..091cfebc188ff 100644 --- a/src/wp-admin/includes/class-plugin-upgrader.php +++ b/src/wp-admin/includes/class-plugin-upgrader.php @@ -472,7 +472,7 @@ public function check_package( $source ) { } $working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit( WP_CONTENT_DIR ), $source ); - if ( ! is_dir( $working_directory ) ) { // Sanity check, if the above fails, let's not prevent installation. + if ( ! is_dir( $working_directory ) ) { // Confidence check, if the above fails, let's not prevent installation. return $source; } diff --git a/src/wp-admin/includes/class-theme-upgrader.php b/src/wp-admin/includes/class-theme-upgrader.php index 12bd4772919cc..869bf64220fdf 100644 --- a/src/wp-admin/includes/class-theme-upgrader.php +++ b/src/wp-admin/includes/class-theme-upgrader.php @@ -371,6 +371,8 @@ public function upgrade( $theme, $args = array() ) { * @since 3.0.0 * @since 3.7.0 The `$args` parameter was added, making clearing the update cache optional. * + * @global string $wp_version The WordPress version string. + * * @param string[] $themes Array of the theme slugs. * @param array $args { * Optional. Other arguments for upgrading several themes at once. Default empty array. @@ -381,6 +383,8 @@ public function upgrade( $theme, $args = array() ) { * @return array[]|false An array of results, or false if unable to connect to the filesystem. */ public function bulk_upgrade( $themes, $args = array() ) { + global $wp_version; + $defaults = array( 'clear_update_cache' => true, ); @@ -442,23 +446,55 @@ public function bulk_upgrade( $themes, $args = array() ) { // Get the URL to the zip file. $r = $current->response[ $theme ]; - $result = $this->run( - array( - 'package' => $r['package'], - 'destination' => get_theme_root( $theme ), - 'clear_destination' => true, - 'clear_working' => true, - 'is_multi' => true, - 'hook_extra' => array( - 'theme' => $theme, - 'temp_backup' => array( - 'slug' => $theme, - 'src' => get_theme_root( $theme ), - 'dir' => 'themes', + if ( isset( $r['requires'] ) && ! is_wp_version_compatible( $r['requires'] ) ) { + $result = new WP_Error( + 'incompatible_wp_required_version', + sprintf( + /* translators: 1: Current WordPress version, 2: WordPress version required by the new theme version. */ + __( 'Your WordPress version is %1$s, however the new theme version requires %2$s.' ), + $wp_version, + $r['requires'] + ) + ); + + $this->skin->before( $result ); + $this->skin->error( $result ); + $this->skin->after(); + } elseif ( isset( $r['requires_php'] ) && ! is_php_version_compatible( $r['requires_php'] ) ) { + $result = new WP_Error( + 'incompatible_php_required_version', + sprintf( + /* translators: 1: Current PHP version, 2: PHP version required by the new theme version. */ + __( 'The PHP version on your server is %1$s, however the new theme version requires %2$s.' ), + PHP_VERSION, + $r['requires_php'] + ) + ); + + $this->skin->before( $result ); + $this->skin->error( $result ); + $this->skin->after(); + } else { + add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) ); + $result = $this->run( + array( + 'package' => $r['package'], + 'destination' => get_theme_root( $theme ), + 'clear_destination' => true, + 'clear_working' => true, + 'is_multi' => true, + 'hook_extra' => array( + 'theme' => $theme, + 'temp_backup' => array( + 'slug' => $theme, + 'src' => get_theme_root( $theme ), + 'dir' => 'themes', + ), ), - ), - ) - ); + ) + ); + remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) ); + } $results[ $theme ] = $result; @@ -538,7 +574,7 @@ public function check_package( $source ) { // Check that the folder contains a valid theme. $working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit( WP_CONTENT_DIR ), $source ); - if ( ! is_dir( $working_directory ) ) { // Sanity check, if the above fails, let's not prevent installation. + if ( ! is_dir( $working_directory ) ) { // Confidence check, if the above fails, let's not prevent installation. return $source; } diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index d83c8737685eb..ed6a9e75a47b3 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -381,6 +381,14 @@ public static function debug_data() { // Conditionally add debug information for multisite setups. if ( is_multisite() ) { + $site_id = get_current_blog_id(); + + $info['wp-core']['fields']['site_id'] = array( + 'label' => __( 'Site ID' ), + 'value' => $site_id, + 'debug' => $site_id, + ); + $network_query = new WP_Network_Query(); $network_ids = $network_query->query( array( diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index b9986d1bdec7a..c93ac71bec525 100644 --- a/src/wp-admin/includes/post.php +++ b/src/wp-admin/includes/post.php @@ -452,7 +452,7 @@ function edit_post( $post_data = null ) { $success = wp_update_post( $translated ); - // If the save failed, see if we can sanity check the main fields and try again. + // If the save failed, see if we can confidence check the main fields and try again. if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) { $fields = array( 'post_title', 'post_content', 'post_excerpt' ); diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php index ee710d3df36dc..0c66ad3ee9db0 100644 --- a/src/wp-admin/includes/update-core.php +++ b/src/wp-admin/includes/update-core.php @@ -1093,7 +1093,7 @@ function update_core( $from, $to ) { */ apply_filters( 'update_feedback', __( 'Verifying the unpacked files…' ) ); - // Sanity check the unzipped distribution. + // Confidence check the unzipped distribution. $distro = ''; $roots = array( '/wordpress/', '/wordpress-mu/' ); diff --git a/src/wp-admin/install.php b/src/wp-admin/install.php index 971392d07647c..bf102893ff9df 100644 --- a/src/wp-admin/install.php +++ b/src/wp-admin/install.php @@ -6,7 +6,7 @@ * @subpackage Administration */ -// Sanity check. +// Confidence check. if ( false ) { ?> diff --git a/src/wp-content/themes/twentyten/functions.php b/src/wp-content/themes/twentyten/functions.php index eb4fe64ef3a19..c2baec76eff4d 100644 --- a/src/wp-content/themes/twentyten/functions.php +++ b/src/wp-content/themes/twentyten/functions.php @@ -172,7 +172,7 @@ function twentyten_setup() { */ 'width' => apply_filters( 'twentyten_header_image_width', 940 ), /** - * Filters the Twenty Ten defaul header image height. + * Filters the Twenty Ten default header image height. * * @since Twenty Ten 1.0 * diff --git a/src/wp-content/themes/twentytwenty/assets/js/customize-controls.js b/src/wp-content/themes/twentytwenty/assets/js/customize-controls.js index 4397cf29c75de..ba2d5ad63f812 100644 --- a/src/wp-content/themes/twentytwenty/assets/js/customize-controls.js +++ b/src/wp-content/themes/twentytwenty/assets/js/customize-controls.js @@ -69,7 +69,7 @@ // Get accessible colors for the defined background-color and hue. colors = twentyTwentyColor( backgroundColor, accentHue ); - // Sanity check. + // Confidence check. if ( colors.getAccentColor() && 'function' === typeof colors.getAccentColor().toCSS ) { // Update the value for this context. value[ context ] = { diff --git a/src/wp-content/themes/twentytwentyone/inc/template-functions.php b/src/wp-content/themes/twentytwentyone/inc/template-functions.php index 5c1ca0f1e116d..4924773dc1c38 100644 --- a/src/wp-content/themes/twentytwentyone/inc/template-functions.php +++ b/src/wp-content/themes/twentytwentyone/inc/template-functions.php @@ -367,7 +367,7 @@ function twenty_twenty_one_print_first_instance_of_block( $block_name, $content // Loop blocks. foreach ( $blocks as $block ) { - // Sanity check. + // Confidence check. if ( ! isset( $block['blockName'] ) ) { continue; } diff --git a/src/wp-includes/block-supports/background.php b/src/wp-includes/block-supports/background.php index a8de0c6b63b20..283833991f57b 100644 --- a/src/wp-includes/block-supports/background.php +++ b/src/wp-includes/block-supports/background.php @@ -40,6 +40,7 @@ function wp_register_background_support( $block_type ) { * it is also applied to non-server-rendered blocks. * * @since 6.4.0 + * @since 6.5.0 Added support for `backgroundPosition` and `backgroundRepeat` output. * @access private * * @param string $block_content Rendered block content. @@ -64,9 +65,20 @@ function wp_render_background_support( $block_content, $block ) { $background_image_url = isset( $block_attributes['style']['background']['backgroundImage']['url'] ) ? $block_attributes['style']['background']['backgroundImage']['url'] : null; + + if ( ! $background_image_source && ! $background_image_url ) { + return $block_content; + } + $background_size = isset( $block_attributes['style']['background']['backgroundSize'] ) ? $block_attributes['style']['background']['backgroundSize'] : 'cover'; + $background_position = isset( $block_attributes['style']['background']['backgroundPosition'] ) + ? $block_attributes['style']['background']['backgroundPosition'] + : null; + $background_repeat = isset( $block_attributes['style']['background']['backgroundRepeat'] ) + ? $block_attributes['style']['background']['backgroundRepeat'] + : null; $background_block_styles = array(); @@ -76,8 +88,15 @@ function wp_render_background_support( $block_content, $block ) { ) { // Set file based background URL. $background_block_styles['backgroundImage']['url'] = $background_image_url; - // Only output the background size when an image url is set. - $background_block_styles['backgroundSize'] = $background_size; + // Only output the background size and repeat when an image url is set. + $background_block_styles['backgroundSize'] = $background_size; + $background_block_styles['backgroundRepeat'] = $background_repeat; + $background_block_styles['backgroundPosition'] = $background_position; + + // If the background size is set to `contain` and no position is set, set the position to `center`. + if ( 'contain' === $background_size && ! isset( $background_position ) ) { + $background_block_styles['backgroundPosition'] = 'center'; + } } $styles = wp_style_engine_get_styles( array( 'background' => $background_block_styles ) ); @@ -99,6 +118,7 @@ function wp_render_background_support( $block_content, $block ) { $updated_style .= $styles['css']; $tags->set_attribute( 'style', $updated_style ); + $tags->add_class( 'has-background' ); } return $tags->get_updated_html(); diff --git a/src/wp-includes/block-supports/layout.php b/src/wp-includes/block-supports/layout.php index 70d1fe4255fdd..67d6a3f1b77ac 100644 --- a/src/wp-includes/block-supports/layout.php +++ b/src/wp-includes/block-supports/layout.php @@ -638,7 +638,7 @@ function wp_render_layout_support_flag( $block_content, $block ) { * for features like the enhanced pagination of the Query block. */ $container_class = wp_unique_prefixed_id( - 'wp-container-' . sanitize_title( $block['blockName'] ) . '-layout-' + 'wp-container-' . sanitize_title( $block['blockName'] ) . '-is-layout-' ); // Set the correct layout type for blocks using legacy content width. @@ -883,17 +883,45 @@ function wp_restore_group_inner_container( $block_content, $block ) { return $block_content; } - $replace_regex = sprintf( + /* + * This filter runs after the layout classnames have been added to the block, so they + * have to be removed from the outer wrapper and then added to the inner. + */ + $layout_classes = array(); + $processor = new WP_HTML_Tag_Processor( $block_content ); + + if ( $processor->next_tag( array( 'class_name' => 'wp-block-group' ) ) ) { + foreach ( $processor->class_list() as $class_name ) { + if ( str_contains( $class_name, 'is-layout-' ) ) { + $layout_classes[] = $class_name; + $processor->remove_class( $class_name ); + } + } + } + + $content_without_layout_classes = $processor->get_updated_html(); + $replace_regex = sprintf( '/(^\s*<%1$s\b[^>]*wp-block-group[^>]*>)(.*)(<\/%1$s>\s*$)/ms', preg_quote( $tag_name, '/' ) ); - $updated_content = preg_replace_callback( + $updated_content = preg_replace_callback( $replace_regex, static function ( $matches ) { return $matches[1] . '
' . $matches[2] . '
' . $matches[3]; }, - $block_content + $content_without_layout_classes ); + + // Add layout classes to inner wrapper. + if ( ! empty( $layout_classes ) ) { + $processor = new WP_HTML_Tag_Processor( $updated_content ); + if ( $processor->next_tag( array( 'class_name' => 'wp-block-group__inner-container' ) ) ) { + foreach ( $layout_classes as $class_name ) { + $processor->add_class( $class_name ); + } + } + $updated_content = $processor->get_updated_html(); + } return $updated_content; } diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index 24f82510bd782..d12eea0e5f326 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -3079,25 +3079,26 @@ public function trash_changeset_post( $post ) { return false; } + $previous_status = $post->post_status; + /** This filter is documented in wp-includes/post.php */ - $check = apply_filters( 'pre_trash_post', null, $post ); + $check = apply_filters( 'pre_trash_post', null, $post, $previous_status ); if ( null !== $check ) { return $check; } /** This action is documented in wp-includes/post.php */ - do_action( 'wp_trash_post', $post_id ); + do_action( 'wp_trash_post', $post_id, $previous_status ); - add_post_meta( $post_id, '_wp_trash_meta_status', $post->post_status ); + add_post_meta( $post_id, '_wp_trash_meta_status', $previous_status ); add_post_meta( $post_id, '_wp_trash_meta_time', time() ); - $old_status = $post->post_status; $new_status = 'trash'; $wpdb->update( $wpdb->posts, array( 'post_status' => $new_status ), array( 'ID' => $post->ID ) ); clean_post_cache( $post->ID ); $post->post_status = $new_status; - wp_transition_post_status( $new_status, $old_status, $post ); + wp_transition_post_status( $new_status, $previous_status, $post ); /** This action is documented in wp-includes/post.php */ do_action( "edit_post_{$post->post_type}", $post->ID, $post ); @@ -3119,7 +3120,7 @@ public function trash_changeset_post( $post ) { wp_trash_post_comments( $post_id ); /** This action is documented in wp-includes/post.php */ - do_action( 'trashed_post', $post_id ); + do_action( 'trashed_post', $post_id, $previous_status ); return $post; } diff --git a/src/wp-includes/class-wp-tax-query.php b/src/wp-includes/class-wp-tax-query.php index 38841c42b06de..58e53ea4a2c75 100644 --- a/src/wp-includes/class-wp-tax-query.php +++ b/src/wp-includes/class-wp-tax-query.php @@ -505,7 +505,7 @@ public function get_sql_for_clause( &$clause, $parent_query ) { protected function find_compatible_table_alias( $clause, $parent_query ) { $alias = false; - // Sanity check. Only IN queries use the JOIN syntax. + // Confidence check. Only IN queries use the JOIN syntax. if ( ! isset( $clause['operator'] ) || 'IN' !== $clause['operator'] ) { return $alias; } diff --git a/src/wp-includes/class-wp-theme-json-resolver.php b/src/wp-includes/class-wp-theme-json-resolver.php index 90710a5c1b2f4..5a785612ce185 100644 --- a/src/wp-includes/class-wp-theme-json-resolver.php +++ b/src/wp-includes/class-wp-theme-json-resolver.php @@ -327,6 +327,11 @@ public static function get_theme_data( $deprecated = array(), $options = array() $theme_support_data['settings']['border']['style'] = true; $theme_support_data['settings']['border']['width'] = true; } + + // Allow themes to enable appearance tools via theme_support. + if ( current_theme_supports( 'appearance-tools' ) ) { + $theme_support_data['settings']['appearanceTools'] = true; + } } $with_theme_supports = new WP_Theme_JSON( $theme_support_data ); $with_theme_supports->merge( static::$theme ); diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index 9fea12a8d3e99..37f4d11ce9fb4 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -344,6 +344,8 @@ class WP_Theme_JSON { * @since 6.3.0 Added support for `typography.textColumns`, removed `layout.definitions`. * @since 6.4.0 Added support for `layout.allowEditing`, `background.backgroundImage`, * `typography.writingMode`, `lightbox.enabled` and `lightbox.allowEditing`. + * @since 6.5.0 Added support for `layout.allowCustomContentAndWideSize` and + * `background.backgroundSize`. * @var array */ const VALID_SETTINGS = array( @@ -351,6 +353,7 @@ class WP_Theme_JSON { 'useRootPaddingAwareAlignments' => null, 'background' => array( 'backgroundImage' => null, + 'backgroundSize' => null, ), 'border' => array( 'color' => null, @@ -380,9 +383,10 @@ class WP_Theme_JSON { 'minHeight' => null, ), 'layout' => array( - 'contentSize' => null, - 'wideSize' => null, - 'allowEditing' => null, + 'contentSize' => null, + 'wideSize' => null, + 'allowEditing' => null, + 'allowCustomContentAndWideSize' => null, ), 'lightbox' => array( 'enabled' => null, @@ -571,10 +575,12 @@ public static function get_element_class_name( $element ) { * @since 6.0.0 * @since 6.2.0 Added `dimensions.minHeight` and `position.sticky`. * @since 6.4.0 Added `background.backgroundImage`. + * @since 6.5.0 Added `background.backgroundSize`. * @var array */ const APPEARANCE_TOOLS_OPT_INS = array( array( 'background', 'backgroundImage' ), + array( 'background', 'backgroundSize' ), array( 'border', 'color' ), array( 'border', 'radius' ), array( 'border', 'style' ), diff --git a/src/wp-includes/class-wpdb.php b/src/wp-includes/class-wpdb.php index baba39d91f4d9..d9186b91f463f 100644 --- a/src/wp-includes/class-wpdb.php +++ b/src/wp-includes/class-wpdb.php @@ -154,7 +154,7 @@ class wpdb { protected $result; /** - * Cached column info, for sanity checking data before inserting. + * Cached column info, for confidence checking data before inserting. * * @since 4.2.0 * @@ -172,7 +172,7 @@ class wpdb { protected $table_charset = array(); /** - * Whether text fields in the current query need to be sanity checked. + * Whether text fields in the current query need to be confidence checked. * * @since 4.2.0 * @@ -1927,7 +1927,7 @@ public function flush() { mysqli_free_result( $this->result ); $this->result = null; - // Sanity check before using the handle. + // Confidence check before using the handle. if ( empty( $this->dbh ) || ! ( $this->dbh instanceof mysqli ) ) { return; } @@ -3516,7 +3516,7 @@ protected function check_safe_collation( $query ) { return false; } - // If any of the columns don't have one of these collations, it needs more sanity checking. + // If any of the columns don't have one of these collations, it needs more confidence checking. $safe_collations = array( 'utf8_bin', 'utf8_general_ci', diff --git a/src/wp-includes/cron.php b/src/wp-includes/cron.php index c1837e6051c1e..aadc22b7eb17d 100644 --- a/src/wp-includes/cron.php +++ b/src/wp-includes/cron.php @@ -874,7 +874,7 @@ function spawn_cron( $gmt_time = 0 ) { return false; } - // Sanity check. + // Confidence check. $crons = wp_get_ready_cron_jobs(); if ( empty( $crons ) ) { return false; diff --git a/src/wp-includes/fonts.php b/src/wp-includes/fonts.php index 306364bdc8099..87503c275f390 100644 --- a/src/wp-includes/fonts.php +++ b/src/wp-includes/fonts.php @@ -22,7 +22,7 @@ * @type array $font_variation { * @type string $font-family The font-family property. * @type string|string[] $src The URL(s) to each resource containing the font data. - * @type string $font_style Optional. The font-style property. Default 'normal'. + * @type string $font-style Optional. The font-style property. Default 'normal'. * @type string $font-weight Optional. The font-weight property. Default '400'. * @type string $font-display Optional. The font-display property. Default 'fallback'. * @type string $ascent-override Optional. The ascent-override property. diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index d270157d1f886..c4ecb81f66160 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -4284,7 +4284,7 @@ function _wp_die_process_input( $message, $title = '', $args = array() ) { } /** - * Encodes a variable into JSON, with some sanity checks. + * Encodes a variable into JSON, with some confidence checks. * * @since 4.1.0 * @since 5.3.0 No longer handles support for PHP < 5.6. @@ -4300,7 +4300,7 @@ function _wp_die_process_input( $message, $title = '', $args = array() ) { function wp_json_encode( $value, $flags = 0, $depth = 512 ) { $json = json_encode( $value, $flags, $depth ); - // If json_encode() was successful, no need to do more sanity checking. + // If json_encode() was successful, no need to do more confidence checking. if ( false !== $json ) { return $json; } @@ -4315,7 +4315,7 @@ function wp_json_encode( $value, $flags = 0, $depth = 512 ) { } /** - * Performs sanity checks on data that shall be encoded to JSON. + * Performs confidence checks on data that shall be encoded to JSON. * * @ignore * @since 4.1.0 diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php index e46c368c702d4..41823af00ff93 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -100,15 +100,19 @@ * The following list specifies the HTML tags that _are_ supported: * * - Containers: ADDRESS, BLOCKQUOTE, DETAILS, DIALOG, DIV, FOOTER, HEADER, MAIN, MENU, SPAN, SUMMARY. - * - Form elements: BUTTON, FIELDSET, SEARCH. + * - Custom elements: All custom elements are supported. :) + * - Form elements: BUTTON, DATALIST, FIELDSET, LABEL, LEGEND, METER, PROGRESS, SEARCH. * - Formatting elements: B, BIG, CODE, EM, FONT, I, SMALL, STRIKE, STRONG, TT, U. * - Heading elements: H1, H2, H3, H4, H5, H6, HGROUP. * - Links: A. * - Lists: DL. - * - Media elements: FIGCAPTION, FIGURE, IMG. + * - Media elements: AUDIO, CANVAS, FIGCAPTION, FIGURE, IMG, MAP, PICTURE, VIDEO. * - Paragraph: P. - * - Sectioning elements: ARTICLE, ASIDE, NAV, SECTION - * - Deprecated elements: CENTER, DIR + * - Phrasing elements: ABBR, BDI, BDO, CITE, DATA, DEL, DFN, INS, MARK, OUTPUT, Q, SAMP, SUB, SUP, TIME, VAR. + * - Sectioning elements: ARTICLE, ASIDE, NAV, SECTION. + * - Templating elements: SLOT. + * - Text decoration: RUBY. + * - Deprecated elements: ACRONYM, BLINK, CENTER, DIR, ISINDEX, MULTICOL, NEXTID, SPACER. * * ### Supported markup * @@ -830,41 +834,132 @@ private function step_in_body() { $this->reconstruct_active_formatting_elements(); $this->insert_html_element( $this->state->current_token ); return true; + } + + /* + * These tags require special handling in the 'in body' insertion mode + * but that handling hasn't yet been implemented. + * + * As the rules for each tag are implemented, the corresponding tag + * name should be removed from this list. An accompanying test should + * help ensure this list is maintained. + * + * @see Tests_HtmlApi_WpHtmlProcessor::test_step_in_body_fails_on_unsupported_tags + * + * Since this switch structure throws a WP_HTML_Unsupported_Exception, it's + * possible to handle "any other start tag" and "any other end tag" below, + * as that guarantees execution doesn't proceed for the unimplemented tags. + * + * @see https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inbody + */ + switch ( $tag_name ) { + case 'APPLET': + case 'AREA': + case 'BASE': + case 'BASEFONT': + case 'BGSOUND': + case 'BODY': + case 'BR': + case 'CAPTION': + case 'COL': + case 'COLGROUP': + case 'DD': + case 'DT': + case 'EMBED': + case 'FORM': + case 'FRAME': + case 'FRAMESET': + case 'HEAD': + case 'HR': + case 'HTML': + case 'IFRAME': + case 'INPUT': + case 'KEYGEN': + case 'LI': + case 'LINK': + case 'LISTING': + case 'MARQUEE': + case 'MATH': + case 'META': + case 'NOBR': + case 'NOEMBED': + case 'NOFRAMES': + case 'NOSCRIPT': + case 'OBJECT': + case 'OL': + case 'OPTGROUP': + case 'OPTION': + case 'PARAM': + case 'PLAINTEXT': + case 'PRE': + case 'RB': + case 'RP': + case 'RT': + case 'RTC': + case 'SARCASM': + case 'SCRIPT': + case 'SELECT': + case 'SOURCE': + case 'STYLE': + case 'SVG': + case 'TABLE': + case 'TBODY': + case 'TD': + case 'TEMPLATE': + case 'TEXTAREA': + case 'TFOOT': + case 'TH': + case 'THEAD': + case 'TITLE': + case 'TR': + case 'TRACK': + case 'UL': + case 'WBR': + case 'XMP': + $this->last_error = self::ERROR_UNSUPPORTED; + throw new WP_HTML_Unsupported_Exception( "Cannot process {$tag_name} element." ); + } + if ( ! $this->is_tag_closer() ) { /* * > Any other start tag */ - case '+SPAN': - $this->reconstruct_active_formatting_elements(); - $this->insert_html_element( $this->state->current_token ); - return true; + $this->reconstruct_active_formatting_elements(); + $this->insert_html_element( $this->state->current_token ); + return true; + } else { + /* + * > Any other end tag + */ /* - * Any other end tag + * Find the corresponding tag opener in the stack of open elements, if + * it exists before reaching a special element, which provides a kind + * of boundary in the stack. For example, a `` should not + * close anything beyond its containing `P` or `DIV` element. */ - case '-SPAN': - foreach ( $this->state->stack_of_open_elements->walk_up() as $item ) { - // > If node is an HTML element with the same tag name as the token, then: - if ( $item->node_name === $tag_name ) { - $this->generate_implied_end_tags( $tag_name ); + foreach ( $this->state->stack_of_open_elements->walk_up() as $node ) { + if ( $tag_name === $node->node_name ) { + break; + } - // > If node is not the current node, then this is a parse error. + if ( self::is_special( $node->node_name ) ) { + // This is a parse error, ignore the token. + return $this->step(); + } + } - $this->state->stack_of_open_elements->pop_until( $tag_name ); - return true; - } + $this->generate_implied_end_tags( $tag_name ); + if ( $node !== $this->state->stack_of_open_elements->current_node() ) { + // @todo Record parse error: this error doesn't impact parsing. + } - // > Otherwise, if node is in the special category, then this is a parse error; ignore the token, and return. - if ( self::is_special( $item->node_name ) ) { - return $this->step(); - } + foreach ( $this->state->stack_of_open_elements->walk_up() as $item ) { + $this->state->stack_of_open_elements->pop(); + if ( $node === $item ) { + return true; } - // Execution should not reach here; if it does then something went wrong. - return false; - - default: - $this->last_error = self::ERROR_UNSUPPORTED; - throw new WP_HTML_Unsupported_Exception( "Cannot process {$tag_name} element." ); + } } } @@ -1264,7 +1359,7 @@ private function run_adoption_agency_algorithm() { // > If formatting element is not in the stack of open elements, then this is a parse error; remove the element from the list, and return. if ( ! $this->state->stack_of_open_elements->contains_node( $formatting_element ) ) { - $this->state->active_formatting_elements->remove_node( $formatting_element->bookmark_name ); + $this->state->active_formatting_elements->remove_node( $formatting_element ); return; } diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index d6b6bc6649cc9..25fefbb6211cb 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -3861,7 +3861,7 @@ function wp_untrash_post_comments( $post = null ) { } foreach ( $group_by_status as $status => $comments ) { - // Sanity check. This shouldn't happen. + // Confidence check. This shouldn't happen. if ( 'post-trashed' === $status ) { $status = '0'; } diff --git a/src/wp-includes/shortcodes.php b/src/wp-includes/shortcodes.php index 24df21d4da11e..98cd8f71ddd02 100644 --- a/src/wp-includes/shortcodes.php +++ b/src/wp-includes/shortcodes.php @@ -504,7 +504,7 @@ function do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ) { $element = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $element ); } - // Looks like we found some crazy unfiltered HTML. Skipping it for sanity. + // Looks like we found some crazy unfiltered HTML. Skipping it for confidence. $element = strtr( $element, $trans ); continue; } diff --git a/src/wp-includes/style-engine/class-wp-style-engine.php b/src/wp-includes/style-engine/class-wp-style-engine.php index 121bac2d927ba..790e33f38c0e3 100644 --- a/src/wp-includes/style-engine/class-wp-style-engine.php +++ b/src/wp-includes/style-engine/class-wp-style-engine.php @@ -23,6 +23,7 @@ * @since 6.1.0 * @since 6.3.0 Added support for text-columns. * @since 6.4.0 Added support for background.backgroundImage. + * @since 6.5.0 Added support for background.backgroundPosition and background.backgroundRepeat. */ #[AllowDynamicProperties] final class WP_Style_Engine { @@ -48,14 +49,26 @@ final class WP_Style_Engine { */ const BLOCK_STYLE_DEFINITIONS_METADATA = array( 'background' => array( - 'backgroundImage' => array( + 'backgroundImage' => array( 'property_keys' => array( 'default' => 'background-image', ), 'value_func' => array( self::class, 'get_url_or_value_css_declaration' ), 'path' => array( 'background', 'backgroundImage' ), ), - 'backgroundSize' => array( + 'backgroundPosition' => array( + 'property_keys' => array( + 'default' => 'background-position', + ), + 'path' => array( 'background', 'backgroundPosition' ), + ), + 'backgroundRepeat' => array( + 'property_keys' => array( + 'default' => 'background-repeat', + ), + 'path' => array( 'background', 'backgroundRepeat' ), + ), + 'backgroundSize' => array( 'property_keys' => array( 'default' => 'background-size', ), @@ -215,6 +228,9 @@ final class WP_Style_Engine { 'default' => 'font-size', ), 'path' => array( 'typography', 'fontSize' ), + 'css_vars' => array( + 'font-size' => '--wp--preset--font-size--$slug', + ), 'classnames' => array( 'has-$slug-font-size' => 'font-size', ), @@ -223,6 +239,9 @@ final class WP_Style_Engine { 'property_keys' => array( 'default' => 'font-family', ), + 'css_vars' => array( + 'font-family' => '--wp--preset--font-family--$slug', + ), 'path' => array( 'typography', 'fontFamily' ), 'classnames' => array( 'has-$slug-font-family' => 'font-family', diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index 59ec5345fe0cd..b64a2f08db3ee 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -2434,6 +2434,11 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) { $description = wp_unslash( $args['description'] ); $parent = (int) $args['parent']; + // Sanitization could clean the name to an empty string that must be checked again. + if ( '' === $name ) { + return new WP_Error( 'invalid_term_name', __( 'Invalid term name.' ) ); + } + $slug_provided = ! empty( $args['slug'] ); if ( ! $slug_provided ) { $slug = sanitize_title( $name ); @@ -2573,7 +2578,7 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) { $tt_id = (int) $wpdb->insert_id; /* - * Sanity check: if we just created a term with the same parent + taxonomy + slug but a higher term_id than + * Confidence check: if we just created a term with the same parent + taxonomy + slug but a higher term_id than * an existing term, then we have unwittingly created a duplicate term. Delete the dupe, and use the term_id * and term_taxonomy_id of the older term instead. Then return out of the function so that the "create" hooks * are not fired. diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php index 1638128b4cf26..040275e0f8377 100644 --- a/src/wp-includes/theme.php +++ b/src/wp-includes/theme.php @@ -2617,12 +2617,15 @@ function get_theme_starter_content() { * @since 5.6.0 The `post-formats` feature warns if no array is passed as the second parameter. * @since 5.8.0 The `widgets-block-editor` feature enables the Widgets block editor. * @since 6.0.0 The `html5` feature warns if no array is passed as the second parameter. + * @since 6.5.0 The `appearance-tools` feature enables a few design tools for blocks, + * see `WP_Theme_JSON::APPEARANCE_TOOLS_OPT_INS` for a complete list. * * @global array $_wp_theme_features * * @param string $feature The feature being added. Likely core values include: * - 'admin-bar' * - 'align-wide' + * - 'appearance-tools' * - 'automatic-feed-links' * - 'core-block-patterns' * - 'custom-background' diff --git a/tests/phpunit/tests/actions.php b/tests/phpunit/tests/actions.php index 8b57382b9c545..e25183f75913d 100644 --- a/tests/phpunit/tests/actions.php +++ b/tests/phpunit/tests/actions.php @@ -229,35 +229,133 @@ public function test_action_args_with_php4_syntax() { $this->assertSame( array( $val ), array_pop( $argsvar ) ); } - public function test_action_priority() { - $a = new MockAction(); + /** + * @ticket 60193 + * + * @dataProvider data_priority_callback_order_with_integers + * @dataProvider data_priority_callback_order_with_unhappy_path_nonintegers + * + * @covers ::do_action + * + * @param array $priorities { + * Indexed array of the priorities for the MockAction callbacks. + * + * @type mixed $0 Priority for 'action' callback. + * @type mixed $1 Priority for 'action2' callback. + * } + * @param array $expected_call_order An array of callback names in expected call order. + * @param string $expected_deprecation Optional. Deprecation message. Default ''. + */ + public function test_priority_callback_order( $priorities, $expected_call_order, $expected_deprecation = '' ) { + $mock = new MockAction(); $hook_name = __FUNCTION__; - add_action( $hook_name, array( &$a, 'action' ), 10 ); - add_action( $hook_name, array( &$a, 'action2' ), 9 ); + if ( $expected_deprecation && PHP_VERSION_ID >= 80100 ) { + $this->expectDeprecation(); + $this->expectDeprecationMessage( $expected_deprecation ); + } + + add_action( $hook_name, array( $mock, 'action' ), $priorities[0] ); + add_action( $hook_name, array( $mock, 'action2' ), $priorities[1] ); do_action( $hook_name ); - // Two events, one per action. - $this->assertSame( 2, $a->get_call_count() ); + $this->assertSame( 2, $mock->get_call_count(), 'The number of call counts does not match' ); + + $actual_call_order = wp_list_pluck( $mock->get_events(), 'action' ); + $this->assertSame( $expected_call_order, $actual_call_order, 'The action callback order does not match the expected order' ); + } - $expected = array( - // 'action2' is called first because it has priority 9. - array( - 'action' => 'action2', - 'hook_name' => $hook_name, - 'tag' => $hook_name, // Back compat. - 'args' => array( '' ), + /** + * Happy path data provider. + * + * @return array[] + */ + public function data_priority_callback_order_with_integers() { + return array( + 'int DESC' => array( + 'priorities' => array( 10, 9 ), + 'expected_call_order' => array( 'action2', 'action' ), ), - // 'action' is called second. - array( - 'action' => 'action', - 'hook_name' => $hook_name, - 'tag' => $hook_name, // Back compat. - 'args' => array( '' ), + 'int ASC' => array( + 'priorities' => array( 9, 10 ), + 'expected_call_order' => array( 'action', 'action2' ), ), ); + } + + /** + * Unhappy path data provider. + * + * @return array[] + */ + public function data_priority_callback_order_with_unhappy_path_nonintegers() { + return array( + // Numbers as strings and floats. + 'int as string DESC' => array( + 'priorities' => array( '10', '9' ), + 'expected_call_order' => array( 'action2', 'action' ), + ), + 'int as string ASC' => array( + 'priorities' => array( '9', '10' ), + 'expected_call_order' => array( 'action', 'action2' ), + ), + 'float DESC' => array( + 'priorities' => array( 10.0, 9.5 ), + 'expected_call_order' => array( 'action2', 'action' ), + 'expected_deprecation' => 'Implicit conversion from float 9.5 to int loses precision', + ), + 'float ASC' => array( + 'priorities' => array( 9.5, 10.0 ), + 'expected_call_order' => array( 'action', 'action2' ), + 'expected_deprecation' => 'Implicit conversion from float 9.5 to int loses precision', + ), + 'float as string DESC' => array( + 'priorities' => array( '10.0', '9.5' ), + 'expected_call_order' => array( 'action2', 'action' ), + ), + 'float as string ASC' => array( + 'priorities' => array( '9.5', '10.0' ), + 'expected_call_order' => array( 'action', 'action2' ), + ), - $this->assertSame( $expected, $a->get_events() ); + // Non-numeric. + 'null' => array( + 'priorities' => array( null, null ), + 'expected_call_order' => array( 'action', 'action2' ), + ), + 'bool DESC' => array( + 'priorities' => array( true, false ), + 'expected_call_order' => array( 'action2', 'action' ), + ), + 'bool ASC' => array( + 'priorities' => array( false, true ), + 'expected_call_order' => array( 'action', 'action2' ), + ), + 'non-numerical string DESC' => array( + 'priorities' => array( 'test1', 'test2' ), + 'expected_call_order' => array( 'action', 'action2' ), + ), + 'non-numerical string ASC' => array( + 'priorities' => array( 'test1', 'test2' ), + 'expected_call_order' => array( 'action', 'action2' ), + ), + 'int, non-numerical string DESC' => array( + 'priorities' => array( 10, 'test' ), + 'expected_call_order' => array( 'action2', 'action' ), + ), + 'int, non-numerical string ASC' => array( + 'priorities' => array( 'test', 10 ), + 'expected_call_order' => array( 'action', 'action2' ), + ), + 'float, non-numerical string DESC' => array( + 'priorities' => array( 10.0, 'test' ), + 'expected_call_order' => array( 'action2', 'action' ), + ), + 'float, non-numerical string ASC' => array( + 'priorities' => array( 'test', 10.0 ), + 'expected_call_order' => array( 'action', 'action2' ), + ), + ); } /** diff --git a/tests/phpunit/tests/ajax/wpAjaxImageEditor.php b/tests/phpunit/tests/ajax/wpAjaxImageEditor.php index ac761c3520341..89745d645883c 100644 --- a/tests/phpunit/tests/ajax/wpAjaxImageEditor.php +++ b/tests/phpunit/tests/ajax/wpAjaxImageEditor.php @@ -52,7 +52,7 @@ public function testCropImageIntoLargerOne() { $ret = wp_save_image( $id ); $this->assertObjectHasProperty( 'error', $ret ); - $this->assertEquals( 'Images cannot be scaled to a size larger than the original.', $ret->error ); + $this->assertSame( 'Images cannot be scaled to a size larger than the original.', $ret->error ); } /** diff --git a/tests/phpunit/tests/ajax/wpAjaxInlineSave.php b/tests/phpunit/tests/ajax/wpAjaxInlineSave.php index 2edd630de8c64..afb73e6dcff61 100644 --- a/tests/phpunit/tests/ajax/wpAjaxInlineSave.php +++ b/tests/phpunit/tests/ajax/wpAjaxInlineSave.php @@ -110,7 +110,7 @@ public function test_quick_edit_draft_should_not_set_publish_date() { $this->assertSame( 'draft', $post->post_status ); - $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt ); + $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); // Set up a request. $_POST['_inline_edit'] = wp_create_nonce( 'inlineeditnonce' ); @@ -142,7 +142,7 @@ public function test_quick_edit_draft_should_not_set_publish_date() { $post_date = sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $_POST['aa'], $_POST['mm'], $_POST['jj'], $_POST['hh'], $_POST['mn'], $_POST['ss'] ); - $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt ); + $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); } /** @@ -167,7 +167,7 @@ public function test_quick_edit_draft_should_set_publish_date() { $this->assertSame( 'draft', $post->post_status ); - $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt ); + $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); // Set up a request. $_POST['_inline_edit'] = wp_create_nonce( 'inlineeditnonce' ); @@ -197,6 +197,6 @@ public function test_quick_edit_draft_should_set_publish_date() { $post = get_post( $post->ID ); - $this->assertEquals( '2020-09-11 19:20:11', $post->post_date_gmt ); + $this->assertSame( '2020-09-11 19:20:11', $post->post_date_gmt ); } } diff --git a/tests/phpunit/tests/block-supports/layout.php b/tests/phpunit/tests/block-supports/layout.php index df0abf9b49922..379c10fe2b566 100644 --- a/tests/phpunit/tests/block-supports/layout.php +++ b/tests/phpunit/tests/block-supports/layout.php @@ -252,4 +252,94 @@ public function data_layout_support_flag_renders_classnames_on_wrapper() { ), ); } + + /** + * Check that wp_restore_group_inner_container() restores the legacy inner container on the Group block. + * + * @ticket 60130 + * + * @covers ::wp_restore_group_inner_container + * + * @dataProvider data_restore_group_inner_container + * + * @param array $args Dataset to test. + * @param string $expected_output The expected output. + */ + public function test_restore_group_inner_container( $args, $expected_output ) { + $actual_output = wp_restore_group_inner_container( $args['block_content'], $args['block'] ); + $this->assertEquals( $expected_output, $actual_output ); + } + + /** + * Data provider for test_restore_group_inner_container. + * + * @return array + */ + public function data_restore_group_inner_container() { + return array( + 'group block with existing inner container' => array( + 'args' => array( + 'block_content' => '
', + 'block' => array( + 'blockName' => 'core/group', + 'attrs' => array( + 'layout' => array( + 'type' => 'default', + ), + ), + 'innerBlocks' => array(), + 'innerHTML' => '
', + 'innerContent' => array( + '
', + ' ', + '
', + ), + ), + ), + 'expected_output' => '
', + ), + 'group block with no existing inner container' => array( + 'args' => array( + 'block_content' => '
', + 'block' => array( + 'blockName' => 'core/group', + 'attrs' => array( + 'layout' => array( + 'type' => 'default', + ), + ), + 'innerBlocks' => array(), + 'innerHTML' => '
', + 'innerContent' => array( + '
', + ' ', + '
', + ), + ), + ), + 'expected_output' => '
', + ), + 'group block with layout classnames' => array( + 'args' => array( + 'block_content' => '
', + 'block' => array( + 'blockName' => 'core/group', + 'attrs' => array( + 'layout' => array( + 'type' => 'default', + ), + ), + 'innerBlocks' => array(), + 'innerHTML' => '
', + 'innerContent' => array( + '
', + ' ', + '
', + ), + ), + ), + 'expected_output' => '
', + ), + ); + } } diff --git a/tests/phpunit/tests/block-supports/wpRenderBackgroundSupport.php b/tests/phpunit/tests/block-supports/wpRenderBackgroundSupport.php index 4f38db87ab317..83ea7cd47c972 100644 --- a/tests/phpunit/tests/block-supports/wpRenderBackgroundSupport.php +++ b/tests/phpunit/tests/block-supports/wpRenderBackgroundSupport.php @@ -67,6 +67,7 @@ public function filter_set_theme_root() { * Tests that background image block support works as expected. * * @ticket 59357 + * @ticket 60175 * * @covers ::wp_render_background_support * @@ -135,7 +136,24 @@ public function data_background_block_support() { 'source' => 'file', ), ), - 'expected_wrapper' => '
Content
', + 'expected_wrapper' => '
Content
', + 'wrapper' => '
Content
', + ), + 'background image style with contain, position, and repeat is applied' => array( + 'theme_name' => 'block-theme-child-with-fluid-typography', + 'block_name' => 'test/background-rules-are-output', + 'background_settings' => array( + 'backgroundImage' => true, + ), + 'background_style' => array( + 'backgroundImage' => array( + 'url' => 'https://example.com/image.jpg', + 'source' => 'file', + ), + 'backgroundRepeat' => 'no-repeat', + 'backgroundSize' => 'contain', + ), + 'expected_wrapper' => '
Content
', 'wrapper' => '
Content
', ), 'background image style is appended if a style attribute already exists' => array( @@ -150,8 +168,8 @@ public function data_background_block_support() { 'source' => 'file', ), ), - 'expected_wrapper' => '
Content
', - 'wrapper' => '
Content
', + 'expected_wrapper' => '
Content
', + 'wrapper' => '
Content
', ), 'background image style is appended if a style attribute containing multiple styles already exists' => array( 'theme_name' => 'block-theme-child-with-fluid-typography', @@ -165,8 +183,8 @@ public function data_background_block_support() { 'source' => 'file', ), ), - 'expected_wrapper' => '
Content
', - 'wrapper' => '
Content
', + 'expected_wrapper' => '
Content
', + 'wrapper' => '
Content
', ), 'background image style is not applied if the block does not support background image' => array( 'theme_name' => 'block-theme-child-with-fluid-typography', diff --git a/tests/phpunit/tests/customize/manager.php b/tests/phpunit/tests/customize/manager.php index 9f0ff383ed0e8..0f8ddb2d9bbf3 100644 --- a/tests/phpunit/tests/customize/manager.php +++ b/tests/phpunit/tests/customize/manager.php @@ -2150,6 +2150,45 @@ public function test_trash_changeset_post_preserves_properties() { $this->assertSame( $args['post_content'], $post->post_content ); } + /** + * Test that trash_changeset_post() passes the correct number of arguments to post trash hooks. + * + * @ticket 60183 + * @covers WP_Customize_Manager::trash_changeset_post + */ + public function test_trash_changeset_post_passes_all_arguments_to_trash_hooks() { + $args = array( + 'post_type' => 'customize_changeset', + 'post_content' => wp_json_encode( + array( + 'blogname' => array( + 'value' => 'Test', + ), + ) + ), + 'post_name' => wp_generate_uuid4(), + 'post_status' => 'draft', + ); + + $post_id = wp_insert_post( $args ); + + $manager = $this->create_test_manager( $args['post_name'] ); + + $pre_trash_post = new MockAction(); + $wp_trash_post = new MockAction(); + $trashed_post = new MockAction(); + + add_action( 'pre_trash_post', array( $pre_trash_post, 'action' ), 10, 3 ); + add_action( 'wp_trash_post', array( $wp_trash_post, 'action' ), 10, 2 ); + add_action( 'trashed_post', array( $trashed_post, 'action' ), 10, 2 ); + + $manager->trash_changeset_post( $post_id ); + + $this->assertCount( 3, $pre_trash_post->get_args()[0] ); + $this->assertCount( 2, $wp_trash_post->get_args()[0] ); + $this->assertCount( 2, $trashed_post->get_args()[0] ); + } + /** * Register scratchpad setting. * diff --git a/tests/phpunit/tests/db/charset.php b/tests/phpunit/tests/db/charset.php index 1a79ab911f2fb..52eb56a7a80f4 100644 --- a/tests/phpunit/tests/db/charset.php +++ b/tests/phpunit/tests/db/charset.php @@ -1022,7 +1022,7 @@ public function data_table_collation_check() { $table_name = 'table_collation_check'; $data = array( 'utf8_bin' => array( - // utf8_bin tables don't need extra sanity checking. + // utf8_bin tables don't need extra confidence checking. 'create' => '( a VARCHAR(50) COLLATE utf8_bin )', 'expected' => true, ), @@ -1037,13 +1037,13 @@ public function data_table_collation_check() { 'expected' => false, ), 'utf8_bin + big5_chinese_ci' => array( - // utf8_bin tables don't need extra sanity checking, + // utf8_bin tables don't need extra confidence checking, // except for when they're not just utf8_bin. 'create' => '( a VARCHAR(50) COLLATE utf8_bin, b VARCHAR(50) COLLATE big5_chinese_ci )', 'expected' => false, ), 'utf8_bin + int' => array( - // utf8_bin tables don't need extra sanity checking + // utf8_bin tables don't need extra confidence checking // when the other columns aren't strings. 'create' => '( a VARCHAR(50) COLLATE utf8_bin, b INT )', 'expected' => true, diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index 9021397e3b94c..228077188067b 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -3366,7 +3366,7 @@ public function test_wp_default_packages_vendor( $script ) { wp_default_packages_vendor( $wp_scripts ); - $this->assertEquals( $package_json[ $script ], $wp_scripts->query( $script, 'registered' )->ver ); + $this->assertSame( $package_json[ $script ], $wp_scripts->query( $script, 'registered' )->ver ); } public function data_wp_default_packages_vendor() { diff --git a/tests/phpunit/tests/filters.php b/tests/phpunit/tests/filters.php index 04a5f9e915030..6d512a19acb64 100644 --- a/tests/phpunit/tests/filters.php +++ b/tests/phpunit/tests/filters.php @@ -118,37 +118,133 @@ public function test_filter_args_2() { $this->assertSame( array( $val ), array_pop( $argsvar2 ) ); } - public function test_filter_priority() { - $a = new MockAction(); + /** + * @ticket 60193 + * + * @dataProvider data_priority_callback_order_with_integers + * @dataProvider data_priority_callback_order_with_unhappy_path_nonintegers + * + * @covers ::apply_filters + * + * @param array $priorities { + * Indexed array of the priorities for the MockAction callbacks. + * + * @type mixed $0 Priority for 'action' callback. + * @type mixed $1 Priority for 'action2' callback. + * } + * @param array $expected_call_order An array of callback names in expected call order. + * @param string $expected_deprecation Optional. Deprecation message. Default ''. + */ + public function test_priority_callback_order( $priorities, $expected_call_order, $expected_deprecation = '' ) { + $mock = new MockAction(); $hook_name = __FUNCTION__; - $val = __FUNCTION__ . '_val'; - // Make two filters with different priorities. - add_filter( $hook_name, array( $a, 'filter' ), 10 ); - add_filter( $hook_name, array( $a, 'filter2' ), 9 ); - $this->assertSame( $val, apply_filters( $hook_name, $val ) ); + if ( $expected_deprecation && PHP_VERSION_ID >= 80100 ) { + $this->expectDeprecation(); + $this->expectDeprecationMessage( $expected_deprecation ); + } + + add_filter( $hook_name, array( $mock, 'filter' ), $priorities[0] ); + add_filter( $hook_name, array( $mock, 'filter2' ), $priorities[1] ); + apply_filters( $hook_name, __FUNCTION__ . '_val' ); + + $this->assertSame( 2, $mock->get_call_count(), 'The number of call counts does not match' ); - // There should be two events, one per filter. - $this->assertSame( 2, $a->get_call_count() ); + $actual_call_order = wp_list_pluck( $mock->get_events(), 'filter' ); + $this->assertSame( $expected_call_order, $actual_call_order, 'The filter callback order does not match the expected order' ); + } - $expected = array( - // 'filter2' is called first because it has priority 9. - array( - 'filter' => 'filter2', - 'hook_name' => $hook_name, - 'tag' => $hook_name, // Back compat. - 'args' => array( $val ), + /** + * Happy path data provider. + * + * @return array[] + */ + public function data_priority_callback_order_with_integers() { + return array( + 'int DESC' => array( + 'priorities' => array( 10, 9 ), + 'expected_call_order' => array( 'filter2', 'filter' ), ), - // 'filter' is called second. - array( - 'filter' => 'filter', - 'hook_name' => $hook_name, - 'tag' => $hook_name, // Back compat. - 'args' => array( $val ), + 'int ASC' => array( + 'priorities' => array( 9, 10 ), + 'expected_call_order' => array( 'filter', 'filter2' ), ), ); + } - $this->assertSame( $expected, $a->get_events() ); + /** + * Unhappy path data provider. + * + * @return array[] + */ + public function data_priority_callback_order_with_unhappy_path_nonintegers() { + return array( + // Numbers as strings and floats. + 'int as string DESC' => array( + 'priorities' => array( '10', '9' ), + 'expected_call_order' => array( 'filter2', 'filter' ), + ), + 'int as string ASC' => array( + 'priorities' => array( '9', '10' ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + 'float DESC' => array( + 'priorities' => array( 10.0, 9.5 ), + 'expected_call_order' => array( 'filter2', 'filter' ), + 'expected_deprecation' => 'Implicit conversion from float 9.5 to int loses precision', + ), + 'float ASC' => array( + 'priorities' => array( 9.5, 10.0 ), + 'expected_call_order' => array( 'filter', 'filter2' ), + 'expected_deprecation' => 'Implicit conversion from float 9.5 to int loses precision', + ), + 'float as string DESC' => array( + 'priorities' => array( '10.0', '9.5' ), + 'expected_call_order' => array( 'filter2', 'filter' ), + ), + 'float as string ASC' => array( + 'priorities' => array( '9.5', '10.0' ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + + // Non-numeric. + 'null' => array( + 'priorities' => array( null, null ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + 'bool DESC' => array( + 'priorities' => array( true, false ), + 'expected_call_order' => array( 'filter2', 'filter' ), + ), + 'bool ASC' => array( + 'priorities' => array( false, true ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + 'non-numerical string DESC' => array( + 'priorities' => array( 'test1', 'test2' ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + 'non-numerical string ASC' => array( + 'priorities' => array( 'test1', 'test2' ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + 'int, non-numerical string DESC' => array( + 'priorities' => array( 10, 'test' ), + 'expected_call_order' => array( 'filter2', 'filter' ), + ), + 'int, non-numerical string ASC' => array( + 'priorities' => array( 'test', 10 ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + 'float, non-numerical string DESC' => array( + 'priorities' => array( 10.0, 'test' ), + 'expected_call_order' => array( 'filter2', 'filter' ), + ), + 'float, non-numerical string ASC' => array( + 'priorities' => array( 'test', 10.0 ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + ); } /** diff --git a/tests/phpunit/tests/formatting/wpTexturize.php b/tests/phpunit/tests/formatting/wpTexturize.php index 3202db4ba760f..fa81245c83bb9 100644 --- a/tests/phpunit/tests/formatting/wpTexturize.php +++ b/tests/phpunit/tests/formatting/wpTexturize.php @@ -1788,7 +1788,7 @@ public function data_translate() { } /** - * Extra sanity checks for _wptexturize_pushpop_element() + * Extra confidence checks for _wptexturize_pushpop_element() * * @ticket 28483 * @dataProvider data_element_stack diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index cef6a1eaf5462..828184491d7b9 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -229,7 +229,7 @@ public function test_wp_unique_filename() { $testdir = DIR_TESTDATA . '/images/'; - // Sanity check. + // Confidence check. $this->assertSame( 'abcdefg.png', wp_unique_filename( $testdir, 'abcdefg.png' ), 'Test non-existing file, file name should be unchanged.' ); // Ensure correct images exist. diff --git a/tests/phpunit/tests/hooks/applyFilters.php b/tests/phpunit/tests/hooks/applyFilters.php index 4c3a594aa98e0..50c35e3498a96 100644 --- a/tests/phpunit/tests/hooks/applyFilters.php +++ b/tests/phpunit/tests/hooks/applyFilters.php @@ -42,4 +42,132 @@ public function test_apply_filters_with_multiple_calls() { $this->assertSame( $returned_two, $arg ); $this->assertSame( 2, $a->get_call_count() ); } + + /** + * @ticket 60193 + * + * @dataProvider data_priority_callback_order_with_integers + * @dataProvider data_priority_callback_order_with_unhappy_path_nonintegers + * + * @param array $priorities { + * Indexed array of the priorities for the MockAction callbacks. + * + * @type mixed $0 Priority for 'action' callback. + * @type mixed $1 Priority for 'action2' callback. + * } + * @param array $expected_call_order An array of callback names in expected call order. + * @param string $expected_deprecation Optional. Deprecation message. Default ''. + */ + public function test_priority_callback_order( $priorities, $expected_call_order, $expected_deprecation = '' ) { + $mock = new MockAction(); + $hook = new WP_Hook(); + $hook_name = __FUNCTION__; + + if ( $expected_deprecation && PHP_VERSION_ID >= 80100 ) { + $this->expectDeprecation(); + $this->expectDeprecationMessage( $expected_deprecation ); + } + + $hook->add_filter( $hook_name, array( $mock, 'filter' ), $priorities[0], 1 ); + $hook->add_filter( $hook_name, array( $mock, 'filter2' ), $priorities[1], 1 ); + $hook->apply_filters( __FUNCTION__ . '_val', array( '' ) ); + + $this->assertSame( 2, $mock->get_call_count(), 'The number of call counts does not match' ); + + $actual_call_order = wp_list_pluck( $mock->get_events(), 'filter' ); + $this->assertSame( $expected_call_order, $actual_call_order, 'The filter callback order does not match the expected order' ); + } + + /** + * Happy path data provider. + * + * @return array[] + */ + public function data_priority_callback_order_with_integers() { + return array( + 'int DESC' => array( + 'priorities' => array( 10, 9 ), + 'expected_call_order' => array( 'filter2', 'filter' ), + ), + 'int ASC' => array( + 'priorities' => array( 9, 10 ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + ); + } + + /** + * Unhappy path data provider. + * + * @return array[] + */ + public function data_priority_callback_order_with_unhappy_path_nonintegers() { + return array( + // Numbers as strings and floats. + 'int as string DESC' => array( + 'priorities' => array( '10', '9' ), + 'expected_call_order' => array( 'filter2', 'filter' ), + ), + 'int as string ASC' => array( + 'priorities' => array( '9', '10' ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + 'float DESC' => array( + 'priorities' => array( 10.0, 9.5 ), + 'expected_call_order' => array( 'filter2', 'filter' ), + 'expected_deprecation' => 'Implicit conversion from float 9.5 to int loses precision', + ), + 'float ASC' => array( + 'priorities' => array( 9.5, 10.0 ), + 'expected_call_order' => array( 'filter', 'filter2' ), + 'expected_deprecation' => 'Implicit conversion from float 9.5 to int loses precision', + ), + 'float as string DESC' => array( + 'priorities' => array( '10.0', '9.5' ), + 'expected_call_order' => array( 'filter2', 'filter' ), + ), + 'float as string ASC' => array( + 'priorities' => array( '9.5', '10.0' ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + + // Non-numeric. + 'null' => array( + 'priorities' => array( null, null ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + 'bool DESC' => array( + 'priorities' => array( true, false ), + 'expected_call_order' => array( 'filter2', 'filter' ), + ), + 'bool ASC' => array( + 'priorities' => array( false, true ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + 'non-numerical string DESC' => array( + 'priorities' => array( 'test1', 'test2' ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + 'non-numerical string ASC' => array( + 'priorities' => array( 'test1', 'test2' ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + 'int, non-numerical string DESC' => array( + 'priorities' => array( 10, 'test' ), + 'expected_call_order' => array( 'filter2', 'filter' ), + ), + 'int, non-numerical string ASC' => array( + 'priorities' => array( 'test', 10 ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + 'float, non-numerical string DESC' => array( + 'priorities' => array( 10.0, 'test' ), + 'expected_call_order' => array( 'filter2', 'filter' ), + ), + 'float, non-numerical string ASC' => array( + 'priorities' => array( 'test', 10.0 ), + 'expected_call_order' => array( 'filter', 'filter2' ), + ), + ); + } } diff --git a/tests/phpunit/tests/hooks/doAction.php b/tests/phpunit/tests/hooks/doAction.php index 858917fdcede1..c9767f865df26 100644 --- a/tests/phpunit/tests/hooks/doAction.php +++ b/tests/phpunit/tests/hooks/doAction.php @@ -85,6 +85,134 @@ public function test_do_action_with_multiple_callbacks_on_different_priorities() $this->assertSame( 1, $a->get_call_count() ); } + /** + * @ticket 60193 + * + * @dataProvider data_priority_callback_order_with_integers + * @dataProvider data_priority_callback_order_with_unhappy_path_nonintegers + * + * @param array $priorities { + * Indexed array of the priorities for the MockAction callbacks. + * + * @type mixed $0 Priority for 'action' callback. + * @type mixed $1 Priority for 'action2' callback. + * } + * @param array $expected_call_order An array of callback names in expected call order. + * @param string $expected_deprecation Optional. Deprecation message. Default ''. + */ + public function test_priority_callback_order( $priorities, $expected_call_order, $expected_deprecation = '' ) { + $mock = new MockAction(); + $hook = new WP_Hook(); + $hook_name = __FUNCTION__; + + if ( $expected_deprecation && PHP_VERSION_ID >= 80100 ) { + $this->expectDeprecation(); + $this->expectDeprecationMessage( $expected_deprecation ); + } + + $hook->add_filter( $hook_name, array( $mock, 'action' ), $priorities[0], 1 ); + $hook->add_filter( $hook_name, array( $mock, 'action2' ), $priorities[1], 1 ); + $hook->do_action( array( '' ) ); + + $this->assertSame( 2, $mock->get_call_count(), 'The number of call counts does not match' ); + + $actual_call_order = wp_list_pluck( $mock->get_events(), 'action' ); + $this->assertSame( $expected_call_order, $actual_call_order, 'The action callback order does not match the expected order' ); + } + + /** + * Happy path data provider. + * + * @return array[] + */ + public function data_priority_callback_order_with_integers() { + return array( + 'int DESC' => array( + 'priorities' => array( 10, 9 ), + 'expected_call_order' => array( 'action2', 'action' ), + ), + 'int ASC' => array( + 'priorities' => array( 9, 10 ), + 'expected_call_order' => array( 'action', 'action2' ), + ), + ); + } + + /** + * Unhappy path data provider. + * + * @return array[] + */ + public function data_priority_callback_order_with_unhappy_path_nonintegers() { + return array( + // Numbers as strings and floats. + 'int as string DESC' => array( + 'priorities' => array( '10', '9' ), + 'expected_call_order' => array( 'action2', 'action' ), + ), + 'int as string ASC' => array( + 'priorities' => array( '9', '10' ), + 'expected_call_order' => array( 'action', 'action2' ), + ), + 'float DESC' => array( + 'priorities' => array( 10.0, 9.5 ), + 'expected_call_order' => array( 'action2', 'action' ), + 'expected_deprecation' => 'Implicit conversion from float 9.5 to int loses precision', + ), + 'float ASC' => array( + 'priorities' => array( 9.5, 10.0 ), + 'expected_call_order' => array( 'action', 'action2' ), + 'expected_deprecation' => 'Implicit conversion from float 9.5 to int loses precision', + ), + 'float as string DESC' => array( + 'priorities' => array( '10.0', '9.5' ), + 'expected_call_order' => array( 'action2', 'action' ), + ), + 'float as string ASC' => array( + 'priorities' => array( '9.5', '10.0' ), + 'expected_call_order' => array( 'action', 'action2' ), + ), + + // Non-numeric. + 'null' => array( + 'priorities' => array( null, null ), + 'expected_call_order' => array( 'action', 'action2' ), + ), + 'bool DESC' => array( + 'priorities' => array( true, false ), + 'expected_call_order' => array( 'action2', 'action' ), + ), + 'bool ASC' => array( + 'priorities' => array( false, true ), + 'expected_call_order' => array( 'action', 'action2' ), + ), + 'non-numerical string DESC' => array( + 'priorities' => array( 'test1', 'test2' ), + 'expected_call_order' => array( 'action', 'action2' ), + ), + 'non-numerical string ASC' => array( + 'priorities' => array( 'test1', 'test2' ), + 'expected_call_order' => array( 'action', 'action2' ), + ), + 'int, non-numerical string DESC' => array( + 'priorities' => array( 10, 'test' ), + 'expected_call_order' => array( 'action2', 'action' ), + ), + 'int, non-numerical string ASC' => array( + 'priorities' => array( 'test', 10 ), + 'expected_call_order' => array( 'action', 'action2' ), + ), + 'float, non-numerical string DESC' => array( + 'priorities' => array( 10.0, 'test' ), + 'expected_call_order' => array( 'action2', 'action' ), + ), + 'float, non-numerical string ASC' => array( + 'priorities' => array( 'test', 10.0 ), + 'expected_call_order' => array( 'action', 'action2' ), + ), + ); + } + public function test_do_action_with_no_accepted_args() { $callback = array( $this, '_action_callback' ); $hook = new WP_Hook(); diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessor.php b/tests/phpunit/tests/html-api/wpHtmlProcessor.php index a9af5d790fc53..2e5565c9734fa 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessor.php @@ -60,22 +60,6 @@ public function test_get_tag_is_null_once_document_is_finished() { $this->assertNull( $p->get_tag() ); } - /** - * Ensures that if the HTML Processor encounters inputs that it can't properly handle, - * that it stops processing the rest of the document. This prevents data corruption. - * - * @ticket 59167 - * - * @covers WP_HTML_Processor::next_tag - */ - public function test_stops_processing_after_unsupported_elements() { - $p = WP_HTML_Processor::create_fragment( '

' ); - $p->next_tag( 'P' ); - $this->assertFalse( $p->next_tag(), 'Stepped into a tag after encountering X-NOT-SUPPORTED element when it should have aborted.' ); - $this->assertNull( $p->get_tag(), "Should have aborted processing, but still reported tag {$p->get_tag()} after properly failing to step into tag." ); - $this->assertFalse( $p->next_tag( 'P' ), 'Stepped into normal P element after X-NOT-SUPPORTED element when it should have aborted.' ); - } - /** * Ensures that the HTML Processor maintains its internal state through seek calls. * @@ -147,4 +131,96 @@ public function test_fails_to_reconstruct_formatting_elements() { $this->assertTrue( $p->next_tag( 'EM' ), 'Could not find first EM.' ); $this->assertFalse( $p->next_tag( 'EM' ), 'Should have aborted before finding second EM as it required reconstructing the first EM.' ); } + + /** + * Ensures that special handling of unsupported tags is cleaned up + * as handling is implemented. Otherwise there's risk of leaving special + * handling (that is never reached) when tag handling is implemented. + * + * @ticket 60092 + * + * @dataProvider data_unsupported_special_in_body_tags + * + * @covers WP_HTML_Processor::step_in_body + * + * @param string $tag_name Name of the tag to test. + */ + public function test_step_in_body_fails_on_unsupported_tags( $tag_name ) { + $fragment = WP_HTML_Processor::create_fragment( '<' . $tag_name . '>' ); + $this->assertFalse( $fragment->next_tag(), 'Should fail to find tag: ' . $tag_name . '.' ); + $this->assertEquals( $fragment->get_last_error(), WP_HTML_Processor::ERROR_UNSUPPORTED, 'Should have unsupported last error.' ); + } + + /** + * Data provider. + * + * @return array[] + */ + public function data_unsupported_special_in_body_tags() { + return array( + 'APPLET' => array( 'APPLET' ), + 'AREA' => array( 'AREA' ), + 'BASE' => array( 'BASE' ), + 'BASEFONT' => array( 'BASEFONT' ), + 'BGSOUND' => array( 'BGSOUND' ), + 'BODY' => array( 'BODY' ), + 'BR' => array( 'BR' ), + 'CAPTION' => array( 'CAPTION' ), + 'COL' => array( 'COL' ), + 'COLGROUP' => array( 'COLGROUP' ), + 'DD' => array( 'DD' ), + 'DT' => array( 'DT' ), + 'EMBED' => array( 'EMBED' ), + 'FORM' => array( 'FORM' ), + 'FRAME' => array( 'FRAME' ), + 'FRAMESET' => array( 'FRAMESET' ), + 'HEAD' => array( 'HEAD' ), + 'HR' => array( 'HR' ), + 'HTML' => array( 'HTML' ), + 'IFRAME' => array( 'IFRAME' ), + 'INPUT' => array( 'INPUT' ), + 'KEYGEN' => array( 'KEYGEN' ), + 'LI' => array( 'LI' ), + 'LINK' => array( 'LINK' ), + 'LISTING' => array( 'LISTING' ), + 'MARQUEE' => array( 'MARQUEE' ), + 'MATH' => array( 'MATH' ), + 'META' => array( 'META' ), + 'NOBR' => array( 'NOBR' ), + 'NOEMBED' => array( 'NOEMBED' ), + 'NOFRAMES' => array( 'NOFRAMES' ), + 'NOSCRIPT' => array( 'NOSCRIPT' ), + 'OBJECT' => array( 'OBJECT' ), + 'OL' => array( 'OL' ), + 'OPTGROUP' => array( 'OPTGROUP' ), + 'OPTION' => array( 'OPTION' ), + 'PARAM' => array( 'PARAM' ), + 'PLAINTEXT' => array( 'PLAINTEXT' ), + 'PRE' => array( 'PRE' ), + 'RB' => array( 'RB' ), + 'RP' => array( 'RP' ), + 'RT' => array( 'RT' ), + 'RTC' => array( 'RTC' ), + 'SARCASM' => array( 'SARCASM' ), + 'SCRIPT' => array( 'SCRIPT' ), + 'SELECT' => array( 'SELECT' ), + 'SOURCE' => array( 'SOURCE' ), + 'STYLE' => array( 'STYLE' ), + 'SVG' => array( 'SVG' ), + 'TABLE' => array( 'TABLE' ), + 'TBODY' => array( 'TBODY' ), + 'TD' => array( 'TD' ), + 'TEMPLATE' => array( 'TEMPLATE' ), + 'TEXTAREA' => array( 'TEXTAREA' ), + 'TFOOT' => array( 'TFOOT' ), + 'TH' => array( 'TH' ), + 'THEAD' => array( 'THEAD' ), + 'TITLE' => array( 'TITLE' ), + 'TR' => array( 'TR' ), + 'TRACK' => array( 'TRACK' ), + 'UL' => array( 'UL' ), + 'WBR' => array( 'WBR' ), + 'XMP' => array( 'XMP' ), + ); + } } diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php b/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php index 2fd852e434412..3b339e4f82ee9 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php @@ -37,14 +37,26 @@ public function test_navigates_into_normative_html_for_supported_elements( $html public function data_single_tag_of_supported_elements() { $supported_elements = array( 'A', + 'ABBR', + 'ACRONYM', // Neutralized 'ADDRESS', 'ARTICLE', 'ASIDE', + 'AUDIO', 'B', + 'BDI', + 'BDO', 'BIG', + 'BLINK', // Deprecated 'BUTTON', + 'CANVAS', 'CENTER', // Neutralized + 'CITE', 'CODE', + 'DATA', + 'DATALIST', + 'DFN', + 'DEL', 'DETAILS', 'DIALOG', 'DIR', @@ -66,19 +78,42 @@ public function data_single_tag_of_supported_elements() { 'HGROUP', 'I', 'IMG', + 'INS', + 'ISINDEX', // Deprecated + 'KBD', + 'LABEL', + 'LEGEND', 'MAIN', + 'MAP', + 'MARK', 'MENU', + 'METER', + 'MULTICOL', // Deprecated 'NAV', + 'NEXTID', // Deprecated + 'OUTPUT', 'P', + 'PICTURE', + 'PROGRESS', + 'Q', + 'RUBY', + 'SAMP', 'SEARCH', 'SECTION', + 'SLOT', 'SMALL', + 'SPACER', // Deprecated 'SPAN', 'STRIKE', 'STRONG', + 'SUB', 'SUMMARY', + 'SUP', + 'TIME', 'TT', 'U', + 'VAR', + 'VIDEO', ); $data = array(); @@ -121,28 +156,16 @@ public function test_fails_when_encountering_unsupported_tag( $html ) { */ public function data_unsupported_elements() { $unsupported_elements = array( - 'ABBR', - 'ACRONYM', // Neutralized 'APPLET', // Deprecated 'AREA', - 'AUDIO', 'BASE', - 'BDI', - 'BDO', 'BGSOUND', // Deprecated; self-closing if self-closing flag provided, otherwise normal. - 'BLINK', // Deprecated 'BODY', 'BR', - 'CANVAS', 'CAPTION', - 'CITE', 'COL', 'COLGROUP', - 'DATA', - 'DATALIST', 'DD', - 'DEL', - 'DEFN', 'DT', 'EMBED', 'FORM', @@ -153,23 +176,13 @@ public function data_unsupported_elements() { 'HTML', 'IFRAME', 'INPUT', - 'INS', - 'ISINDEX', // Deprecated - 'KBD', 'KEYGEN', // Deprecated; void - 'LABEL', - 'LEGEND', 'LI', 'LINK', 'LISTING', // Deprecated, use PRE instead. - 'MAP', - 'MARK', 'MARQUEE', // Deprecated 'MATH', 'META', - 'METER', - 'MULTICOL', // Deprecated - 'NEXTID', // Deprecated 'NOBR', // Neutralized 'NOEMBED', // Neutralized 'NOFRAMES', // Neutralized @@ -178,26 +191,16 @@ public function data_unsupported_elements() { 'OL', 'OPTGROUP', 'OPTION', - 'OUTPUT', - 'PICTURE', 'PLAINTEXT', // Neutralized 'PRE', - 'PROGRESS', - 'Q', 'RB', // Neutralized 'RP', 'RT', 'RTC', // Neutralized - 'RUBY', - 'SAMP', 'SCRIPT', 'SELECT', - 'SLOT', 'SOURCE', - 'SPACER', // Deprecated 'STYLE', - 'SUB', - 'SUP', 'SVG', 'TABLE', 'TBODY', @@ -207,19 +210,12 @@ public function data_unsupported_elements() { 'TFOOT', 'TH', 'THEAD', - 'TIME', 'TITLE', 'TR', 'TRACK', 'UL', - 'VAR', - 'VIDEO', 'WBR', 'XMP', // Deprecated, use PRE instead. - - // Made up elements, custom elements. - 'X-NOT-AN-HTML-ELEMENT', - 'HUMAN-TIME', ); $data = array(); @@ -360,6 +356,10 @@ public function data_html_target_with_breadcrumbs() { 'H4 inside H2' => array( '

Major

Minor

', array( 'HTML', 'BODY', 'H2', 'SPAN', 'H4' ), 1 ), 'H5 after unclosed H4 inside H2' => array( '

Major

Minor

', array( 'HTML', 'BODY', 'H2', 'SPAN', 'H5' ), 1 ), 'H5 after H4 inside H2' => array( '

Major

Minor

', array( 'HTML', 'BODY', 'H5' ), 1 ), + + // Custom elements. + 'WP-EMOJI' => array( '
', array( 'HTML', 'BODY', 'DIV', 'WP-EMOJI' ), 1 ), + 'WP-EMOJI then IMG' => array( '
', array( 'HTML', 'BODY', 'DIV', 'IMG' ), 1 ), ); } diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php b/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php index 7bd243d8dce9a..bd3996d51d7b7 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php @@ -35,7 +35,7 @@ public function test_in_body_article_group_closes_open_p_element( $tag_name ) { continue; } - $this->assertEquals( + $this->assertSame( $tag_name, $processor->get_tag(), "Expected to find {$tag_name} but found {$processor->get_tag()} instead." @@ -125,7 +125,7 @@ public function test_in_body_skips_unexpected_button_closer() { $p = WP_HTML_Processor::create_fragment( '
Test
' ); $p->step(); - $this->assertEquals( 'DIV', $p->get_tag(), 'Did not stop at initial DIV tag.' ); + $this->assertSame( 'DIV', $p->get_tag(), 'Did not stop at initial DIV tag.' ); $this->assertFalse( $p->is_tag_closer(), 'Did not find that initial DIV tag is an opener.' ); /* @@ -133,7 +133,7 @@ public function test_in_body_skips_unexpected_button_closer() { * It should be ignored as there's no BUTTON to close. */ $this->assertTrue( $p->step(), 'Found no further tags when it should have found the closing DIV' ); - $this->assertEquals( 'DIV', $p->get_tag(), "Did not skip unexpected BUTTON; stopped at {$p->get_tag()}." ); + $this->assertSame( 'DIV', $p->get_tag(), "Did not skip unexpected BUTTON; stopped at {$p->get_tag()}." ); $this->assertTrue( $p->is_tag_closer(), 'Did not find that the terminal DIV tag is a closer.' ); } diff --git a/tests/phpunit/tests/html-api/wpHtmlSupportRequiredOpenElements.php b/tests/phpunit/tests/html-api/wpHtmlSupportRequiredOpenElements.php index 9dbb689df0329..a0c9c600c1e45 100644 --- a/tests/phpunit/tests/html-api/wpHtmlSupportRequiredOpenElements.php +++ b/tests/phpunit/tests/html-api/wpHtmlSupportRequiredOpenElements.php @@ -72,21 +72,16 @@ public function test_has_element_in_scope_needs_support() { $this->ensure_support_is_added_everywhere( 'OBJECT' ); $this->ensure_support_is_added_everywhere( 'TEMPLATE' ); - // MathML Elements - $this->ensure_support_is_added_everywhere( 'MI' ); - $this->ensure_support_is_added_everywhere( 'MO' ); - $this->ensure_support_is_added_everywhere( 'MN' ); - $this->ensure_support_is_added_everywhere( 'MS' ); - $this->ensure_support_is_added_everywhere( 'MTEXT' ); - $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' ); + // MathML Elements: MI, MO, MN, MS, MTEXT, ANNOTATION-XML. + $this->ensure_support_is_added_everywhere( 'MATH' ); /* * SVG elements: note that TITLE is both an HTML element and an SVG element * so care must be taken when adding support for either one. + * + * FOREIGNOBJECT, DESC, TITLE. */ - $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' ); - $this->ensure_support_is_added_everywhere( 'DESC' ); - $this->ensure_support_is_added_everywhere( 'TITLE' ); + $this->ensure_support_is_added_everywhere( 'SVG' ); } /** @@ -115,21 +110,16 @@ public function test_has_element_in_list_item_scope_needs_support() { $this->ensure_support_is_added_everywhere( 'OBJECT' ); $this->ensure_support_is_added_everywhere( 'TEMPLATE' ); - // MathML Elements - $this->ensure_support_is_added_everywhere( 'MI' ); - $this->ensure_support_is_added_everywhere( 'MO' ); - $this->ensure_support_is_added_everywhere( 'MN' ); - $this->ensure_support_is_added_everywhere( 'MS' ); - $this->ensure_support_is_added_everywhere( 'MTEXT' ); - $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' ); + // MathML Elements: MI, MO, MN, MS, MTEXT, ANNOTATION-XML. + $this->ensure_support_is_added_everywhere( 'MATH' ); /* * SVG elements: note that TITLE is both an HTML element and an SVG element * so care must be taken when adding support for either one. + * + * FOREIGNOBJECT, DESC, TITLE. */ - $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' ); - $this->ensure_support_is_added_everywhere( 'DESC' ); - $this->ensure_support_is_added_everywhere( 'TITLE' ); + $this->ensure_support_is_added_everywhere( 'SVG' ); // These elements are specific to list item scope. $this->ensure_support_is_added_everywhere( 'OL' ); @@ -161,21 +151,16 @@ public function test_has_element_in_button_scope_needs_support() { $this->ensure_support_is_added_everywhere( 'OBJECT' ); $this->ensure_support_is_added_everywhere( 'TEMPLATE' ); - // MathML Elements - $this->ensure_support_is_added_everywhere( 'MI' ); - $this->ensure_support_is_added_everywhere( 'MO' ); - $this->ensure_support_is_added_everywhere( 'MN' ); - $this->ensure_support_is_added_everywhere( 'MS' ); - $this->ensure_support_is_added_everywhere( 'MTEXT' ); - $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' ); + // MathML Elements: MI, MO, MN, MS, MTEXT, ANNOTATION-XML. + $this->ensure_support_is_added_everywhere( 'MATH' ); /* * SVG elements: note that TITLE is both an HTML element and an SVG element * so care must be taken when adding support for either one. + * + * FOREIGNOBJECT, DESC, TITLE. */ - $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' ); - $this->ensure_support_is_added_everywhere( 'DESC' ); - $this->ensure_support_is_added_everywhere( 'TITLE' ); + $this->ensure_support_is_added_everywhere( 'SVG' ); } /** @@ -201,21 +186,16 @@ public function test_after_element_pop_must_maintain_p_in_button_scope_flag() { $this->ensure_support_is_added_everywhere( 'OBJECT' ); $this->ensure_support_is_added_everywhere( 'TEMPLATE' ); - // MathML Elements - $this->ensure_support_is_added_everywhere( 'MI' ); - $this->ensure_support_is_added_everywhere( 'MO' ); - $this->ensure_support_is_added_everywhere( 'MN' ); - $this->ensure_support_is_added_everywhere( 'MS' ); - $this->ensure_support_is_added_everywhere( 'MTEXT' ); - $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' ); + // MathML Elements: MI, MO, MN, MS, MTEXT, ANNOTATION-XML. + $this->ensure_support_is_added_everywhere( 'MATH' ); /* * SVG elements: note that TITLE is both an HTML element and an SVG element * so care must be taken when adding support for either one. + * + * FOREIGNOBJECT, DESC, TITLE. */ - $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' ); - $this->ensure_support_is_added_everywhere( 'DESC' ); - $this->ensure_support_is_added_everywhere( 'TITLE' ); + $this->ensure_support_is_added_everywhere( 'SVG' ); } /** @@ -241,21 +221,16 @@ public function test_after_element_push_must_maintain_p_in_button_scope_flag() { $this->ensure_support_is_added_everywhere( 'OBJECT' ); $this->ensure_support_is_added_everywhere( 'TEMPLATE' ); - // MathML Elements - $this->ensure_support_is_added_everywhere( 'MI' ); - $this->ensure_support_is_added_everywhere( 'MO' ); - $this->ensure_support_is_added_everywhere( 'MN' ); - $this->ensure_support_is_added_everywhere( 'MS' ); - $this->ensure_support_is_added_everywhere( 'MTEXT' ); - $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' ); + // MathML Elements: MI, MO, MN, MS, MTEXT, ANNOTATION-XML. + $this->ensure_support_is_added_everywhere( 'MATH' ); /* * SVG elements: note that TITLE is both an HTML element and an SVG element * so care must be taken when adding support for either one. + * + * FOREIGNOBJECT, DESC, TITLE. */ - $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' ); - $this->ensure_support_is_added_everywhere( 'DESC' ); - $this->ensure_support_is_added_everywhere( 'TITLE' ); + $this->ensure_support_is_added_everywhere( 'SVG' ); } /** @@ -280,21 +255,16 @@ public function test_has_element_in_table_scope_needs_support() { $this->ensure_support_is_added_everywhere( 'OBJECT' ); $this->ensure_support_is_added_everywhere( 'TEMPLATE' ); - // MathML Elements - $this->ensure_support_is_added_everywhere( 'MI' ); - $this->ensure_support_is_added_everywhere( 'MO' ); - $this->ensure_support_is_added_everywhere( 'MN' ); - $this->ensure_support_is_added_everywhere( 'MS' ); - $this->ensure_support_is_added_everywhere( 'MTEXT' ); - $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' ); + // MathML Elements: MI, MO, MN, MS, MTEXT, ANNOTATION-XML. + $this->ensure_support_is_added_everywhere( 'MATH' ); /* * SVG elements: note that TITLE is both an HTML element and an SVG element * so care must be taken when adding support for either one. + * + * FOREIGNOBJECT, DESC, TITLE. */ - $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' ); - $this->ensure_support_is_added_everywhere( 'DESC' ); - $this->ensure_support_is_added_everywhere( 'TITLE' ); + $this->ensure_support_is_added_everywhere( 'SVG' ); // These elements are specific to TABLE scope. $this->ensure_support_is_added_everywhere( 'HTML' ); @@ -335,21 +305,16 @@ public function test_has_element_in_select_scope_needs_support() { $this->ensure_support_is_added_everywhere( 'OBJECT' ); $this->ensure_support_is_added_everywhere( 'TEMPLATE' ); - // MathML Elements - $this->ensure_support_is_added_everywhere( 'MI' ); - $this->ensure_support_is_added_everywhere( 'MO' ); - $this->ensure_support_is_added_everywhere( 'MN' ); - $this->ensure_support_is_added_everywhere( 'MS' ); - $this->ensure_support_is_added_everywhere( 'MTEXT' ); - $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' ); + // MathML Elements: MI, MO, MN, MS, MTEXT, ANNOTATION-XML. + $this->ensure_support_is_added_everywhere( 'MATH' ); /* * SVG elements: note that TITLE is both an HTML element and an SVG element * so care must be taken when adding support for either one. + * + * FOREIGNOBJECT, DESC, TITLE. */ - $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' ); - $this->ensure_support_is_added_everywhere( 'DESC' ); - $this->ensure_support_is_added_everywhere( 'TITLE' ); + $this->ensure_support_is_added_everywhere( 'SVG' ); // These elements are specific to SELECT scope. $this->ensure_support_is_added_everywhere( 'OPTGROUP' ); diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index 548c5eb2cabf8..6e0207add28de 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -329,12 +329,12 @@ public function test_user_without_publish_posts_cannot_affect_sticky() { ); stick_post( $post->ID ); - // Sanity check. + // Confidence check. $this->assertTrue( is_sticky( $post->ID ) ); wp_set_current_user( self::$grammarian_id ); - // Sanity check. + // Confidence check. $this->assertFalse( current_user_can( 'publish_posts' ) ); $this->assertTrue( current_user_can( 'edit_others_posts' ) ); $this->assertTrue( current_user_can( 'edit_published_posts' ) ); @@ -367,12 +367,12 @@ public function test_user_without_publish_posts_cannot_affect_sticky_with_edit_p ); stick_post( $post->ID ); - // Sanity check. + // Confidence check. $this->assertTrue( is_sticky( $post->ID ) ); wp_set_current_user( self::$grammarian_id ); - // Sanity check. + // Confidence check. $this->assertFalse( current_user_can( 'publish_posts' ) ); $this->assertTrue( current_user_can( 'edit_others_posts' ) ); $this->assertTrue( current_user_can( 'edit_published_posts' ) ); diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php index ac5b0741e90a0..2cad1ef03225f 100644 --- a/tests/phpunit/tests/rest-api/rest-users-controller.php +++ b/tests/phpunit/tests/rest-api/rest-users-controller.php @@ -2520,7 +2520,7 @@ public function test_delete_user_reassign() { ) ); - // Sanity check to ensure the factory created the post correctly. + // Confidence check to ensure the factory created the post correctly. $post = get_post( $test_post ); $this->assertEquals( $user_id, $post->post_author ); diff --git a/tests/phpunit/tests/style-engine/styleEngine.php b/tests/phpunit/tests/style-engine/styleEngine.php index b1a01563c2097..b208e4ef0575a 100644 --- a/tests/phpunit/tests/style-engine/styleEngine.php +++ b/tests/phpunit/tests/style-engine/styleEngine.php @@ -27,6 +27,7 @@ public function tear_down() { * @ticket 56467 * @ticket 58549 * @ticket 58590 + * @ticket 60175 * * @covers ::wp_style_engine_get_styles * @@ -252,19 +253,26 @@ public function data_wp_style_engine_get_styles() { 'elements_with_css_var_value' => array( 'block_styles' => array( - 'color' => array( + 'color' => array( 'text' => 'var:preset|color|my-little-pony', ), + 'typography' => array( + 'fontSize' => 'var:preset|font-size|cabbage-patch', + 'fontFamily' => 'var:preset|font-family|transformers', + ), ), 'options' => array( 'selector' => '.wp-selector', ), 'expected_output' => array( - 'css' => '.wp-selector{color:var(--wp--preset--color--my-little-pony);}', + 'css' => '.wp-selector{color:var(--wp--preset--color--my-little-pony);font-size:var(--wp--preset--font-size--cabbage-patch);font-family:var(--wp--preset--font-family--transformers);}', 'declarations' => array( - 'color' => 'var(--wp--preset--color--my-little-pony)', + 'color' => 'var(--wp--preset--color--my-little-pony)', + 'font-size' => 'var(--wp--preset--font-size--cabbage-patch)', + 'font-family' => 'var(--wp--preset--font-family--transformers)', + ), - 'classnames' => 'has-text-color has-my-little-pony-color', + 'classnames' => 'has-text-color has-my-little-pony-color has-cabbage-patch-font-size has-transformers-font-family', ), ), @@ -513,18 +521,22 @@ public function data_wp_style_engine_get_styles() { 'inline_background_image_url_with_background_size' => array( 'block_styles' => array( 'background' => array( - 'backgroundImage' => array( + 'backgroundImage' => array( 'url' => 'https://example.com/image.jpg', ), - 'backgroundSize' => 'cover', + 'backgroundPosition' => 'center', + 'backgroundRepeat' => 'no-repeat', + 'backgroundSize' => 'cover', ), ), 'options' => array(), 'expected_output' => array( - 'css' => "background-image:url('https://example.com/image.jpg');background-size:cover;", + 'css' => "background-image:url('https://example.com/image.jpg');background-position:center;background-repeat:no-repeat;background-size:cover;", 'declarations' => array( - 'background-image' => "url('https://example.com/image.jpg')", - 'background-size' => 'cover', + 'background-image' => "url('https://example.com/image.jpg')", + 'background-position' => 'center', + 'background-repeat' => 'no-repeat', + 'background-size' => 'cover', ), ), ), diff --git a/tests/phpunit/tests/term/wpInsertTerm.php b/tests/phpunit/tests/term/wpInsertTerm.php index d99593b1d5f2e..798db9233bfc8 100644 --- a/tests/phpunit/tests/term/wpInsertTerm.php +++ b/tests/phpunit/tests/term/wpInsertTerm.php @@ -895,6 +895,19 @@ public function test_wp_insert_term_with_null_description() { $this->assertSame( '', $term_object->description ); } + /** + * @ticket 59995 + */ + public function test_wp_insert_term_with_empty_name_after_db_sanitization() { + $term = wp_insert_term( + '', + 'post_tag' + ); + + $this->assertWPError( $term ); + $this->assertSame( 'invalid_term_name', $term->get_error_code() ); + } + /** Helpers */ public function deleted_term_cb( $term, $tt_id, $taxonomy, $deleted_term, $object_ids ) { diff --git a/tests/phpunit/tests/theme.php b/tests/phpunit/tests/theme.php index cf5ea9ad6c208..a70bf9e7ff60a 100644 --- a/tests/phpunit/tests/theme.php +++ b/tests/phpunit/tests/theme.php @@ -1259,8 +1259,8 @@ function () use ( $new_root ) { // Cleanup. switch_theme( $old_theme->get_stylesheet() ); - $this->assertEquals( $old_root . '/test', $path1, 'The original stylesheet path is not correct' ); - $this->assertEquals( $new_root . '/test', $path2, 'The new stylesheet path is not correct' ); + $this->assertSame( $old_root . '/test', $path1, 'The original stylesheet path is not correct' ); + $this->assertSame( $new_root . '/test', $path2, 'The new stylesheet path is not correct' ); } /** @@ -1302,7 +1302,7 @@ function () use ( $new_root ) { // Cleanup. switch_theme( $old_theme->get_stylesheet() ); - $this->assertEquals( $old_root . '/test-parent', $path1, 'The original template path is not correct' ); - $this->assertEquals( $new_root . '/test-parent', $path2, 'The new template path is not correct' ); + $this->assertSame( $old_root . '/test-parent', $path1, 'The original template path is not correct' ); + $this->assertSame( $new_root . '/test-parent', $path2, 'The new template path is not correct' ); } } diff --git a/tests/phpunit/tests/theme/wpThemeJson.php b/tests/phpunit/tests/theme/wpThemeJson.php index 6da723583ba45..49e1661844b10 100644 --- a/tests/phpunit/tests/theme/wpThemeJson.php +++ b/tests/phpunit/tests/theme/wpThemeJson.php @@ -264,6 +264,7 @@ public function test_get_settings_appearance_true_opts_in() { $expected = array( 'background' => array( 'backgroundImage' => true, + 'backgroundSize' => true, ), 'border' => array( 'width' => true, @@ -300,6 +301,7 @@ public function test_get_settings_appearance_true_opts_in() { 'core/group' => array( 'background' => array( 'backgroundImage' => true, + 'backgroundSize' => true, ), 'border' => array( 'width' => true, diff --git a/tests/phpunit/tests/theme/wpThemeJsonResolver.php b/tests/phpunit/tests/theme/wpThemeJsonResolver.php index cc7cfa2f65238..dd5fff2bff8ef 100644 --- a/tests/phpunit/tests/theme/wpThemeJsonResolver.php +++ b/tests/phpunit/tests/theme/wpThemeJsonResolver.php @@ -433,6 +433,9 @@ public function data_get_core_data() { /** * @ticket 54336 + * @ticket 60118 + * + * @covers ::add_theme_support */ public function test_add_theme_supports_are_loaded_for_themes_without_theme_json() { switch_theme( 'default' ); @@ -455,15 +458,18 @@ public function test_add_theme_supports_are_loaded_for_themes_without_theme_json ); add_theme_support( 'editor-color-palette', $color_palette ); add_theme_support( 'custom-line-height' ); + add_theme_support( 'appearance-tools' ); $settings = WP_Theme_JSON_Resolver::get_theme_data()->get_settings(); remove_theme_support( 'custom-line-height' ); remove_theme_support( 'editor-color-palette' ); + remove_theme_support( 'appearance-tools' ); $this->assertFalse( wp_theme_has_theme_json() ); $this->assertTrue( $settings['typography']['lineHeight'] ); $this->assertSame( $color_palette, $settings['color']['palette']['theme'] ); + $this->assertTrue( $settings['border']['color'], 'Support for "appearance-tools" was not added.' ); } /**