WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#20296 closed feature request (wontfix)

WP_Query implements Countable

Reported by: hakre Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch close
Focuses: Cc:

Description

Giving WP_Query the Countable interface would allow to deal with it more fluently the "PHP way".

Attachments (1)

20296.diff (656 bytes) - added by hakre 3 years ago.

Download all attachments as: .zip

Change History (8)

@hakre3 years ago

comment:1 @hakre3 years ago

Related: #20297

comment:2 @GaryJ3 years ago

  • Keywords close added

Although in the default compilation since PHP 5.0, until PHP 5.3 PHP can be compiled without the SPL, so it's not guaranteed to have the interface always present. I suspect that referencing a non-defined interface would cause a fatal error for those (few) that don't have the SPL compiled in PHP.

comment:3 follow-up: @johnbillion3 years ago

  • Keywords reporter-feedback added

Similarly to #20297, what is the use case for this? The patch as-is achieves nothing. If WP_Query is to implement the countable interface then your patch should include the corresponding code changes which take advantage of it, otherwise the change is pointless.

comment:4 @nacin3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Since SPL can be disabled, this is definitely wontfix. I will comment more on the idea in #20297.

comment:5 in reply to: ↑ 3 @hakre3 years ago

  • Keywords reporter-feedback removed

Replying to GaryJ:

Although in the default compilation since PHP 5.0, until PHP 5.3 PHP can be compiled without the SPL, so it's not guaranteed to have the interface always present. I suspect that referencing a non-defined interface would cause a fatal error for those (few) that don't have the SPL compiled in PHP.

There is more in PHP that can be disabled which will break Wordpress even the minimum requirements don't show that picture. So generally this would need a review whether or not PHP is commonly compiled without the SPL. That is commonly not the case, the SPL is available everywhere by default and it's safe to expect it that way.

Replying to johnbillion:

Similarly to #20297, what is the use case for this?

The usage is obvious I'd say. See PHP Manual for details of the interface.

comment:6 follow-up: @dd323 years ago

There is more in PHP that can be disabled which will break Wordpress even the minimum requirements don't show that picture.

Such as? Other than the MySQL extension, we've got back-compat functionality available for the (compiled by default) json and hmac components, and don't use several other default items which are often disabled.

SPL is, from memory, more commonly disabled than both the above.

comment:7 in reply to: ↑ 6 @hakre3 years ago

Replying to dd32:

Such as?

For example PCRE.

Version 0, edited 3 years ago by hakre (next)
Note: See TracTickets for help on using tickets.