Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Deprecate mysqli driver_version property
The driver version hasn't been updated in 13 years, so this number
is essentially meaningless. Check PHP_VERSION_ID instead.
  • Loading branch information
kamil-tekiela authored and nikic committed Mar 15, 2021
1 parent 11dbed9 commit 3dfd355
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
5 changes: 5 additions & 0 deletions UPGRADING
Expand Up @@ -212,6 +212,11 @@ PHP 8.1 UPGRADE NOTES
4. Deprecated Functionality
========================================

- MySQLi:
. The mysqli_driver::$driver_version property has been deprecated. The driver
version is meaningless as it hasn't been updated in more than a decade. Use
PHP_VERSION_ID instead.

========================================
5. Changed Functions
========================================
Expand Down
1 change: 1 addition & 0 deletions ext/mysqli/mysqli_driver.c
Expand Up @@ -78,6 +78,7 @@ static int driver_client_info_read(mysqli_object *obj, zval *retval, bool quiet)
/* {{{ property driver_driver_version_read */
static int driver_driver_version_read(mysqli_object *obj, zval *retval, bool quiet)
{
zend_error(E_DEPRECATED, "The driver_version property is deprecated");
ZVAL_LONG(retval, MYSQLI_VERSION_ID);
return SUCCESS;
}
Expand Down
3 changes: 2 additions & 1 deletion ext/mysqli/tests/mysqli_class_mysqli_driver_interface.phpt
Expand Up @@ -54,7 +54,6 @@ printf("driver->client_info = '%s'\n", $driver->client_info);
assert(mysqli_get_client_version() === $driver->client_version);
printf("driver->client_version = '%s'\n", $driver->client_version);

assert($driver->driver_version > 0);
printf("driver->driver_version = '%s'\n", $driver->driver_version);

assert(in_array($driver->report_mode, [
Expand Down Expand Up @@ -103,6 +102,8 @@ report_mode
Magic, magic properties:
driver->client_info = '%s'
driver->client_version = '%d'

Deprecated: The driver_version property is deprecated in %s on line %d
driver->driver_version = '%d'
driver->report_mode = '%d'
driver->reconnect = ''
Expand Down
5 changes: 0 additions & 5 deletions ext/mysqli/tests/mysqli_driver.phpt
Expand Up @@ -27,11 +27,6 @@ if (($tmp = $driver->client_version) !== $client_version) {
gettype($tmp), $tmp);
}

if (!is_int($tmp = $driver->driver_version) || (0 == $tmp)) {
printf("[004] Expecting int/any, got %s/%s\n",
gettype($tmp), $tmp);
}

$all_modes = [
MYSQLI_REPORT_ALL,
MYSQLI_REPORT_STRICT,
Expand Down

0 comments on commit 3dfd355

Please sign in to comment.