Make WordPress Core

#64174 closed defect (bug) (wontfix)

deprecation notice for conditional scripts

Reported by: hupe13 Owned by:
Priority: normal Milestone:
Component: Script Loader Version: 6.9
Severity: normal Keywords:
Cc: Focuses: javascript, css

Description (last modified by sabernhardt)

WordPress 6.9 beta 2, php 8.3

If is defined in wp-config.php:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );

I get a php warning:

PHP Deprecated: Function WP_Dependencies-&gt;add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers. in /.../wp-includes/functions.php on line 6131

Change History (8)

#1 @sabernhardt
13 months ago

  • Description modified (diff)
  • Focuses php-compatibility removed
  • Keywords close added
  • Summary WP_DEBUG and WP_DEBUG_LOG → deprecation notice for conditional scripts

The message is intentionally added to tell theme and plugin developers that core deprecated the 'conditional' argument for scripts and styles in #63821. When the active theme and/or a plugin registers an outdated script, WP_DEBUG will show or log the message.

I'll use the 'close' keyword but leave the ticket open. According to comment:29:ticket:63821

We can always commit with deprecation notices, and if they raise too many flags during beta/RC we can remove it.

#2 @sabernhardt
13 months ago

  • Keywords 2nd-opinion added; close removed

I have not found any other complaints yet, but I want to suggest keeping the deprecation notices until one of the late release candidates.

That way, more theme and plugin authors can know that scripts should not have the conditional argument (or depend on such scripts). However, if the script registration is not changed before general release, removing the notice could avoid adding noise for end users who check their sites with debug before updating (and for the extenders who have higher-priority issues to fix).

#3 @WFMattR
12 months ago

I saw the same issue -- it seems to be caused by some of the older themes, possibly twentyeleven through twentyseventeen. For example, a few lines in twentyseventeen's functions.php:

wp_style_add_data( 'twentyseventeen-ie9', 'conditional', 'IE 9' );

wp_style_add_data( 'twentyseventeen-ie8', 'conditional', 'lt IE 9' );

wp_script_add_data( 'html5', 'conditional', 'lt IE 9' );

The message occurs when viewing the front end. When I switch to a newer theme like twentytwentyfour, the deprecation message is not logged.

#4 @hupe13
12 months ago

It's my test page and I don't always work on it. I just made the updates (WP 6.9 beta 4). When I tested it now, there is no warning anymore. The active theme is GeneratePress. The oldest installed theme is Twenty Twenty-One.

#5 @sabernhardt
12 months ago

  • Keywords needs-patch added
  • Milestone Awaiting Review → 6.9

T13, T15 and T17 stopped enqueueing the conditional scripts two years ago (#56699), and T11 did not enqueue any of them. If you update T12, T14 or T16 before updating WordPress, you should not have the conditional scripts enqueued because of #58836. However, child themes of any of these might enqueue the scripts. Plus many other classic themes could have conditional scripts, with or without a child theme.

@edge22 added comment:44:ticket:63821, suggesting

Maybe it's better handled silently (or logged only when SCRIPT_DEBUG is enabled), instead of surfacing as a _doing_it_wrong() notice.

#6 @peterwilsoncc
12 months ago

  • Focuses javascript css added

I've been going back and forth on this, and will probably continue to.

Ultimately, I don't think it's wise to suppress the errors and silently deprecate as it's very important developers be aware that their scripts and styles are not been enqueued if they have IE conditional data.

Only calling _deprecated_argument() if SCRIPT_DEBUG is enabled would be problematic for development plugins, such as Query Monitor, as the notice would be suppressed from them too as they typically use the deprecated_argument_run hook to collect messages.

If deprecated_argument_trigger_error and related filters passed the $function_name, $version, $message = '' arguments, it might be possible to use SCRIPT_DEBUG on the filter but it's a little too late to add that for the 6.9 cycle.

tl;dr: I think it's best to close this ticket as unplanned/wontfix.

#7 @jorbin
12 months ago

  • Keywords close added

My thoughts are aligned with @peterwilsoncc on this. I think the benefit of notifying developers and helping them use modern best practices is more important than unexpected output because some sites have error display enabled.

I would also be in favor of closing this as wontfix.

#8 @desrosj
12 months ago

  • Component General → Script Loader
  • Keywords 2nd-opinion needs-patch close removed
  • Milestone 6.9
  • Resolution → wontfix
  • Status new → closed

Thanks everyone for the discussion on this one!

I agree that these notices should not be suppressed. Going to close this one out.

Note: See TracTickets for help on using tickets.