WordPress.org

Making WordPress.org

#3551 closed defect (fixed)

Plugin Directory: Requires PHP: Standardise on values

Reported by: dd32 Owned by: dd32
Milestone: Priority: normal
Component: Plugin Directory Keywords: needs-patch
Cc:

Description

Following on from #2952 a lot of plugins have started implementing the Requires PHP header.

Unfortunately, a lot of them are not following any form of computer-readable standard.

For example, a quick selection:

PHP 4
Yes
5.3+
4.6 or greater
5.6 or later
4 & 5
5+
5.6 or 7.0
4
5.6 or higher
>= 5.4
5.4 and higher
4,5
5.4+
(PHP 5.6 + libsodium extension) or (PHP 7.2 or above)

(Yes, some plugins have specified they're PHP 4 compatible, I doubt they are)

A quick look suggests that 2,715 plugins have specified a sane identifier (x.y, or x.y.z) with a further 156 plugins specifying it in ways such as the above list which make it harder to pragmatically use.

I'd recommend that we validate the number in some form in the readme parser to make the data more useful long term.
I'd suggest

  • Require the version number be specified as x.y or x.y.z
  • If Other data is in there, pull out the first version-like string, ie. 5.3 from 5.3+, 5.3 or greater, or 5.3-7.1. Based on existing data, it looks like that should be fine.
  • Add a warning to the readme validator when unexpected values are encountered and note if it's truncated/sanitised to something reasonable.

Change History (4)

#1 @danieltj
18 months ago

My opinion on this - take it as you will is to require a valid version number - as you stated; x.y or x.y.z and if invalid, don't show this requires header at all. This would all only correct and relevant data to be shown here.

#2 follow-up: @Otto42
18 months ago

They do much the same for the Requires at least: and Tested up to: headers.

I say we simply ignore anything that looks unlike a version number. If they have anything else there, then the header is completely ignored. Force the issue.

#3 in reply to: ↑ 2 @dd32
18 months ago

Replying to Otto42:

They do much the same for the Requires at least: and Tested up to: headers.

That's what caused me to take a sanity look at the Requires data :)

I say we simply ignore anything that looks unlike a version number. If they have anything else there, then the header is completely ignored. Force the issue.

It seems like that's the consensus, so yeah, lets just ignore any non-version data and throw a warning in the validator then.

#4 @dd32
18 months ago

  • Owner set to dd32
  • Resolution set to fixed
  • Status changed from new to closed

In 7049:

Plugin Directory: Readme: Ignore invalid Requires PHP headers and add a parsing warning clarifying the expected contents.

Fixes #3551.

Note: See TracTickets for help on using tickets.