class-file-tree-producer.php
6 days ago
class-hmac-client.php
6 days ago
class-hmac-server.php
6 days ago
class-http-server.php
6 days ago
class-mysql-dump-producer.php
6 days ago
class-pdo-polyfill.php
6 days ago
class-sqlite-driver-pdo.php
6 days ago
class-staged-artifacts.php
6 days ago
class-staged-endpoints.php
6 days ago
class-staged-push-stream-protocol.php
6 days ago
class-wpdb-driver-pdo.php
6 days ago
export.php
6 days ago
utils.php
6 days ago
class-pdo-polyfill.php
58 lines
| 1 | <?php |
| 2 | /** |
| 3 | * PDO polyfill for hosts without the PDO extension. |
| 4 | * |
| 5 | * The reprint-exporter codebase references PDO::* constants, \PDOException, |
| 6 | * and \PDOStatement at multiple call sites (see the design spec for an audit). |
| 7 | * On hosts without ext-pdo, those references would fatal at runtime even |
| 8 | * though the wpdb adapter is the chosen connection. |
| 9 | * |
| 10 | * This file conditionally defines those names in the global namespace so |
| 11 | * existing code can resolve them without modification. Constant values |
| 12 | * match the real PDO extension exactly so behavior is identical regardless |
| 13 | * of which is loaded. |
| 14 | * |
| 15 | * Side-effect note: on PDO-less hosts, class_exists('PDO') with the default |
| 16 | * autoload-true argument now returns true. Co-resident code that uses |
| 17 | * class_exists('PDO') as an optional-feature gate (skip PDO path if false) |
| 18 | * will see the polyfill and try to use it, fataling where it previously |
| 19 | * skipped cleanly. This is acceptable for the exporter's deployment surface |
| 20 | * but documented here so a reader can grep for it. |
| 21 | */ |
| 22 | |
| 23 | if (!class_exists('PDO', false)) { |
| 24 | eval(<<<'PHP' |
| 25 | class PDO |
| 26 | { |
| 27 | const FETCH_ASSOC = 2; |
| 28 | const FETCH_COLUMN = 7; |
| 29 | const PARAM_STR = 2; |
| 30 | const ATTR_ERRMODE = 3; |
| 31 | const ERRMODE_EXCEPTION = 2; |
| 32 | const MYSQL_ATTR_USE_BUFFERED_QUERY = 1000; |
| 33 | } |
| 34 | PHP |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | if (!class_exists('PDOStatement', false)) { |
| 39 | eval(<<<'PHP' |
| 40 | class PDOStatement |
| 41 | { |
| 42 | } |
| 43 | PHP |
| 44 | ); |
| 45 | } |
| 46 | |
| 47 | if (!class_exists('PDOException', false)) { |
| 48 | // Real PDOException extends \Exception (not \RuntimeException). Match |
| 49 | // upstream so `catch (\RuntimeException $e)` does not accidentally catch |
| 50 | // the polyfilled exception while missing the real one. |
| 51 | eval(<<<'PHP' |
| 52 | class PDOException extends \Exception |
| 53 | { |
| 54 | } |
| 55 | PHP |
| 56 | ); |
| 57 | } |
| 58 |