Automattic / VIP-Coding-Standards

PHP_CodeSniffer ruleset to enforce WordPress VIP coding standards.

Home Page:https://wpvip.com/documentation/how-to-install-php-code-sniffer-for-wordpress-com-vip/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sniff for using PDO to connect to DB

ross-mulcahy opened this issue · comments

What problem would the enhancement address for VIP?

The PDO_MYSQL module is not enabled on VIP. Plugins reliant on PDO like MailPoet are therefore currently not compatible with VIP.

Describe the solution you'd like

An error should be thrown on an attempt to create a PDO connection.

What code should be reported as a violation?

$db = new PDO();

What code should not be reported as a violation?

Any attempt to use PDO should be reported.

The upstream WPCS repo already has a sniff which does this: WordPress.DB.RestrictedClasses: https://github.com/WordPress/WordPress-Coding-Standards/blob/develop/WordPress/Sniffs/DB/RestrictedClassesSniff.php