Make WordPress Core

Opened 17 months ago

Last modified 7 months ago

#56709 new defect (bug)

Encountered a problem that no one has ever met Please help me

Reported by: qq2094629698's profile qq2094629698 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Formatting Keywords: dev-feedback php80 reporter-feedback
Focuses: Cc:

Description (last modified by davidbaumwald)

As usual, I used the element to update the page. After clicking the update button, I clicked the update button for a few more times, and this problem occurred. The contents of my page were all gone, leaving only one line of errors, (Warning: count(): Parameter must be an array or an object that implements Countable in/www/wwwroot/www.xxxx.com/wp-includes/formatting.php on line 3415)And the same is true for publishing new pages. Please help me, thank you!

I used to update the page several times every month. It used to be normal, but the problem didn't appear until today

Change History (4)

#1 @davidbaumwald
17 months ago

  • Component changed from Bootstrap/Load to Formatting
  • Description modified (diff)
  • Focuses ui accessibility javascript coding-standards removed
  • Keywords dev-feedback added
  • Severity changed from major to normal
  • Version 6.0.2 deleted

Hi @qq2094629698 and welcome to WordPress Trac! I did a search for this specific report, and I cannot find one that matches up exactly. So, thank you for reporting this! I am updating the ticket details for better discoverability for other contributors and users who may experience the same issue.

Tracing this in the 6.0 branch, this seems to point to https://core.trac.wordpress.org/browser/branches/6.0/src/wp-includes/formatting.php#L3415 which does implement count on a variable that could indeed be false.

Paging @jrf to see if this should be treated any differently than other type validation fixes(e.g. #54827) or attempt to track down at the source of where convert_smilies is being called.

If this requires a similar solution to #54827, we can also tag this with good-first-bug and needs-patch.

#2 @jrf
17 months ago

  • Keywords php8 added

Thanks for looping me in @davidbaumwald.

I have seen numerous similar issues, including with the convert_smilies() function, and they are 100% of the time caused by an incorrect call to this function, so this needs a backtrace to figure out where this is coming from.

Tracing this in the 6.0 branch, this seems to point to https://core.trac.wordpress.org/browser/branches/6.0/src/wp-includes/formatting.php#L3415 which does implement count on a variable that could indeed be false.

The thing is, it will actually be pretty hard to get this error, even when passing invalid input.
The preg_split() doesn't easily return false. AFAIK, this will only happen when the regex is faulty (which it isn't) and would then be accompanied by a warning about the error in the regex, see: https://3v4l.org/N3t8W

@qq2094629698 Aside from the backtrace, could you please also mention in your reply:

  • The version of WordPress you are using (to confirm we're actually looking at the right call to count().
  • The version of PHP your site is running on.
  • Test whether you can still reproduce the error with a WP native theme and all plugins turned off ?

#3 @svgator
9 months ago

Here is a link to a bug report describing the issue in more detail:
https://core.trac.wordpress.org/ticket/58406

#4 @hellofromTonya
7 months ago

  • Keywords php80 reporter-feedback added; php8 removed

Ticket changes:

  • Added reporter-feedback as a response from @qq2094629698 is needed to investigate further.
  • Changed the php8 keyword to php80 to denote that in PHP 8.0 the Warning would change to Fatal.

Need more information

@svgator is this ticket the same as #58406? If yes, 58406 as a duplicate of this ticket.

@qq2094629698 can you please provide the following information @jrf requested:

Aside from the backtrace, could you please also mention in your reply:

  • The version of WordPress you are using (to confirm we're actually looking at the right call to count().
  • The version of PHP your site is running on.
  • Test whether you can still reproduce the error with a WP native theme and all plugins turned off ?

The information can help contributors produce the reported issue and investigate.

Is this a PHP 8.0 incompatibility?

Reviewed this ticket to determine if it is an incompatibility with PHP 8.0 and should be listed in the known incompatibilities for WP 6.3.

Findings: no, not with the current information provided. Thus, the php-compatibility focus should not be added to the ticket.

Note: See TracTickets for help on using tickets.