Make WordPress Core

Opened 14 months ago

Last modified 9 months ago

#48116 new enhancement

Proposal: Tracking PHP Extension Usage

Reported by: dd32 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Upgrade/Install Keywords: 2nd-opinion dev-feedback has-patch
Focuses: Cc:


WordPress.org currently tracks the PHP usage of the platform and a bunch of other details, but one data point that's been needed time and time again is PHP Extension usage.

While we have some data sources which we refer to sometimes (VaultPress, Hosting Test Runner) these don't necessarily represent the very broad and varied hosting environments that WordPress runs on, as evidenced in the past by having to guess and revert/make changes based on bug reports afterwards.

WordPress can't be the only project that would benefit from knowing what ~34% of the web is running either, we're positioned in a very good place to influence other projects and PHP itself.
It could also give some direction to the Site Health project as to what segment of users it should potentially target with extra warnings.

Some decisions that rely upon knowing what PHP extensions are in use include..

  • #47699 Can we drop the JSON Extension polyfill?
  • #35517 Should the SSH endpoint even be in core since it's been broken for 3 year for some (most?) users
  • #17268 Can we use the native gettext extension to improve translation speed?
  • Do we still need to support the MySQL PHP extension? Can we just rely upon MySQLi?
  • #42352 Can we add support for proper prepared queries based on MySQLi? Do we need to think about ext/MySQL support? (And is PDO an option?)
  • #47186 How many users are using 32bit PHP without the libSodium Extension installed? (How wide spread is libSodium in the first place?)

I brought this up back in May on Slack and there wasn't any significant concerns raised, so I've finally made this ticket - if we can start sending the data from core I can get the API side storing data and we can find a way to publish the data for all to use as needed in these decisions.

The attached patch is just a quick POC, I'm not sure if there's anything else that should be included (or shouldn't be) but it could include other things like the following in the platform_flags section:

  • 'db' => defined( 'WP_USE_EXT_MYSQL' ) && WP_USE_EXT_MYSQL ? 'mysql_forced' : ( function_exists( 'mysqli_connect') ? 'mysqli' : 'mysql' ) to determine MySQL vs MySQLi usage
  • 'db_class' => get_class( $wpdb ) to detect the usage of other Database droppins
  • web server in use based on the $is_apache, $is_IIS, $is_iis7, $is_nginx globals

On the privacy side of this - The new elements pass through the core_version_check_query_args filter that exists to opt-out of sending this data, and it doesn't contain personal details, so when used and processed in aggregate it should be okay.

Note: Any API would simply be aggregate percentages of an unknown total, ie. { platform: { bits: { 32: 50.5, 64: 49.5 } }, extensions: { json: 99.999, mysqli: 95.4, mysql: 45.2, .... } }

Attachments (1)

48116.diff (637 bytes) - added by dd32 14 months ago.

Download all attachments as: .zip

Change History (8)

14 months ago

#1 @dd32
14 months ago

There's also the potential that maybe we'd want to record the versions of the extensions loaded, ie:

$extensions = array_combine( get_loaded_extensions(), array_map( 'phpversion', get_loaded_extensions() ) );

results in something like this on PHP 7.3.3:

  'xmlreader' => string '7.3.3' (length=5)
  'xmlwriter' => string '7.3.3' (length=5)
  'mysqlnd' => string 'mysqlnd 5.0.12-dev - 20150407 - $Id: 7cc7cc96e675f6d72e5cf0f267f48e167c2abb23 $' (length=79)
  'cgi-fcgi' => boolean false
  'gd' => string '7.3.3' (length=5)
  'mysqli' => string '7.3.3' (length=5)
  'xdebug' => string '2.7.0' (length=5)

#2 @desrosj
14 months ago

  • Keywords has-patch added

This ticket was mentioned in Slack in #hosting-community by jadonn. View the logs.

14 months ago

This ticket was mentioned in Slack in #hosting-community by mike. View the logs.

14 months ago

This ticket was mentioned in Slack in #hosting-community by amykamala. View the logs.

14 months ago

#6 @mikeschroder
14 months ago

I've mentioned this outside of the ticket, but wanted to mention I think it'd be great if we started tracking availability of PHP extensions for all of the reasons mentioned in the ticket description.

Thanks @dd32!

This ticket was mentioned in Slack in #hosting-community by skithund. View the logs.

9 months ago

Note: See TracTickets for help on using tickets.