Page MenuHomePhabricator

Remove old mysql extension support in favor of mysqli
Closed, ResolvedPublic

Description

Since we're about to drastically raise our PHP version requirements, we end up in the area where the old mysql extension used by DatabaseMysql is deprecated in favor of mysqli. After that, it is completely removed in PHP7 and HHVM. I therefore propose to first deprecate then remove the support for it.

Official documentation for PHP extension 'mysql'

Deprecated in MW 1.30 - to be decided if removed in MW 1.31 or later.

Extensions using DatabaseMysql (see CodeSearch):

  • ContributionReporting (in code)
    • Abandoned and unused, the old code haven't working even before that. No point in wasting time on this.
  • OdbcDatabase (in code) (I6c2c37b)
  • Wikibase (in tests) (Ice89b5a)
  • Echo (in tests) (I3150bcd)
  • Flow (in tests) (Ib24561d)
  • EducationProgram (in tests) (I7228c3a)
  • SemanticExtraSpecialProperties (in tests) (5ce8bdc during refactoring for 2.0 (still in alpha))
  • MathSearch (in comments for type hinting) (rEMAS9c316a4)

Details

Related Gerrit Patches:
mediawiki/core : masterRemove support for PHP extension 'mysql' (not mysqli!)
mediawiki/extensions/EducationProgram : masterDon't use deprecated DatabaseMysql
mediawiki/extensions/Echo : masterDon't use deprecated DatabaseMysql
mediawiki/extensions/Wikibase : masterDon't use deprecated DatabaseMysql
mediawiki/extensions/OdbcDatabase : masterDon't use deprecated DatabaseMysql
mediawiki/extensions/Flow : masterDon't use deprecated DatabaseMysql
mediawiki/core : masterSoft deprecation of DatabaseMysql
mediawiki/core : masterReplace mocks of DatabaseMysql by DatabaseMysqli

Event Timeline

MaxSem created this task.Dec 4 2015, 2:01 AM
MaxSem raised the priority of this task from to Needs Triage.
MaxSem updated the task description. (Show Details)
MaxSem added a subscriber: MaxSem.
Restricted Application added subscribers: StudiesWorld, Aklapper. · View Herald TranscriptDec 4 2015, 2:01 AM
Ricordisamoa added a subscriber: Ricordisamoa.
Aklapper renamed this task from Remove old mysql extension support to Remove old mysql extension support in favor of mysqli.Dec 4 2015, 12:32 PM
Aklapper set Security to None.
Danny_B moved this task from Unsorted to PHP 7 on the [DO NOT USE] NewPHP board.May 9 2016, 12:15 AM
Seb35 added a subscriber: Seb35.Aug 9 2016, 8:38 PM

I guess there is no much suspense about removing support for the PHP extension mysql since:

  • mysqli is supported since MediaWiki 1.22
  • mysqli is automatically selected in Database::factory() since MediaWiki 1.22
  • mysqli is very standard in PHP installations
  • to explicitely select the driver mysql, you can, but you have to use the advanced variable $wgDBservers with the option 'driver' => 'mysql', which is documented neither in DefaultSettings.php neither on MediaWiki.org
  • as said, mysql is deprecated since PHP 5.5 and removed in PHP 7.0
  • PHP 5.6 emits a warning at runtime when mysql is used: in the MediaWiki class DatabaseBase (with var_dump): ["mPHPError":protected]=>string(111) "mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead" (although I don’t know in which log is written this warning)

As you said, it is probably more polite to first deprecate it, probably in MediaWiki 1.28, and possibly remove it in MediaWiki 1.29 or 1.30.

Seb35 claimed this task.Dec 30 2016, 2:06 PM

Ok, I try to follow the process in the soon-official RfC Deprcation policy T146965.

First, as stated by my comment above, only a very explicit will leads to activating the 'mysql' driver in MediaWiki, non-action auto-selects the 'mysqli' driver. Additionnally, PHP extension 'mysql' is removed in PHP 7.0 and PHP extension 'mysqli' exists since PHP 5.0 (ref).

I searched the words « 'mysql' » and « driver » in the core and extensions in Wikimedia repository, as well as in (public) operations and integration repositories (to search jointly I used: grep -C 10 mysql | grep -C 5 driver). Found:

  • some translations of message 'config-no-db' mention "./configure --with-mysql" although the original message is "./configure --with-mysqli", fixed in translatewiki for all non-fuzzy messages;
  • includes/libs/rdbms/database/Database.php: method factory, the 'mysql' driver will be removed in code and method docblock ('mysqli' driver MUST be kept, else MediaWiki would fallback to the class DatabaseMysql which is under deprecation);
  • includes/libs/rdbms/database/DatabaseMysqli.php: this file will be removed;
  • includes/installer/MysqlInstaller.php: method isCompiled, remove self::checkExtension( 'mysql' )

In operations/puppet/modules/mariadb/files/pt-heartbeat-wikimedia: function get_cxn_params, there are the words "driver" and "mysql"; I think it is a false alert, but I mention here to double-check.

I submit a patch to hard-deprecate the class. I wrote inside it will be removed in MediaWiki 1.31 LTS (according to the meaning of @deprecated from the in-draft PSR-5), it can be changed to MediaWiki 1.30 (sooner would violate the RfC Deprecation policy).

Seb35 triaged this task as Medium priority.Dec 30 2016, 2:07 PM
Seb35 added a comment.Dec 30 2016, 3:09 PM

I also researched DatabaseMysql (the class name which will be removed) and mysql_ (the functions of the PHP extension mysql).

Class DatabaseMysql: (should be removed during deprecation period)
MediaWiki core:

  • tests/phpunit/includes/utils/BatchRowUpdateTest.php (mock)
  • tests/phpunit/includes/db/LBFactoryTest.php (mock)
  • tests/phpunit/includes/db/DatabaseMysqlBaseTest.php (mock)
  • tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php (mock)
  • tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php (mock)
  • includes/libs/rdbms/database/Database.php (in a comment)

Extensions:

  • in code: ContributionReporting, MWSearch, OdbcDatabase, WikiFarm
  • in tests: Echo, EducationProgram, Flow, Wikibase, Wikidata
  • in a comment: MathSearch

Functions mysql_*: (for information linked to this task)

  • nothing in MediaWiki core
  • used in extensions BlueSpiceFoundation, WikidataEntitySuggester, WikiLexicalData, WikiFarm
  • written in comments elsewhere

Given it is in tests in MediaWiki core and in ContributionReporting (which is in WMF config, although it seems to be non-activated), the change I will propose is only a soft-deprecation.

Change 329682 had a related patch set uploaded (by Seb35):
Soft deprecation of DatabaseMysql

https://gerrit.wikimedia.org/r/329682

Change 329764 had a related patch set uploaded (by Seb35):
Replace mocks of DatabaseMysql by DatabaseMysqli

https://gerrit.wikimedia.org/r/329764

The two patches in mediawiki/core are independent, as long as there is no hard-deprecation or removal.

Change 329764 merged by jenkins-bot:
Replace mocks of DatabaseMysql by DatabaseMysqli

https://gerrit.wikimedia.org/r/329764

we could possibly do this for mw 1.30 or mw 1.31? We should have one last lts release that supports this extension, then remove support for it entirely + bump minimum db requirement.

Depends if we want to support this during 1.31 LTS or not. I’m not sure what benefits there are in keeping it in this LTS, though.

Seb35 added a subscriber: jcrespo.Mar 2 2017, 5:17 PM

@jcrespo: Is the 'mysql' PHP extension used on WMF servers? Any preference/advice in keeping it for the next LTS?

jcrespo added a comment.EditedMar 2 2017, 5:37 PM

I am probably the wrong person to be asked this, I am not familiar with the WMF app server configuration, that should be checked on the operations/mediawiki-config repo.

And regarding release planing, that probably should probably be a decision for release engineering with input from mediawiki stakeholders and security? I am not sure, and I may be wrong here. I would expect production to use mysqli long time ago, but maybe something at CI/beta uses both PHP and mysql?

MaxSem added a comment.Mar 2 2017, 5:53 PM

@jcrespo: Is the 'mysql' PHP extension used on WMF servers? Any preference/advice in keeping it for the next LTS?

We mostly use HHVM which doesn't have mysql at all. For some cases, PHP 5.5 is still used and it has both mysql and mysqli, from them mysqli is always used by MediaWiki.

Seb35 updated the task description. (Show Details)Aug 5 2017, 6:56 PM
Reedy added a project: Operations.EditedAug 5 2017, 8:01 PM
Reedy added a subscriber: Reedy.

We should probably make a move on this...

However, if we look at WMF production where we're still using php5 rather than hhvm...

Do we presume dumps etc are similar?

reedy@silver:~$ dpkg -l | grep php5-mysql
ii  php5-mysql                           5.5.9+dfsg-1ubuntu4.21                     amd64        MySQL module for php5
reedy@silver:~$ dpkg -l | grep mysqli
reedy@silver:~$
Reedy added a comment.Aug 5 2017, 8:10 PM

Though... Why?

> echo extension_loaded( 'mysql' );
1
> echo extension_loaded( 'mysqli' );
1
Paladox added a comment.EditedAug 5 2017, 8:51 PM

php5-mysql has mysqli. i see no packages with the name php5-mysqli in debian https://packages.debian.org/jessie/php5-mysqli

@Paladox is right, php5-mysql is the generic package name for mysql support on PHP, it bundles (or at least, it used to) all non-generic connector (old and improved), except the native one: https://packages.debian.org/jessie/amd64/php5-mysql/filelist . In fact, after dropping the mysql package, it is still called mysql: https://packages.debian.org/stretch/amd64/php7.0-mysql/filelist

Change 329682 merged by jenkins-bot:
[mediawiki/core@master] Soft deprecation of DatabaseMysql

https://gerrit.wikimedia.org/r/329682

Seb35 changed the task status from Open to Stalled.Aug 28 2017, 9:28 PM
Seb35 updated the task description. (Show Details)
Seb35 updated the task description. (Show Details)Jan 16 2018, 6:44 PM

Change 404522 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/Echo@master] Don't use deprecated DatabaseMysql

https://gerrit.wikimedia.org/r/404522

Seb35 added a comment.Jan 16 2018, 7:02 PM

I wrote the patch to remove DatabaseMysql and tried to find everywhere where there is a link with the driver mysql, but obviously there is an homonymy with the type mysql. I found occurences in multiple extensions, often in tests but some in the code itself; there also some extensions which directly use the functions mysql_* but it is out of scope of this task.

I suggest we try to fix the extensions as far as possible and decide in some months if this patch is included in 1.31 (LTS) or later.

Change 404523 had a related patch set uploaded (by Seb35; owner: Seb35):
[mediawiki/core@master] Remove support for PHP extension 'mysql' (not mysqli!)

https://gerrit.wikimedia.org/r/404523

Seb35 changed the task status from Stalled to Open.Jan 16 2018, 7:19 PM
MaxSem updated the task description. (Show Details)Jan 16 2018, 7:23 PM

Change 404537 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/EducationProgram@master] Don't use deprecated DatabaseMysql

https://gerrit.wikimedia.org/r/404537

Seb35 updated the task description. (Show Details)Jan 16 2018, 9:29 PM

Change 404541 had a related patch set uploaded (by Seb35; owner: Seb35):
[mediawiki/extensions/Flow@master] Don't use deprecated DatabaseMysql

https://gerrit.wikimedia.org/r/404541

Change 404543 had a related patch set uploaded (by Seb35; owner: Seb35):
[mediawiki/extensions/OdbcDatabase@master] Don't use deprecated DatabaseMysql

https://gerrit.wikimedia.org/r/404543

Seb35 updated the task description. (Show Details)Jan 16 2018, 9:50 PM
Seb35 updated the task description. (Show Details)Jan 16 2018, 10:46 PM

Change 404541 merged by jenkins-bot:
[mediawiki/extensions/Flow@master] Don't use deprecated DatabaseMysql

https://gerrit.wikimedia.org/r/404541

Seb35 updated the task description. (Show Details)Jan 16 2018, 11:43 PM

Change 404543 merged by jenkins-bot:
[mediawiki/extensions/OdbcDatabase@master] Don't use deprecated DatabaseMysql

https://gerrit.wikimedia.org/r/404543

Seb35 updated the task description. (Show Details)Jan 17 2018, 12:17 AM

Change 404712 had a related patch set uploaded (by Seb35; owner: Seb35):
[mediawiki/extensions/Wikibase@master] Don't use deprecated DatabaseMysql

https://gerrit.wikimedia.org/r/404712

Seb35 updated the task description. (Show Details)Jan 17 2018, 4:33 PM

Change 404712 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Don't use deprecated DatabaseMysql

https://gerrit.wikimedia.org/r/404712

Jdforrester-WMF updated the task description. (Show Details)
Jdforrester-WMF updated the task description. (Show Details)

Change 404522 merged by jenkins-bot:
[mediawiki/extensions/Echo@master] Don't use deprecated DatabaseMysql

https://gerrit.wikimedia.org/r/404522

Change 404537 merged by jenkins-bot:
[mediawiki/extensions/EducationProgram@master] Don't use deprecated DatabaseMysql

https://gerrit.wikimedia.org/r/404537

Change 404523 merged by jenkins-bot:
[mediawiki/core@master] Remove support for PHP extension 'mysql' (not mysqli!)

https://gerrit.wikimedia.org/r/404523

MaxSem closed this task as Resolved.Jan 17 2018, 7:14 PM

Weee!