WordPress.org

Make WordPress Core

Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#20296 closed feature request (wontfix)

WP_Query implements Countable

Reported by: hakre Owned by:
Priority: normal Milestone:
Component: General Version:
Severity: normal Keywords: has-patch close
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 15 months ago.

Download all attachments as: .zip

Change History (8)

hakre15 months ago

comment:1 hakre15 months ago

Related: #20297

comment:2 GaryJ15 months 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: johnbillion15 months 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 nacin15 months 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 hakre15 months 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: dd3215 months 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 hakre15 months ago

Replying to dd32:

Such as?

For example PCRE.

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

SPL more often disabled than json? Never encountered that, but well, memory indeed can serve wrong, before introducing that a metric should be run first, good old Json has taught that lesson in the past (#16918, #18015).

Last edited 15 months ago by hakre (previous) (diff)
Note: See TracTickets for help on using tickets.