rfc:pdo_driver_specific_subclasses

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:pdo_driver_specific_subclasses [2023/06/13 16:45] danackrfc:pdo_driver_specific_subclasses [2024/02/12 14:24] (current) derick
Line 3: Line 3:
   * Date: 2022-06-20    * Date: 2022-06-20 
   * Author: Danack   * Author: Danack
-  * Status: Under Discussion+  * Status: Implemented
   * First Published at: https://wiki.php.net/rfc/pdo_driver_specific_subclasses   * First Published at: https://wiki.php.net/rfc/pdo_driver_specific_subclasses
 +  * Target: PHP 8.4
  
  
Line 136: Line 137:
      * @cname SQLITE_DETERMINISTIC      * @cname SQLITE_DETERMINISTIC
      */      */
-    public const SQLITE_DETERMINISTIC = UNKNOWN;+    public const DETERMINISTIC = UNKNOWN;
  
     /**     /**
Line 142: Line 143:
      * @cname SQLITE_ATTR_OPEN_FLAGS      * @cname SQLITE_ATTR_OPEN_FLAGS
      */      */
-    public const SQLITE_ATTR_OPEN_FLAGS = UNKNOWN;+    public const ATTR_OPEN_FLAGS = UNKNOWN;
  
     /**     /**
Line 148: Line 149:
      * @cname SQLITE_OPEN_READONLY      * @cname SQLITE_OPEN_READONLY
      */      */
-    public const SQLITE_OPEN_READONLY = UNKNOWN;+    public const OPEN_READONLY = UNKNOWN;
  
     /**     /**
Line 154: Line 155:
      * @cname SQLITE_OPEN_READWRITE      * @cname SQLITE_OPEN_READWRITE
      */      */
-    public const SQLITE_OPEN_READWRITE = UNKNOWN;+    public const OPEN_READWRITE = UNKNOWN;
  
     /**     /**
Line 160: Line 161:
      * @cname SQLITE_OPEN_CREATE      * @cname SQLITE_OPEN_CREATE
      */      */
-    public const SQLITE_OPEN_CREATE = UNKNOWN;+    public const OPEN_CREATE = UNKNOWN;
  
     /**     /**
Line 166: Line 167:
      * @cname SQLITE_ATTR_READONLY_STATEMENT      * @cname SQLITE_ATTR_READONLY_STATEMENT
      */      */
-    public const SQLITE_ATTR_READONLY_STATEMENT = UNKNOWN;+    public const ATTR_READONLY_STATEMENT = UNKNOWN;
  
     /**     /**
Line 172: Line 173:
      * @cname      * @cname
      */      */
-    public const SQLITE_ATTR_EXTENDED_RESULT_CODES = UNKNOWN;+    public const ATTR_EXTENDED_RESULT_CODES = UNKNOWN;
  
     // Registers an aggregating User Defined Function for use in SQL statements     // Registers an aggregating User Defined Function for use in SQL statements
Line 203: Line 204:
         int $rowid,         int $rowid,
         ?string $dbname = "main", //null,         ?string $dbname = "main", //null,
-        int $flags = PdoSqlite::SQLITE_OPEN_READONLY+        int $flags = PdoSqlite::OPEN_READONLY
     ): mixed /* resource|false */ {}     ): mixed /* resource|false */ {}
 } }
Line 209: Line 210:
  
  
-Although there may be DB specific functionality that could be exposed for the other database types that PDO support, this RFC does not intend to expose them.+Although there may be DB specific functionality that could be exposed for the other database types that PDO supports, this RFC does not intend to expose them.
  
 ==== Add a way of creating them through PDO static factory method ==== ==== Add a way of creating them through PDO static factory method ====
Line 241: Line 242:
 The code will throw an exception if the type of database being connected to isn't of the correct type for the class. The code will throw an exception if the type of database being connected to isn't of the correct type for the class.
  
 +
 +==== Sqlite Extension directory ini setting ====
 +
 +The Sqlite3 extension requires users to set an ini setting to allow SQLite extensions to be loaded, presumably from a desire to keep things 'secure'. However, as this appears to only be a vulnerability if someone is able to upload and execute PHP code on a server, in which case the box is completely compromised any way, it doesn't seem to be necessary.
 +
 +Additionally, in the proposed PdoSqlite class this code:
 +
 +<code c>
 +sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1);
 +</code>
 +
 +is used to temporarily enable extension loading, before loading the extension, which only enables it through the C api, whereas the Sqlite3 extension uses the code:
 +
 +<code c>
 +sqlite3_enable_load_extension(sqlite_handle, 1);
 +</code>
 +
 +which affects both the C api and loading extensions through SQL code.
  
  
Line 263: Line 282:
 These are the known current issues. These are the known current issues.
  
-==== Sqlite Extension directory ini setting ==== 
  
-The Sqlite3 extension requires users to set an ini setting to allow SQLite extensions to be loaded, presumably from a desire to keep things 'secure'. However, as this appears to only be a vulnerability if someone is able to upload and execute PHP code on a server, in which case the box is completely compromised any way, it doesn't seem to be necessary.+===== Unaffected PHP Functionality =====
  
-Additionally, in the proposed PdoSqlite class this code:+Everything not PDO
  
-<code c> +===== Frequently asked questions =====
-sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1); +
-</code>+
  
-is used to temporarily enable extension loading, before loading the extension, which only enables it through the C api, whereas the Sqlite3 extension uses the code:+==== if someone does 'new PDO(...)' will they now get back 'PdoPgsql' ==== 
  
-<code c> +No.
-sqlite3_enable_load_extension(sqlite_handle, 1); +
-</code>+
  
-which affects both the C api and loading extensions through SQL code. +===== Future Scope =====
- +
- +
-TODO - check whether an absolute path is needed.+
  
 ==== When to deprecate old function on PDO ==== ==== When to deprecate old function on PDO ====
  
-The method PDO::sqliteCreateFunction should probably be deprecated and removed at 'some point'. Although this cleanup should happen, the position of this RFC is that it's very low priority+The method PDO::sqliteCreateFunction and other driver specific methods should probably be deprecated and removed at 'some point'. Although this cleanup should happen, the position of this RFC is that it's very low priority, as that code has sat there for years not requiring much maintainance.
- +
-  * 8.3 - PDO subclassses become available  +
-  * 9.0 - calls to PDO::sqliteCreateFunction start raising deprecation notice.  +
-  * 10.0 - driver specific methods and constants on PDO are removedand that functionality can only be accessed through the driver specific class.+
  
 Removing the methods that magically exist or not depending on the specific driver created would save some complication in the PDO code. So although there's no benefit in userland for deprecating the existing magic methods, there may be a complexity saving in maintenance. Removing the methods that magically exist or not depending on the specific driver created would save some complication in the PDO code. So although there's no benefit in userland for deprecating the existing magic methods, there may be a complexity saving in maintenance.
  
 +Choosing the version for them to be deprecated in can be left until the future.
  
-===== Unaffected PHP Functionality ===== 
- 
-Everything not PDO 
- 
-===== Future Scope ===== 
  
 ==== Quoting identifiers ==== ==== Quoting identifiers ====
Line 327: Line 330:
 Accept the RFC or not. Accept the RFC or not.
  
-===== Patches and Tests =====+<doodle title="PDO driver specific subclasses" auth="Danack" voteType="single" closed="false" closeon="2023-07-17T17:00:00Z"> 
 +   * Yes 
 +   * No 
 +</doodle>
  
-WIP code https://github.com/php/php-src/pull/8707+Voting closes at 2023-07-17T17:00:00Z
  
 +===== Patches and Tests =====
 +
 +https://github.com/php/php-src/pull/12804
 +https://github.com/php/php-src/pull/8707 (superseded version)
  
 ===== Implementation ===== ===== Implementation =====
-After the project is implemented, this section should contain  + 
-  - the version(s) it was merged into +Implemented for PHP 8.4 (https://github.com/php/php-src/commit/d6a0b3af68a55836ad7d24d4d832898c5b8c2d8e).
-  a link to the git commit(s) +
-  - a link to the PHP manual entry for the feature +
-  - a link to the language specification section (if any)+
  
 ===== References ===== ===== References =====
  
-proprosal to add [[rfc:implement_sqlite_openblob_in_pdo|sqlite openblob functionality]] previously failed to pass. The discussion gave the impression that the sub-classing [[ https://externals.io/message/100773#100813|approach would be more acceptable]].+proposal to add [[rfc:implement_sqlite_openblob_in_pdo|sqlite openblob functionality]] previously failed to pass. The discussion gave the impression that the sub-classing [[ https://externals.io/message/100773#100813|approach would be more acceptable]].
  
 ===== Rejected Features ===== ===== Rejected Features =====
  
 Keep this updated with features that were discussed on the mail lists. Keep this updated with features that were discussed on the mail lists.
rfc/pdo_driver_specific_subclasses.1686674749.txt.gz · Last modified: 2023/06/13 16:45 by danack