@wp-playground/tools 3.1.15 → 3.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,6 @@ namespace PhpMyAdmin\\Dbal;
15
15
  use Closure;
16
16
  use Exception;
17
17
  use Generator;
18
- use PDO;
19
18
  use PhpMyAdmin\\FieldMetadata;
20
19
  use PhpMyAdmin\\Query\\Utilities;
21
20
  use Throwable;
@@ -260,10 +259,8 @@ class DbiMysqli implements DbiExtension {
260
259
 
261
260
  public function connect($user, $password, array $server) {
262
261
  global $wp_env;
263
- $pdo = new PDO('sqlite:' . $wp_env['db']['path']);
264
- $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
265
262
  $this->driver = new WP_SQLite_Driver(
266
- new WP_SQLite_Connection(array('pdo' => $pdo)),
263
+ new WP_SQLite_Connection(array('path' => $wp_env['db']['path'])),
267
264
  'wordpress'
268
265
  );
269
266
  return $this->driver;
@@ -345,4 +342,4 @@ class DbiMysqli implements DbiExtension {
345
342
  }
346
343
  }
347
344
  `;exports.default=t;
348
- //# sourceMappingURL=DbiMysqli-D7pMLLil.cjs.map
345
+ //# sourceMappingURL=DbiMysqli-B38TcdRZ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DbiMysqli-B38TcdRZ.cjs","sources":["../../../../packages/playground/tools/src/phpmyadmin/DbiMysqli.php?raw"],"sourcesContent":["export default \"<?php declare(strict_types = 1);\\n\\n/**\\n * A phpMyAdmin DBI extension for the MySQL-on-SQLite driver.\\n *\\n * This implementation is based on the original PhpMyAdmin\\\\Dbal\\\\DbiMysqli class.\\n * It is modified to use the MySQL-on-SQLite driver instead of MySQLi extension.\\n *\\n * @see https://github.com/phpmyadmin/phpmyadmin/blob/962857e4f63d42e38f11ff4d63f5e722018add76/libraries/classes/Dbal/DbiMysqli.php\\n * @see https://github.com/phpmyadmin/phpmyadmin/blob/142c0cf3be84c346174b730b6aa3ebcf44029256/src/Dbal/MysqliResult.php\\n */\\n\\nnamespace PhpMyAdmin\\\\Dbal;\\n\\nuse Closure;\\nuse Exception;\\nuse Generator;\\nuse PhpMyAdmin\\\\FieldMetadata;\\nuse PhpMyAdmin\\\\Query\\\\Utilities;\\nuse Throwable;\\nuse WP_SQLite_Connection;\\nuse WP_SQLite_Driver;\\n\\n// Load the SQLite driver.\\nglobal $wp_env;\\n$wp_env = require '/internal/shared/wp-env.php';\\nif ($wp_env['db']['type'] === 'sqlite') {\\n\\trequire_once $wp_env['db']['driver_path'];\\n} else {\\n\\tdie('Error: Unsupported database type: ' . $wp_env['db']['type']);\\n}\\n\\n// Supress the following phpMyAdmin warning:\\n// \\\"The mysqlnd extension is missing. Please check your PHP configuration.\\\"\\nClosure::bind(\\n\\tfunction () {\\n\\t\\t$this->errors = array_values(\\n\\t\\t\\tarray_filter(\\n\\t\\t\\t\\t$this->errors,\\n\\t\\t\\t\\tfunction ($error) {\\n\\t\\t\\t\\t\\t$skip = (\\n\\t\\t\\t\\t\\t\\tstrpos($error->getMessage(), 'mysqlnd') !== false\\n\\t\\t\\t\\t\\t\\t&& strpos($error->getMessage(), 'extension is missing') !== false\\n\\t\\t\\t\\t\\t);\\n\\t\\t\\t\\t\\treturn !$skip;\\n\\t\\t\\t\\t}\\n\\t\\t\\t)\\n\\t\\t);\\n\\t},\\n\\t$GLOBALS['errorHandler'],\\n\\t$GLOBALS['errorHandler']\\n)();\\n\\n// Ensure MySQLi type constants are defined for phpMyAdmin.\\nif (!defined('MYSQLI_TYPE_DECIMAL')) define('MYSQLI_TYPE_DECIMAL', 0);\\nif (!defined('MYSQLI_TYPE_TINY')) define('MYSQLI_TYPE_TINY', 1);\\nif (!defined('MYSQLI_TYPE_CHAR')) define('MYSQLI_TYPE_CHAR', 1);\\nif (!defined('MYSQLI_TYPE_SHORT')) define('MYSQLI_TYPE_SHORT', 2);\\nif (!defined('MYSQLI_TYPE_LONG')) define('MYSQLI_TYPE_LONG', 3);\\nif (!defined('MYSQLI_TYPE_FLOAT')) define('MYSQLI_TYPE_FLOAT', 4);\\nif (!defined('MYSQLI_TYPE_DOUBLE')) define('MYSQLI_TYPE_DOUBLE', 5);\\nif (!defined('MYSQLI_TYPE_NULL')) define('MYSQLI_TYPE_NULL', 6);\\nif (!defined('MYSQLI_TYPE_TIMESTAMP')) define('MYSQLI_TYPE_TIMESTAMP', 7);\\nif (!defined('MYSQLI_TYPE_LONGLONG')) define('MYSQLI_TYPE_LONGLONG', 8);\\nif (!defined('MYSQLI_TYPE_INT24')) define('MYSQLI_TYPE_INT24', 9);\\nif (!defined('MYSQLI_TYPE_DATE')) define('MYSQLI_TYPE_DATE', 10);\\nif (!defined('MYSQLI_TYPE_TIME')) define('MYSQLI_TYPE_TIME', 11);\\nif (!defined('MYSQLI_TYPE_DATETIME')) define('MYSQLI_TYPE_DATETIME', 12);\\nif (!defined('MYSQLI_TYPE_YEAR')) define('MYSQLI_TYPE_YEAR', 13);\\nif (!defined('MYSQLI_TYPE_NEWDATE')) define('MYSQLI_TYPE_NEWDATE', 14);\\nif (!defined('MYSQLI_TYPE_BIT')) define('MYSQLI_TYPE_BIT', 16);\\nif (!defined('MYSQLI_TYPE_VECTOR')) define('MYSQLI_TYPE_VECTOR', 242);\\nif (!defined('MYSQLI_TYPE_JSON')) define('MYSQLI_TYPE_JSON', 245);\\nif (!defined('MYSQLI_TYPE_NEWDECIMAL')) define('MYSQLI_TYPE_NEWDECIMAL', 246);\\nif (!defined('MYSQLI_TYPE_ENUM')) define('MYSQLI_TYPE_ENUM', 247);\\nif (!defined('MYSQLI_TYPE_SET')) define('MYSQLI_TYPE_SET', 248);\\nif (!defined('MYSQLI_TYPE_TINY_BLOB')) define('MYSQLI_TYPE_TINY_BLOB', 249);\\nif (!defined('MYSQLI_TYPE_MEDIUM_BLOB')) define('MYSQLI_TYPE_MEDIUM_BLOB', 250);\\nif (!defined('MYSQLI_TYPE_LONG_BLOB')) define('MYSQLI_TYPE_LONG_BLOB', 251);\\nif (!defined('MYSQLI_TYPE_BLOB')) define('MYSQLI_TYPE_BLOB', 252);\\nif (!defined('MYSQLI_TYPE_VAR_STRING')) define('MYSQLI_TYPE_VAR_STRING', 253);\\nif (!defined('MYSQLI_TYPE_STRING')) define('MYSQLI_TYPE_STRING', 243);\\nif (!defined('MYSQLI_TYPE_GEOMETRY')) define('MYSQLI_TYPE_GEOMETRY', 255);\\n\\n// Ensure MySQLi flags constants are defined for phpMyAdmin.\\nif (!defined('MYSQLI_NOT_NULL_FLAG')) define('MYSQLI_NOT_NULL_FLAG', 1);\\nif (!defined('MYSQLI_PRI_KEY_FLAG')) define('MYSQLI_PRI_KEY_FLAG', 2);\\nif (!defined('MYSQLI_UNIQUE_KEY_FLAG')) define('MYSQLI_UNIQUE_KEY_FLAG', 4);\\nif (!defined('MYSQLI_MULTIPLE_KEY_FLAG')) define('MYSQLI_MULTIPLE_KEY_FLAG', 8);\\nif (!defined('MYSQLI_BLOB_FLAG')) define('MYSQLI_BLOB_FLAG', 16);\\nif (!defined('MYSQLI_UNSIGNED_FLAG')) define('MYSQLI_UNSIGNED_FLAG', 32);\\nif (!defined('MYSQLI_ZEROFILL_FLAG')) define('MYSQLI_ZEROFILL_FLAG', 64);\\nif (!defined('MYSQLI_BINARY_FLAG')) define('MYSQLI_BINARY_FLAG', 128);\\nif (!defined('MYSQLI_ENUM_FLAG')) define('MYSQLI_ENUM_FLAG', 256);\\nif (!defined('MYSQLI_AUTO_INCREMENT_FLAG')) define('MYSQLI_AUTO_INCREMENT_FLAG', 512);\\nif (!defined('MYSQLI_TIMESTAMP_FLAG')) define('MYSQLI_TIMESTAMP_FLAG', 1024);\\nif (!defined('MYSQLI_SET_FLAG')) define('MYSQLI_SET_FLAG', 2048);\\nif (!defined('MYSQLI_NO_DEFAULT_VALUE_FLAG')) define('MYSQLI_NO_DEFAULT_VALUE_FLAG', 4096);\\nif (!defined('MYSQLI_ON_UPDATE_NOW_FLAG')) define('MYSQLI_ON_UPDATE_NOW_FLAG', 8192);\\nif (!defined('MYSQLI_PART_KEY_FLAG')) define('MYSQLI_PART_KEY_FLAG', 16384);\\nif (!defined('MYSQLI_NUM_FLAG')) define('MYSQLI_NUM_FLAG', 32768);\\nif (!defined('MYSQLI_GROUP_FLAG')) define('MYSQLI_GROUP_FLAG', 32768);\\n\\n/**\\n * A custom result class for the MySQL-on-SQLite driver.\\n *\\n * This implementation is based on the original PhpMyAdmin\\\\Dbal\\\\MysqliResult class.\\n *\\n * @see https://github.com/phpmyadmin/phpmyadmin/blob/142c0cf3be84c346174b730b6aa3ebcf44029256/src/Dbal/MysqliResult.php\\n */\\nclass Result implements ResultInterface {\\n\\t/** @var array */\\n\\tprivate $rows = array();\\n\\n\\t/** @var array */\\n\\tprivate $columns = array();\\n\\n\\t/** @var int */\\n\\tprivate $row_offset = 0;\\n\\n\\tpublic function __construct($rows, $columns) {\\n\\t\\t$this->rows = array();\\n\\t\\tif (is_array($rows)) {\\n\\t\\t\\tforeach ($rows as $row) {\\n\\t\\t\\t\\t$this->rows[] = (array) $row;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t$this->columns = $columns;\\n\\t}\\n\\n\\tpublic function fetchAllAssoc(): array {\\n\\t\\treturn $this->rows;\\n\\t}\\n\\n\\tpublic function fetchAllColumn(): array {\\n\\t\\treturn array_column($this->rows, 0);\\n\\t}\\n\\n\\tpublic function fetchAllKeyPair(): array {\\n\\t\\treturn array_combine(\\n\\t\\t\\tarray_column($this->rows, 0),\\n\\t\\t\\tarray_column($this->rows, 1)\\n\\t\\t);\\n\\t}\\n\\n\\tpublic function fetchAssoc(): array {\\n\\t\\t$row = $this->rows[$this->row_offset++] ?? false;\\n\\t\\tif ($row === false) {\\n\\t\\t\\treturn array();\\n\\t\\t}\\n\\t\\treturn $row;\\n\\t}\\n\\n\\tpublic function fetchRow(): array {\\n\\t\\t$row = $this->rows[$this->row_offset++] ?? false;\\n\\t\\tif ($row === false) {\\n\\t\\t\\treturn [];\\n\\t\\t}\\n\\t\\treturn array_values($row);\\n\\t}\\n\\n\\tpublic function fetchValue($field = 0) {\\n\\t\\tif (is_string($field)) {\\n $row = $this->fetchAssoc();\\n } else {\\n $row = $this->fetchRow();\\n }\\n\\t\\treturn $row[$field] ?? false;\\n\\t}\\n\\n\\tpublic function getFieldNames(): array {\\n\\t\\t$names = array();\\n\\t\\tforeach ($this->columns as $column) {\\n\\t\\t\\t$names[] = $column['name'];\\n\\t\\t}\\n\\t\\treturn $names;\\n\\t}\\n\\n\\tpublic function getFieldsMeta(): array {\\n\\t\\t$meta = array();\\n\\t\\tforeach ($this->columns as $column) {\\n\\t\\t\\t$flags = $column['flags'] ?? array();\\n\\n\\t\\t\\t// PhpMyAdmin expects MySQLi-like column metadata rather than PDO syntax.\\n\\t\\t\\t// The SQLite driver provides it in \\\"mysqli:\\\" prefixed metadata keys.\\n\\t\\t\\tforeach ($column as $key => $value) {\\n\\t\\t\\t\\tif (strpos($key, 'mysqli:') === 0) {\\n\\t\\t\\t\\t\\t$column[substr($key, 7)] = $value;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\t\\t\\t// Convert PDO-style flags array to MySQLi-style integer bitmask.\\n\\t\\t\\t// TODO: Remove this when the driver implements \\\"mysqli:flags\\\".\\n\\t\\t\\t$mysqli_flags = 0;\\n\\t\\t\\tforeach ($flags as $flag) {\\n\\t\\t\\t\\tswitch ($flag) {\\n\\t\\t\\t\\t\\tcase 'primary_key':\\n\\t\\t\\t\\t\\t\\t$mysqli_flags |= \\\\MYSQLI_PRI_KEY_FLAG;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\tcase 'unique_key':\\n\\t\\t\\t\\t\\t\\t$mysqli_flags |= \\\\MYSQLI_UNIQUE_KEY_FLAG;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\tcase 'not_null':\\n\\t\\t\\t\\t\\t\\t$mysqli_flags |= \\\\MYSQLI_NOT_NULL_FLAG;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\tcase 'auto_increment':\\n\\t\\t\\t\\t\\t\\t$mysqli_flags |= \\\\MYSQLI_AUTO_INCREMENT_FLAG;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\t$column['flags'] = $mysqli_flags;\\n\\n\\t\\t\\t$field = (object) $column;\\n\\t\\t\\t$meta[] = new FieldMetadata($field->type, $field->flags, $field);\\n\\t\\t}\\n\\t\\treturn $meta;\\n\\t}\\n\\n\\tpublic function getIterator(): Generator {\\n\\t\\t$this->row_offset = 0;\\n\\t\\tforeach ($this->rows as $row) {\\n\\t\\t\\tyield $row;\\n\\t\\t}\\n\\t}\\n\\n\\tpublic function numFields(): int {\\n\\t\\treturn count($this->columns);\\n\\t}\\n\\n\\tpublic function numRows() {\\n\\t\\treturn count($this->rows);\\n\\t}\\n\\n\\tpublic function seek(int $offset): bool {\\n\\t\\t$this->row_offset = $offset;\\n\\t\\tif ($this->row_offset >= count($this->rows)) {\\n\\t\\t\\treturn false;\\n\\t\\t}\\n\\t\\treturn true;\\n\\t}\\n}\\n\\n/**\\n * A custom DBI extension for the MySQL-on-SQLite driver.\\n *\\n * This implementation is based on the original PhpMyAdmin\\\\Dbal\\\\DbiMysqli class.\\n *\\n * @see https://github.com/phpmyadmin/phpmyadmin/blob/962857e4f63d42e38f11ff4d63f5e722018add76/libraries/classes/Dbal/DbiMysqli.php\\n */\\nclass DbiMysqli implements DbiExtension {\\n\\t/** @var WP_SQLite_Driver */\\n private $driver;\\n\\n\\t/** @var string */\\n\\tprivate $last_error_message = '';\\n\\n\\t/** @var int */\\n\\tprivate $last_error_number = 0;\\n\\n public function connect($user, $password, array $server) {\\n\\t\\tglobal $wp_env;\\n $this->driver = new WP_SQLite_Driver(\\n\\t\\t\\tnew WP_SQLite_Connection(array('path' => $wp_env['db']['path'])),\\n\\t\\t\\t'wordpress'\\n\\t\\t);\\n\\t\\treturn $this->driver;\\n }\\n\\n public function selectDb($databaseName, $link): bool {\\n\\t\\t$link->query(sprintf('USE %s', $link->get_connection()->quote_identifier($databaseName)));\\n\\t\\treturn true;\\n }\\n\\n public function realQuery(string $query, $link, int $options) {\\n\\t\\ttry {\\n\\t\\t\\t$this->last_error_message = '';\\n\\t\\t\\t$this->last_error_number = 0;\\n\\t\\t\\t$result = $link->query($query);\\n\\t\\t} catch (Throwable $e) {\\n\\t\\t\\t$this->last_error_message = $e->getMessage();\\n\\t\\t\\t$this->last_error_number = $e->getCode();\\n\\t\\t\\treturn false;\\n\\t\\t}\\n\\t\\tif ($result === false) {\\n\\t\\t\\treturn false;\\n\\t\\t}\\n return new Result($result, $link->get_last_column_meta());\\n }\\n\\n public function realMultiQuery($link, $query): bool {\\n\\t\\treturn false; // Multi-query not implemented.\\n }\\n\\n public function moreResults($link): bool {\\n\\t\\treturn false; // Multi-query not implemented.\\n }\\n\\n public function nextResult($link): bool {\\n\\t\\treturn false; // Multi-query not implemented.\\n }\\n\\n public function storeResult($link) {\\n\\t\\treturn false; // Multi-query not implemented.\\n }\\n\\n public function getHostInfo($link) {\\n\\t\\treturn 'WorPress Playground connection';\\n }\\n\\n public function getProtoInfo($link) {\\n return 10;\\n }\\n\\n public function getClientInfo() {\\n\\t\\treturn 'mysql-on-sqlite 8.0.38';\\n }\\n\\n public function getError($link): string\\n {\\n\\t\\t$error_number = $this->last_error_number;\\n\\t\\t$error_message = $this->last_error_message;\\n\\t\\t$GLOBALS['errno'] = $error_number;\\n\\t\\tif ($error_number === 0 || $error_message === '') {\\n\\t\\t\\treturn '';\\n\\t\\t}\\n\\t\\treturn Utilities::formatError($error_number, $error_message);\\n }\\n\\n public function affectedRows($link) {\\n\\t\\t$value = $link->get_last_return_value();\\n\\t\\treturn is_int($value) ? $value : 0;\\n }\\n\\n public function escapeString($link, $string) {\\n\\t\\t// For some reason, using \\\"$link->get_connection()->quote($string)\\\"\\n\\t\\t// causes the strings to be double-quoted. Let's skip the quoting.\\n\\t\\treturn $string;\\n }\\n\\n public function prepare($link, string $query) {\\n throw new Exception('Not implemented');\\n }\\n}\\n\""],"names":["DbiMysqli"],"mappings":"gFAAA,MAAAA,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA"}
@@ -15,7 +15,6 @@ namespace PhpMyAdmin\\Dbal;
15
15
  use Closure;
16
16
  use Exception;
17
17
  use Generator;
18
- use PDO;
19
18
  use PhpMyAdmin\\FieldMetadata;
20
19
  use PhpMyAdmin\\Query\\Utilities;
21
20
  use Throwable;
@@ -260,10 +259,8 @@ class DbiMysqli implements DbiExtension {
260
259
 
261
260
  public function connect($user, $password, array $server) {
262
261
  global $wp_env;
263
- $pdo = new PDO('sqlite:' . $wp_env['db']['path']);
264
- $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
265
262
  $this->driver = new WP_SQLite_Driver(
266
- new WP_SQLite_Connection(array('pdo' => $pdo)),
263
+ new WP_SQLite_Connection(array('path' => $wp_env['db']['path'])),
267
264
  'wordpress'
268
265
  );
269
266
  return $this->driver;
@@ -348,4 +345,4 @@ class DbiMysqli implements DbiExtension {
348
345
  export {
349
346
  t as default
350
347
  };
351
- //# sourceMappingURL=DbiMysqli-CfQ20D1R.js.map
348
+ //# sourceMappingURL=DbiMysqli-xDyCceKO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DbiMysqli-xDyCceKO.js","sources":["../../../../packages/playground/tools/src/phpmyadmin/DbiMysqli.php?raw"],"sourcesContent":["export default \"<?php declare(strict_types = 1);\\n\\n/**\\n * A phpMyAdmin DBI extension for the MySQL-on-SQLite driver.\\n *\\n * This implementation is based on the original PhpMyAdmin\\\\Dbal\\\\DbiMysqli class.\\n * It is modified to use the MySQL-on-SQLite driver instead of MySQLi extension.\\n *\\n * @see https://github.com/phpmyadmin/phpmyadmin/blob/962857e4f63d42e38f11ff4d63f5e722018add76/libraries/classes/Dbal/DbiMysqli.php\\n * @see https://github.com/phpmyadmin/phpmyadmin/blob/142c0cf3be84c346174b730b6aa3ebcf44029256/src/Dbal/MysqliResult.php\\n */\\n\\nnamespace PhpMyAdmin\\\\Dbal;\\n\\nuse Closure;\\nuse Exception;\\nuse Generator;\\nuse PhpMyAdmin\\\\FieldMetadata;\\nuse PhpMyAdmin\\\\Query\\\\Utilities;\\nuse Throwable;\\nuse WP_SQLite_Connection;\\nuse WP_SQLite_Driver;\\n\\n// Load the SQLite driver.\\nglobal $wp_env;\\n$wp_env = require '/internal/shared/wp-env.php';\\nif ($wp_env['db']['type'] === 'sqlite') {\\n\\trequire_once $wp_env['db']['driver_path'];\\n} else {\\n\\tdie('Error: Unsupported database type: ' . $wp_env['db']['type']);\\n}\\n\\n// Supress the following phpMyAdmin warning:\\n// \\\"The mysqlnd extension is missing. Please check your PHP configuration.\\\"\\nClosure::bind(\\n\\tfunction () {\\n\\t\\t$this->errors = array_values(\\n\\t\\t\\tarray_filter(\\n\\t\\t\\t\\t$this->errors,\\n\\t\\t\\t\\tfunction ($error) {\\n\\t\\t\\t\\t\\t$skip = (\\n\\t\\t\\t\\t\\t\\tstrpos($error->getMessage(), 'mysqlnd') !== false\\n\\t\\t\\t\\t\\t\\t&& strpos($error->getMessage(), 'extension is missing') !== false\\n\\t\\t\\t\\t\\t);\\n\\t\\t\\t\\t\\treturn !$skip;\\n\\t\\t\\t\\t}\\n\\t\\t\\t)\\n\\t\\t);\\n\\t},\\n\\t$GLOBALS['errorHandler'],\\n\\t$GLOBALS['errorHandler']\\n)();\\n\\n// Ensure MySQLi type constants are defined for phpMyAdmin.\\nif (!defined('MYSQLI_TYPE_DECIMAL')) define('MYSQLI_TYPE_DECIMAL', 0);\\nif (!defined('MYSQLI_TYPE_TINY')) define('MYSQLI_TYPE_TINY', 1);\\nif (!defined('MYSQLI_TYPE_CHAR')) define('MYSQLI_TYPE_CHAR', 1);\\nif (!defined('MYSQLI_TYPE_SHORT')) define('MYSQLI_TYPE_SHORT', 2);\\nif (!defined('MYSQLI_TYPE_LONG')) define('MYSQLI_TYPE_LONG', 3);\\nif (!defined('MYSQLI_TYPE_FLOAT')) define('MYSQLI_TYPE_FLOAT', 4);\\nif (!defined('MYSQLI_TYPE_DOUBLE')) define('MYSQLI_TYPE_DOUBLE', 5);\\nif (!defined('MYSQLI_TYPE_NULL')) define('MYSQLI_TYPE_NULL', 6);\\nif (!defined('MYSQLI_TYPE_TIMESTAMP')) define('MYSQLI_TYPE_TIMESTAMP', 7);\\nif (!defined('MYSQLI_TYPE_LONGLONG')) define('MYSQLI_TYPE_LONGLONG', 8);\\nif (!defined('MYSQLI_TYPE_INT24')) define('MYSQLI_TYPE_INT24', 9);\\nif (!defined('MYSQLI_TYPE_DATE')) define('MYSQLI_TYPE_DATE', 10);\\nif (!defined('MYSQLI_TYPE_TIME')) define('MYSQLI_TYPE_TIME', 11);\\nif (!defined('MYSQLI_TYPE_DATETIME')) define('MYSQLI_TYPE_DATETIME', 12);\\nif (!defined('MYSQLI_TYPE_YEAR')) define('MYSQLI_TYPE_YEAR', 13);\\nif (!defined('MYSQLI_TYPE_NEWDATE')) define('MYSQLI_TYPE_NEWDATE', 14);\\nif (!defined('MYSQLI_TYPE_BIT')) define('MYSQLI_TYPE_BIT', 16);\\nif (!defined('MYSQLI_TYPE_VECTOR')) define('MYSQLI_TYPE_VECTOR', 242);\\nif (!defined('MYSQLI_TYPE_JSON')) define('MYSQLI_TYPE_JSON', 245);\\nif (!defined('MYSQLI_TYPE_NEWDECIMAL')) define('MYSQLI_TYPE_NEWDECIMAL', 246);\\nif (!defined('MYSQLI_TYPE_ENUM')) define('MYSQLI_TYPE_ENUM', 247);\\nif (!defined('MYSQLI_TYPE_SET')) define('MYSQLI_TYPE_SET', 248);\\nif (!defined('MYSQLI_TYPE_TINY_BLOB')) define('MYSQLI_TYPE_TINY_BLOB', 249);\\nif (!defined('MYSQLI_TYPE_MEDIUM_BLOB')) define('MYSQLI_TYPE_MEDIUM_BLOB', 250);\\nif (!defined('MYSQLI_TYPE_LONG_BLOB')) define('MYSQLI_TYPE_LONG_BLOB', 251);\\nif (!defined('MYSQLI_TYPE_BLOB')) define('MYSQLI_TYPE_BLOB', 252);\\nif (!defined('MYSQLI_TYPE_VAR_STRING')) define('MYSQLI_TYPE_VAR_STRING', 253);\\nif (!defined('MYSQLI_TYPE_STRING')) define('MYSQLI_TYPE_STRING', 243);\\nif (!defined('MYSQLI_TYPE_GEOMETRY')) define('MYSQLI_TYPE_GEOMETRY', 255);\\n\\n// Ensure MySQLi flags constants are defined for phpMyAdmin.\\nif (!defined('MYSQLI_NOT_NULL_FLAG')) define('MYSQLI_NOT_NULL_FLAG', 1);\\nif (!defined('MYSQLI_PRI_KEY_FLAG')) define('MYSQLI_PRI_KEY_FLAG', 2);\\nif (!defined('MYSQLI_UNIQUE_KEY_FLAG')) define('MYSQLI_UNIQUE_KEY_FLAG', 4);\\nif (!defined('MYSQLI_MULTIPLE_KEY_FLAG')) define('MYSQLI_MULTIPLE_KEY_FLAG', 8);\\nif (!defined('MYSQLI_BLOB_FLAG')) define('MYSQLI_BLOB_FLAG', 16);\\nif (!defined('MYSQLI_UNSIGNED_FLAG')) define('MYSQLI_UNSIGNED_FLAG', 32);\\nif (!defined('MYSQLI_ZEROFILL_FLAG')) define('MYSQLI_ZEROFILL_FLAG', 64);\\nif (!defined('MYSQLI_BINARY_FLAG')) define('MYSQLI_BINARY_FLAG', 128);\\nif (!defined('MYSQLI_ENUM_FLAG')) define('MYSQLI_ENUM_FLAG', 256);\\nif (!defined('MYSQLI_AUTO_INCREMENT_FLAG')) define('MYSQLI_AUTO_INCREMENT_FLAG', 512);\\nif (!defined('MYSQLI_TIMESTAMP_FLAG')) define('MYSQLI_TIMESTAMP_FLAG', 1024);\\nif (!defined('MYSQLI_SET_FLAG')) define('MYSQLI_SET_FLAG', 2048);\\nif (!defined('MYSQLI_NO_DEFAULT_VALUE_FLAG')) define('MYSQLI_NO_DEFAULT_VALUE_FLAG', 4096);\\nif (!defined('MYSQLI_ON_UPDATE_NOW_FLAG')) define('MYSQLI_ON_UPDATE_NOW_FLAG', 8192);\\nif (!defined('MYSQLI_PART_KEY_FLAG')) define('MYSQLI_PART_KEY_FLAG', 16384);\\nif (!defined('MYSQLI_NUM_FLAG')) define('MYSQLI_NUM_FLAG', 32768);\\nif (!defined('MYSQLI_GROUP_FLAG')) define('MYSQLI_GROUP_FLAG', 32768);\\n\\n/**\\n * A custom result class for the MySQL-on-SQLite driver.\\n *\\n * This implementation is based on the original PhpMyAdmin\\\\Dbal\\\\MysqliResult class.\\n *\\n * @see https://github.com/phpmyadmin/phpmyadmin/blob/142c0cf3be84c346174b730b6aa3ebcf44029256/src/Dbal/MysqliResult.php\\n */\\nclass Result implements ResultInterface {\\n\\t/** @var array */\\n\\tprivate $rows = array();\\n\\n\\t/** @var array */\\n\\tprivate $columns = array();\\n\\n\\t/** @var int */\\n\\tprivate $row_offset = 0;\\n\\n\\tpublic function __construct($rows, $columns) {\\n\\t\\t$this->rows = array();\\n\\t\\tif (is_array($rows)) {\\n\\t\\t\\tforeach ($rows as $row) {\\n\\t\\t\\t\\t$this->rows[] = (array) $row;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t$this->columns = $columns;\\n\\t}\\n\\n\\tpublic function fetchAllAssoc(): array {\\n\\t\\treturn $this->rows;\\n\\t}\\n\\n\\tpublic function fetchAllColumn(): array {\\n\\t\\treturn array_column($this->rows, 0);\\n\\t}\\n\\n\\tpublic function fetchAllKeyPair(): array {\\n\\t\\treturn array_combine(\\n\\t\\t\\tarray_column($this->rows, 0),\\n\\t\\t\\tarray_column($this->rows, 1)\\n\\t\\t);\\n\\t}\\n\\n\\tpublic function fetchAssoc(): array {\\n\\t\\t$row = $this->rows[$this->row_offset++] ?? false;\\n\\t\\tif ($row === false) {\\n\\t\\t\\treturn array();\\n\\t\\t}\\n\\t\\treturn $row;\\n\\t}\\n\\n\\tpublic function fetchRow(): array {\\n\\t\\t$row = $this->rows[$this->row_offset++] ?? false;\\n\\t\\tif ($row === false) {\\n\\t\\t\\treturn [];\\n\\t\\t}\\n\\t\\treturn array_values($row);\\n\\t}\\n\\n\\tpublic function fetchValue($field = 0) {\\n\\t\\tif (is_string($field)) {\\n $row = $this->fetchAssoc();\\n } else {\\n $row = $this->fetchRow();\\n }\\n\\t\\treturn $row[$field] ?? false;\\n\\t}\\n\\n\\tpublic function getFieldNames(): array {\\n\\t\\t$names = array();\\n\\t\\tforeach ($this->columns as $column) {\\n\\t\\t\\t$names[] = $column['name'];\\n\\t\\t}\\n\\t\\treturn $names;\\n\\t}\\n\\n\\tpublic function getFieldsMeta(): array {\\n\\t\\t$meta = array();\\n\\t\\tforeach ($this->columns as $column) {\\n\\t\\t\\t$flags = $column['flags'] ?? array();\\n\\n\\t\\t\\t// PhpMyAdmin expects MySQLi-like column metadata rather than PDO syntax.\\n\\t\\t\\t// The SQLite driver provides it in \\\"mysqli:\\\" prefixed metadata keys.\\n\\t\\t\\tforeach ($column as $key => $value) {\\n\\t\\t\\t\\tif (strpos($key, 'mysqli:') === 0) {\\n\\t\\t\\t\\t\\t$column[substr($key, 7)] = $value;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\t\\t\\t// Convert PDO-style flags array to MySQLi-style integer bitmask.\\n\\t\\t\\t// TODO: Remove this when the driver implements \\\"mysqli:flags\\\".\\n\\t\\t\\t$mysqli_flags = 0;\\n\\t\\t\\tforeach ($flags as $flag) {\\n\\t\\t\\t\\tswitch ($flag) {\\n\\t\\t\\t\\t\\tcase 'primary_key':\\n\\t\\t\\t\\t\\t\\t$mysqli_flags |= \\\\MYSQLI_PRI_KEY_FLAG;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\tcase 'unique_key':\\n\\t\\t\\t\\t\\t\\t$mysqli_flags |= \\\\MYSQLI_UNIQUE_KEY_FLAG;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\tcase 'not_null':\\n\\t\\t\\t\\t\\t\\t$mysqli_flags |= \\\\MYSQLI_NOT_NULL_FLAG;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\tcase 'auto_increment':\\n\\t\\t\\t\\t\\t\\t$mysqli_flags |= \\\\MYSQLI_AUTO_INCREMENT_FLAG;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\t$column['flags'] = $mysqli_flags;\\n\\n\\t\\t\\t$field = (object) $column;\\n\\t\\t\\t$meta[] = new FieldMetadata($field->type, $field->flags, $field);\\n\\t\\t}\\n\\t\\treturn $meta;\\n\\t}\\n\\n\\tpublic function getIterator(): Generator {\\n\\t\\t$this->row_offset = 0;\\n\\t\\tforeach ($this->rows as $row) {\\n\\t\\t\\tyield $row;\\n\\t\\t}\\n\\t}\\n\\n\\tpublic function numFields(): int {\\n\\t\\treturn count($this->columns);\\n\\t}\\n\\n\\tpublic function numRows() {\\n\\t\\treturn count($this->rows);\\n\\t}\\n\\n\\tpublic function seek(int $offset): bool {\\n\\t\\t$this->row_offset = $offset;\\n\\t\\tif ($this->row_offset >= count($this->rows)) {\\n\\t\\t\\treturn false;\\n\\t\\t}\\n\\t\\treturn true;\\n\\t}\\n}\\n\\n/**\\n * A custom DBI extension for the MySQL-on-SQLite driver.\\n *\\n * This implementation is based on the original PhpMyAdmin\\\\Dbal\\\\DbiMysqli class.\\n *\\n * @see https://github.com/phpmyadmin/phpmyadmin/blob/962857e4f63d42e38f11ff4d63f5e722018add76/libraries/classes/Dbal/DbiMysqli.php\\n */\\nclass DbiMysqli implements DbiExtension {\\n\\t/** @var WP_SQLite_Driver */\\n private $driver;\\n\\n\\t/** @var string */\\n\\tprivate $last_error_message = '';\\n\\n\\t/** @var int */\\n\\tprivate $last_error_number = 0;\\n\\n public function connect($user, $password, array $server) {\\n\\t\\tglobal $wp_env;\\n $this->driver = new WP_SQLite_Driver(\\n\\t\\t\\tnew WP_SQLite_Connection(array('path' => $wp_env['db']['path'])),\\n\\t\\t\\t'wordpress'\\n\\t\\t);\\n\\t\\treturn $this->driver;\\n }\\n\\n public function selectDb($databaseName, $link): bool {\\n\\t\\t$link->query(sprintf('USE %s', $link->get_connection()->quote_identifier($databaseName)));\\n\\t\\treturn true;\\n }\\n\\n public function realQuery(string $query, $link, int $options) {\\n\\t\\ttry {\\n\\t\\t\\t$this->last_error_message = '';\\n\\t\\t\\t$this->last_error_number = 0;\\n\\t\\t\\t$result = $link->query($query);\\n\\t\\t} catch (Throwable $e) {\\n\\t\\t\\t$this->last_error_message = $e->getMessage();\\n\\t\\t\\t$this->last_error_number = $e->getCode();\\n\\t\\t\\treturn false;\\n\\t\\t}\\n\\t\\tif ($result === false) {\\n\\t\\t\\treturn false;\\n\\t\\t}\\n return new Result($result, $link->get_last_column_meta());\\n }\\n\\n public function realMultiQuery($link, $query): bool {\\n\\t\\treturn false; // Multi-query not implemented.\\n }\\n\\n public function moreResults($link): bool {\\n\\t\\treturn false; // Multi-query not implemented.\\n }\\n\\n public function nextResult($link): bool {\\n\\t\\treturn false; // Multi-query not implemented.\\n }\\n\\n public function storeResult($link) {\\n\\t\\treturn false; // Multi-query not implemented.\\n }\\n\\n public function getHostInfo($link) {\\n\\t\\treturn 'WorPress Playground connection';\\n }\\n\\n public function getProtoInfo($link) {\\n return 10;\\n }\\n\\n public function getClientInfo() {\\n\\t\\treturn 'mysql-on-sqlite 8.0.38';\\n }\\n\\n public function getError($link): string\\n {\\n\\t\\t$error_number = $this->last_error_number;\\n\\t\\t$error_message = $this->last_error_message;\\n\\t\\t$GLOBALS['errno'] = $error_number;\\n\\t\\tif ($error_number === 0 || $error_message === '') {\\n\\t\\t\\treturn '';\\n\\t\\t}\\n\\t\\treturn Utilities::formatError($error_number, $error_message);\\n }\\n\\n public function affectedRows($link) {\\n\\t\\t$value = $link->get_last_return_value();\\n\\t\\treturn is_int($value) ? $value : 0;\\n }\\n\\n public function escapeString($link, $string) {\\n\\t\\t// For some reason, using \\\"$link->get_connection()->quote($string)\\\"\\n\\t\\t// causes the strings to be double-quoted. Let's skip the quoting.\\n\\t\\treturn $string;\\n }\\n\\n public function prepare($link, string $query) {\\n throw new Exception('Not implemented');\\n }\\n}\\n\""],"names":["DbiMysqli"],"mappings":"AAAA,MAAAA,IAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
package/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="5.2.3",i=`https://files.phpmyadmin.net/phpMyAdmin/${e}/phpMyAdmin-${e}-english.zip`,t="/tools/phpmyadmin",p="/index.php?route=/database/structure&db=wordpress";async function s(){return[{step:"unzip",zipFile:{resource:"url",url:i},extractToPath:"/tmp"},{step:"mkdir",path:t},{step:"mv",fromPath:`/tmp/phpMyAdmin-${e}-english`,toPath:t},{step:"writeFile",path:`${t}/libraries/classes/Dbal/DbiMysqli.php`,data:(await Promise.resolve().then(()=>require("./DbiMysqli-D7pMLLil.cjs"))).default},{step:"writeFile",path:`${t}/config.inc.php`,data:(await Promise.resolve().then(()=>require("./config.inc-BPj6j876.cjs"))).default}]}exports.PHPMYADMIN_DOWNLOAD_URL=i;exports.PHPMYADMIN_ENTRY_PATH=p;exports.PHPMYADMIN_INSTALL_PATH=t;exports.PHPMYADMIN_VERSION=e;exports.getPhpMyAdminInstallSteps=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="5.2.3",i=`https://files.phpmyadmin.net/phpMyAdmin/${e}/phpMyAdmin-${e}-english.zip`,t="/tools/phpmyadmin",p="/index.php?route=/database/structure&db=wordpress";async function s(){return[{step:"unzip",zipFile:{resource:"url",url:i},extractToPath:"/tmp"},{step:"mkdir",path:t},{step:"mv",fromPath:`/tmp/phpMyAdmin-${e}-english`,toPath:t},{step:"writeFile",path:`${t}/libraries/classes/Dbal/DbiMysqli.php`,data:(await Promise.resolve().then(()=>require("./DbiMysqli-B38TcdRZ.cjs"))).default},{step:"writeFile",path:`${t}/config.inc.php`,data:(await Promise.resolve().then(()=>require("./config.inc-BPj6j876.cjs"))).default}]}exports.PHPMYADMIN_DOWNLOAD_URL=i;exports.PHPMYADMIN_ENTRY_PATH=p;exports.PHPMYADMIN_INSTALL_PATH=t;exports.PHPMYADMIN_VERSION=e;exports.getPhpMyAdminInstallSteps=s;
2
2
  //# sourceMappingURL=index.cjs.map
package/index.js CHANGED
@@ -22,7 +22,7 @@ async function a() {
22
22
  step: "writeFile",
23
23
  path: `${t}/libraries/classes/Dbal/DbiMysqli.php`,
24
24
  /* @ts-ignore */
25
- data: (await import("./DbiMysqli-CfQ20D1R.js")).default
25
+ data: (await import("./DbiMysqli-xDyCceKO.js")).default
26
26
  },
27
27
  {
28
28
  step: "writeFile",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wp-playground/tools",
3
- "version": "3.1.15",
3
+ "version": "3.1.18",
4
4
  "description": "Tools for WordPress Playground",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,7 +28,7 @@
28
28
  "access": "public",
29
29
  "directory": "../../../dist/packages/playground/tools"
30
30
  },
31
- "gitHead": "65a430c046c86341e7dc3cf6f30c9a5aeb8aa67d",
31
+ "gitHead": "556d5464c00b85ced0a505a31968b3fa1753eb28",
32
32
  "dependencies": {
33
33
  "@zip.js/zip.js": "2.7.57",
34
34
  "ajv": "8.12.0",
@@ -52,7 +52,7 @@
52
52
  "wasm-feature-detect": "1.8.0",
53
53
  "ws": "8.18.3",
54
54
  "yargs": "17.7.2",
55
- "@wp-playground/blueprints": "3.1.15"
55
+ "@wp-playground/blueprints": "3.1.18"
56
56
  },
57
57
  "packageManager": "npm@10.9.2",
58
58
  "overrides": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"DbiMysqli-CfQ20D1R.js","sources":["../../../../packages/playground/tools/src/phpmyadmin/DbiMysqli.php?raw"],"sourcesContent":["export default \"<?php declare(strict_types = 1);\\n\\n/**\\n * A phpMyAdmin DBI extension for the MySQL-on-SQLite driver.\\n *\\n * This implementation is based on the original PhpMyAdmin\\\\Dbal\\\\DbiMysqli class.\\n * It is modified to use the MySQL-on-SQLite driver instead of MySQLi extension.\\n *\\n * @see https://github.com/phpmyadmin/phpmyadmin/blob/962857e4f63d42e38f11ff4d63f5e722018add76/libraries/classes/Dbal/DbiMysqli.php\\n * @see https://github.com/phpmyadmin/phpmyadmin/blob/142c0cf3be84c346174b730b6aa3ebcf44029256/src/Dbal/MysqliResult.php\\n */\\n\\nnamespace PhpMyAdmin\\\\Dbal;\\n\\nuse Closure;\\nuse Exception;\\nuse Generator;\\nuse PDO;\\nuse PhpMyAdmin\\\\FieldMetadata;\\nuse PhpMyAdmin\\\\Query\\\\Utilities;\\nuse Throwable;\\nuse WP_SQLite_Connection;\\nuse WP_SQLite_Driver;\\n\\n// Load the SQLite driver.\\nglobal $wp_env;\\n$wp_env = require '/internal/shared/wp-env.php';\\nif ($wp_env['db']['type'] === 'sqlite') {\\n\\trequire_once $wp_env['db']['driver_path'];\\n} else {\\n\\tdie('Error: Unsupported database type: ' . $wp_env['db']['type']);\\n}\\n\\n// Supress the following phpMyAdmin warning:\\n// \\\"The mysqlnd extension is missing. Please check your PHP configuration.\\\"\\nClosure::bind(\\n\\tfunction () {\\n\\t\\t$this->errors = array_values(\\n\\t\\t\\tarray_filter(\\n\\t\\t\\t\\t$this->errors,\\n\\t\\t\\t\\tfunction ($error) {\\n\\t\\t\\t\\t\\t$skip = (\\n\\t\\t\\t\\t\\t\\tstrpos($error->getMessage(), 'mysqlnd') !== false\\n\\t\\t\\t\\t\\t\\t&& strpos($error->getMessage(), 'extension is missing') !== false\\n\\t\\t\\t\\t\\t);\\n\\t\\t\\t\\t\\treturn !$skip;\\n\\t\\t\\t\\t}\\n\\t\\t\\t)\\n\\t\\t);\\n\\t},\\n\\t$GLOBALS['errorHandler'],\\n\\t$GLOBALS['errorHandler']\\n)();\\n\\n// Ensure MySQLi type constants are defined for phpMyAdmin.\\nif (!defined('MYSQLI_TYPE_DECIMAL')) define('MYSQLI_TYPE_DECIMAL', 0);\\nif (!defined('MYSQLI_TYPE_TINY')) define('MYSQLI_TYPE_TINY', 1);\\nif (!defined('MYSQLI_TYPE_CHAR')) define('MYSQLI_TYPE_CHAR', 1);\\nif (!defined('MYSQLI_TYPE_SHORT')) define('MYSQLI_TYPE_SHORT', 2);\\nif (!defined('MYSQLI_TYPE_LONG')) define('MYSQLI_TYPE_LONG', 3);\\nif (!defined('MYSQLI_TYPE_FLOAT')) define('MYSQLI_TYPE_FLOAT', 4);\\nif (!defined('MYSQLI_TYPE_DOUBLE')) define('MYSQLI_TYPE_DOUBLE', 5);\\nif (!defined('MYSQLI_TYPE_NULL')) define('MYSQLI_TYPE_NULL', 6);\\nif (!defined('MYSQLI_TYPE_TIMESTAMP')) define('MYSQLI_TYPE_TIMESTAMP', 7);\\nif (!defined('MYSQLI_TYPE_LONGLONG')) define('MYSQLI_TYPE_LONGLONG', 8);\\nif (!defined('MYSQLI_TYPE_INT24')) define('MYSQLI_TYPE_INT24', 9);\\nif (!defined('MYSQLI_TYPE_DATE')) define('MYSQLI_TYPE_DATE', 10);\\nif (!defined('MYSQLI_TYPE_TIME')) define('MYSQLI_TYPE_TIME', 11);\\nif (!defined('MYSQLI_TYPE_DATETIME')) define('MYSQLI_TYPE_DATETIME', 12);\\nif (!defined('MYSQLI_TYPE_YEAR')) define('MYSQLI_TYPE_YEAR', 13);\\nif (!defined('MYSQLI_TYPE_NEWDATE')) define('MYSQLI_TYPE_NEWDATE', 14);\\nif (!defined('MYSQLI_TYPE_BIT')) define('MYSQLI_TYPE_BIT', 16);\\nif (!defined('MYSQLI_TYPE_VECTOR')) define('MYSQLI_TYPE_VECTOR', 242);\\nif (!defined('MYSQLI_TYPE_JSON')) define('MYSQLI_TYPE_JSON', 245);\\nif (!defined('MYSQLI_TYPE_NEWDECIMAL')) define('MYSQLI_TYPE_NEWDECIMAL', 246);\\nif (!defined('MYSQLI_TYPE_ENUM')) define('MYSQLI_TYPE_ENUM', 247);\\nif (!defined('MYSQLI_TYPE_SET')) define('MYSQLI_TYPE_SET', 248);\\nif (!defined('MYSQLI_TYPE_TINY_BLOB')) define('MYSQLI_TYPE_TINY_BLOB', 249);\\nif (!defined('MYSQLI_TYPE_MEDIUM_BLOB')) define('MYSQLI_TYPE_MEDIUM_BLOB', 250);\\nif (!defined('MYSQLI_TYPE_LONG_BLOB')) define('MYSQLI_TYPE_LONG_BLOB', 251);\\nif (!defined('MYSQLI_TYPE_BLOB')) define('MYSQLI_TYPE_BLOB', 252);\\nif (!defined('MYSQLI_TYPE_VAR_STRING')) define('MYSQLI_TYPE_VAR_STRING', 253);\\nif (!defined('MYSQLI_TYPE_STRING')) define('MYSQLI_TYPE_STRING', 243);\\nif (!defined('MYSQLI_TYPE_GEOMETRY')) define('MYSQLI_TYPE_GEOMETRY', 255);\\n\\n// Ensure MySQLi flags constants are defined for phpMyAdmin.\\nif (!defined('MYSQLI_NOT_NULL_FLAG')) define('MYSQLI_NOT_NULL_FLAG', 1);\\nif (!defined('MYSQLI_PRI_KEY_FLAG')) define('MYSQLI_PRI_KEY_FLAG', 2);\\nif (!defined('MYSQLI_UNIQUE_KEY_FLAG')) define('MYSQLI_UNIQUE_KEY_FLAG', 4);\\nif (!defined('MYSQLI_MULTIPLE_KEY_FLAG')) define('MYSQLI_MULTIPLE_KEY_FLAG', 8);\\nif (!defined('MYSQLI_BLOB_FLAG')) define('MYSQLI_BLOB_FLAG', 16);\\nif (!defined('MYSQLI_UNSIGNED_FLAG')) define('MYSQLI_UNSIGNED_FLAG', 32);\\nif (!defined('MYSQLI_ZEROFILL_FLAG')) define('MYSQLI_ZEROFILL_FLAG', 64);\\nif (!defined('MYSQLI_BINARY_FLAG')) define('MYSQLI_BINARY_FLAG', 128);\\nif (!defined('MYSQLI_ENUM_FLAG')) define('MYSQLI_ENUM_FLAG', 256);\\nif (!defined('MYSQLI_AUTO_INCREMENT_FLAG')) define('MYSQLI_AUTO_INCREMENT_FLAG', 512);\\nif (!defined('MYSQLI_TIMESTAMP_FLAG')) define('MYSQLI_TIMESTAMP_FLAG', 1024);\\nif (!defined('MYSQLI_SET_FLAG')) define('MYSQLI_SET_FLAG', 2048);\\nif (!defined('MYSQLI_NO_DEFAULT_VALUE_FLAG')) define('MYSQLI_NO_DEFAULT_VALUE_FLAG', 4096);\\nif (!defined('MYSQLI_ON_UPDATE_NOW_FLAG')) define('MYSQLI_ON_UPDATE_NOW_FLAG', 8192);\\nif (!defined('MYSQLI_PART_KEY_FLAG')) define('MYSQLI_PART_KEY_FLAG', 16384);\\nif (!defined('MYSQLI_NUM_FLAG')) define('MYSQLI_NUM_FLAG', 32768);\\nif (!defined('MYSQLI_GROUP_FLAG')) define('MYSQLI_GROUP_FLAG', 32768);\\n\\n/**\\n * A custom result class for the MySQL-on-SQLite driver.\\n *\\n * This implementation is based on the original PhpMyAdmin\\\\Dbal\\\\MysqliResult class.\\n *\\n * @see https://github.com/phpmyadmin/phpmyadmin/blob/142c0cf3be84c346174b730b6aa3ebcf44029256/src/Dbal/MysqliResult.php\\n */\\nclass Result implements ResultInterface {\\n\\t/** @var array */\\n\\tprivate $rows = array();\\n\\n\\t/** @var array */\\n\\tprivate $columns = array();\\n\\n\\t/** @var int */\\n\\tprivate $row_offset = 0;\\n\\n\\tpublic function __construct($rows, $columns) {\\n\\t\\t$this->rows = array();\\n\\t\\tif (is_array($rows)) {\\n\\t\\t\\tforeach ($rows as $row) {\\n\\t\\t\\t\\t$this->rows[] = (array) $row;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t$this->columns = $columns;\\n\\t}\\n\\n\\tpublic function fetchAllAssoc(): array {\\n\\t\\treturn $this->rows;\\n\\t}\\n\\n\\tpublic function fetchAllColumn(): array {\\n\\t\\treturn array_column($this->rows, 0);\\n\\t}\\n\\n\\tpublic function fetchAllKeyPair(): array {\\n\\t\\treturn array_combine(\\n\\t\\t\\tarray_column($this->rows, 0),\\n\\t\\t\\tarray_column($this->rows, 1)\\n\\t\\t);\\n\\t}\\n\\n\\tpublic function fetchAssoc(): array {\\n\\t\\t$row = $this->rows[$this->row_offset++] ?? false;\\n\\t\\tif ($row === false) {\\n\\t\\t\\treturn array();\\n\\t\\t}\\n\\t\\treturn $row;\\n\\t}\\n\\n\\tpublic function fetchRow(): array {\\n\\t\\t$row = $this->rows[$this->row_offset++] ?? false;\\n\\t\\tif ($row === false) {\\n\\t\\t\\treturn [];\\n\\t\\t}\\n\\t\\treturn array_values($row);\\n\\t}\\n\\n\\tpublic function fetchValue($field = 0) {\\n\\t\\tif (is_string($field)) {\\n $row = $this->fetchAssoc();\\n } else {\\n $row = $this->fetchRow();\\n }\\n\\t\\treturn $row[$field] ?? false;\\n\\t}\\n\\n\\tpublic function getFieldNames(): array {\\n\\t\\t$names = array();\\n\\t\\tforeach ($this->columns as $column) {\\n\\t\\t\\t$names[] = $column['name'];\\n\\t\\t}\\n\\t\\treturn $names;\\n\\t}\\n\\n\\tpublic function getFieldsMeta(): array {\\n\\t\\t$meta = array();\\n\\t\\tforeach ($this->columns as $column) {\\n\\t\\t\\t$flags = $column['flags'] ?? array();\\n\\n\\t\\t\\t// PhpMyAdmin expects MySQLi-like column metadata rather than PDO syntax.\\n\\t\\t\\t// The SQLite driver provides it in \\\"mysqli:\\\" prefixed metadata keys.\\n\\t\\t\\tforeach ($column as $key => $value) {\\n\\t\\t\\t\\tif (strpos($key, 'mysqli:') === 0) {\\n\\t\\t\\t\\t\\t$column[substr($key, 7)] = $value;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\t\\t\\t// Convert PDO-style flags array to MySQLi-style integer bitmask.\\n\\t\\t\\t// TODO: Remove this when the driver implements \\\"mysqli:flags\\\".\\n\\t\\t\\t$mysqli_flags = 0;\\n\\t\\t\\tforeach ($flags as $flag) {\\n\\t\\t\\t\\tswitch ($flag) {\\n\\t\\t\\t\\t\\tcase 'primary_key':\\n\\t\\t\\t\\t\\t\\t$mysqli_flags |= \\\\MYSQLI_PRI_KEY_FLAG;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\tcase 'unique_key':\\n\\t\\t\\t\\t\\t\\t$mysqli_flags |= \\\\MYSQLI_UNIQUE_KEY_FLAG;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\tcase 'not_null':\\n\\t\\t\\t\\t\\t\\t$mysqli_flags |= \\\\MYSQLI_NOT_NULL_FLAG;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\tcase 'auto_increment':\\n\\t\\t\\t\\t\\t\\t$mysqli_flags |= \\\\MYSQLI_AUTO_INCREMENT_FLAG;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\t$column['flags'] = $mysqli_flags;\\n\\n\\t\\t\\t$field = (object) $column;\\n\\t\\t\\t$meta[] = new FieldMetadata($field->type, $field->flags, $field);\\n\\t\\t}\\n\\t\\treturn $meta;\\n\\t}\\n\\n\\tpublic function getIterator(): Generator {\\n\\t\\t$this->row_offset = 0;\\n\\t\\tforeach ($this->rows as $row) {\\n\\t\\t\\tyield $row;\\n\\t\\t}\\n\\t}\\n\\n\\tpublic function numFields(): int {\\n\\t\\treturn count($this->columns);\\n\\t}\\n\\n\\tpublic function numRows() {\\n\\t\\treturn count($this->rows);\\n\\t}\\n\\n\\tpublic function seek(int $offset): bool {\\n\\t\\t$this->row_offset = $offset;\\n\\t\\tif ($this->row_offset >= count($this->rows)) {\\n\\t\\t\\treturn false;\\n\\t\\t}\\n\\t\\treturn true;\\n\\t}\\n}\\n\\n/**\\n * A custom DBI extension for the MySQL-on-SQLite driver.\\n *\\n * This implementation is based on the original PhpMyAdmin\\\\Dbal\\\\DbiMysqli class.\\n *\\n * @see https://github.com/phpmyadmin/phpmyadmin/blob/962857e4f63d42e38f11ff4d63f5e722018add76/libraries/classes/Dbal/DbiMysqli.php\\n */\\nclass DbiMysqli implements DbiExtension {\\n\\t/** @var WP_SQLite_Driver */\\n private $driver;\\n\\n\\t/** @var string */\\n\\tprivate $last_error_message = '';\\n\\n\\t/** @var int */\\n\\tprivate $last_error_number = 0;\\n\\n public function connect($user, $password, array $server) {\\n\\t\\tglobal $wp_env;\\n\\t\\t$pdo = new PDO('sqlite:' . $wp_env['db']['path']);\\n\\t\\t$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);\\n $this->driver = new WP_SQLite_Driver(\\n\\t\\t\\tnew WP_SQLite_Connection(array('pdo' => $pdo)),\\n\\t\\t\\t'wordpress'\\n\\t\\t);\\n\\t\\treturn $this->driver;\\n }\\n\\n public function selectDb($databaseName, $link): bool {\\n\\t\\t$link->query(sprintf('USE %s', $link->get_connection()->quote_identifier($databaseName)));\\n\\t\\treturn true;\\n }\\n\\n public function realQuery(string $query, $link, int $options) {\\n\\t\\ttry {\\n\\t\\t\\t$this->last_error_message = '';\\n\\t\\t\\t$this->last_error_number = 0;\\n\\t\\t\\t$result = $link->query($query);\\n\\t\\t} catch (Throwable $e) {\\n\\t\\t\\t$this->last_error_message = $e->getMessage();\\n\\t\\t\\t$this->last_error_number = $e->getCode();\\n\\t\\t\\treturn false;\\n\\t\\t}\\n\\t\\tif ($result === false) {\\n\\t\\t\\treturn false;\\n\\t\\t}\\n return new Result($result, $link->get_last_column_meta());\\n }\\n\\n public function realMultiQuery($link, $query): bool {\\n\\t\\treturn false; // Multi-query not implemented.\\n }\\n\\n public function moreResults($link): bool {\\n\\t\\treturn false; // Multi-query not implemented.\\n }\\n\\n public function nextResult($link): bool {\\n\\t\\treturn false; // Multi-query not implemented.\\n }\\n\\n public function storeResult($link) {\\n\\t\\treturn false; // Multi-query not implemented.\\n }\\n\\n public function getHostInfo($link) {\\n\\t\\treturn 'WorPress Playground connection';\\n }\\n\\n public function getProtoInfo($link) {\\n return 10;\\n }\\n\\n public function getClientInfo() {\\n\\t\\treturn 'mysql-on-sqlite 8.0.38';\\n }\\n\\n public function getError($link): string\\n {\\n\\t\\t$error_number = $this->last_error_number;\\n\\t\\t$error_message = $this->last_error_message;\\n\\t\\t$GLOBALS['errno'] = $error_number;\\n\\t\\tif ($error_number === 0 || $error_message === '') {\\n\\t\\t\\treturn '';\\n\\t\\t}\\n\\t\\treturn Utilities::formatError($error_number, $error_message);\\n }\\n\\n public function affectedRows($link) {\\n\\t\\t$value = $link->get_last_return_value();\\n\\t\\treturn is_int($value) ? $value : 0;\\n }\\n\\n public function escapeString($link, $string) {\\n\\t\\t// For some reason, using \\\"$link->get_connection()->quote($string)\\\"\\n\\t\\t// causes the strings to be double-quoted. Let's skip the quoting.\\n\\t\\treturn $string;\\n }\\n\\n public function prepare($link, string $query) {\\n throw new Exception('Not implemented');\\n }\\n}\\n\""],"names":["DbiMysqli"],"mappings":"AAAA,MAAAA,IAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DbiMysqli-D7pMLLil.cjs","sources":["../../../../packages/playground/tools/src/phpmyadmin/DbiMysqli.php?raw"],"sourcesContent":["export default \"<?php declare(strict_types = 1);\\n\\n/**\\n * A phpMyAdmin DBI extension for the MySQL-on-SQLite driver.\\n *\\n * This implementation is based on the original PhpMyAdmin\\\\Dbal\\\\DbiMysqli class.\\n * It is modified to use the MySQL-on-SQLite driver instead of MySQLi extension.\\n *\\n * @see https://github.com/phpmyadmin/phpmyadmin/blob/962857e4f63d42e38f11ff4d63f5e722018add76/libraries/classes/Dbal/DbiMysqli.php\\n * @see https://github.com/phpmyadmin/phpmyadmin/blob/142c0cf3be84c346174b730b6aa3ebcf44029256/src/Dbal/MysqliResult.php\\n */\\n\\nnamespace PhpMyAdmin\\\\Dbal;\\n\\nuse Closure;\\nuse Exception;\\nuse Generator;\\nuse PDO;\\nuse PhpMyAdmin\\\\FieldMetadata;\\nuse PhpMyAdmin\\\\Query\\\\Utilities;\\nuse Throwable;\\nuse WP_SQLite_Connection;\\nuse WP_SQLite_Driver;\\n\\n// Load the SQLite driver.\\nglobal $wp_env;\\n$wp_env = require '/internal/shared/wp-env.php';\\nif ($wp_env['db']['type'] === 'sqlite') {\\n\\trequire_once $wp_env['db']['driver_path'];\\n} else {\\n\\tdie('Error: Unsupported database type: ' . $wp_env['db']['type']);\\n}\\n\\n// Supress the following phpMyAdmin warning:\\n// \\\"The mysqlnd extension is missing. Please check your PHP configuration.\\\"\\nClosure::bind(\\n\\tfunction () {\\n\\t\\t$this->errors = array_values(\\n\\t\\t\\tarray_filter(\\n\\t\\t\\t\\t$this->errors,\\n\\t\\t\\t\\tfunction ($error) {\\n\\t\\t\\t\\t\\t$skip = (\\n\\t\\t\\t\\t\\t\\tstrpos($error->getMessage(), 'mysqlnd') !== false\\n\\t\\t\\t\\t\\t\\t&& strpos($error->getMessage(), 'extension is missing') !== false\\n\\t\\t\\t\\t\\t);\\n\\t\\t\\t\\t\\treturn !$skip;\\n\\t\\t\\t\\t}\\n\\t\\t\\t)\\n\\t\\t);\\n\\t},\\n\\t$GLOBALS['errorHandler'],\\n\\t$GLOBALS['errorHandler']\\n)();\\n\\n// Ensure MySQLi type constants are defined for phpMyAdmin.\\nif (!defined('MYSQLI_TYPE_DECIMAL')) define('MYSQLI_TYPE_DECIMAL', 0);\\nif (!defined('MYSQLI_TYPE_TINY')) define('MYSQLI_TYPE_TINY', 1);\\nif (!defined('MYSQLI_TYPE_CHAR')) define('MYSQLI_TYPE_CHAR', 1);\\nif (!defined('MYSQLI_TYPE_SHORT')) define('MYSQLI_TYPE_SHORT', 2);\\nif (!defined('MYSQLI_TYPE_LONG')) define('MYSQLI_TYPE_LONG', 3);\\nif (!defined('MYSQLI_TYPE_FLOAT')) define('MYSQLI_TYPE_FLOAT', 4);\\nif (!defined('MYSQLI_TYPE_DOUBLE')) define('MYSQLI_TYPE_DOUBLE', 5);\\nif (!defined('MYSQLI_TYPE_NULL')) define('MYSQLI_TYPE_NULL', 6);\\nif (!defined('MYSQLI_TYPE_TIMESTAMP')) define('MYSQLI_TYPE_TIMESTAMP', 7);\\nif (!defined('MYSQLI_TYPE_LONGLONG')) define('MYSQLI_TYPE_LONGLONG', 8);\\nif (!defined('MYSQLI_TYPE_INT24')) define('MYSQLI_TYPE_INT24', 9);\\nif (!defined('MYSQLI_TYPE_DATE')) define('MYSQLI_TYPE_DATE', 10);\\nif (!defined('MYSQLI_TYPE_TIME')) define('MYSQLI_TYPE_TIME', 11);\\nif (!defined('MYSQLI_TYPE_DATETIME')) define('MYSQLI_TYPE_DATETIME', 12);\\nif (!defined('MYSQLI_TYPE_YEAR')) define('MYSQLI_TYPE_YEAR', 13);\\nif (!defined('MYSQLI_TYPE_NEWDATE')) define('MYSQLI_TYPE_NEWDATE', 14);\\nif (!defined('MYSQLI_TYPE_BIT')) define('MYSQLI_TYPE_BIT', 16);\\nif (!defined('MYSQLI_TYPE_VECTOR')) define('MYSQLI_TYPE_VECTOR', 242);\\nif (!defined('MYSQLI_TYPE_JSON')) define('MYSQLI_TYPE_JSON', 245);\\nif (!defined('MYSQLI_TYPE_NEWDECIMAL')) define('MYSQLI_TYPE_NEWDECIMAL', 246);\\nif (!defined('MYSQLI_TYPE_ENUM')) define('MYSQLI_TYPE_ENUM', 247);\\nif (!defined('MYSQLI_TYPE_SET')) define('MYSQLI_TYPE_SET', 248);\\nif (!defined('MYSQLI_TYPE_TINY_BLOB')) define('MYSQLI_TYPE_TINY_BLOB', 249);\\nif (!defined('MYSQLI_TYPE_MEDIUM_BLOB')) define('MYSQLI_TYPE_MEDIUM_BLOB', 250);\\nif (!defined('MYSQLI_TYPE_LONG_BLOB')) define('MYSQLI_TYPE_LONG_BLOB', 251);\\nif (!defined('MYSQLI_TYPE_BLOB')) define('MYSQLI_TYPE_BLOB', 252);\\nif (!defined('MYSQLI_TYPE_VAR_STRING')) define('MYSQLI_TYPE_VAR_STRING', 253);\\nif (!defined('MYSQLI_TYPE_STRING')) define('MYSQLI_TYPE_STRING', 243);\\nif (!defined('MYSQLI_TYPE_GEOMETRY')) define('MYSQLI_TYPE_GEOMETRY', 255);\\n\\n// Ensure MySQLi flags constants are defined for phpMyAdmin.\\nif (!defined('MYSQLI_NOT_NULL_FLAG')) define('MYSQLI_NOT_NULL_FLAG', 1);\\nif (!defined('MYSQLI_PRI_KEY_FLAG')) define('MYSQLI_PRI_KEY_FLAG', 2);\\nif (!defined('MYSQLI_UNIQUE_KEY_FLAG')) define('MYSQLI_UNIQUE_KEY_FLAG', 4);\\nif (!defined('MYSQLI_MULTIPLE_KEY_FLAG')) define('MYSQLI_MULTIPLE_KEY_FLAG', 8);\\nif (!defined('MYSQLI_BLOB_FLAG')) define('MYSQLI_BLOB_FLAG', 16);\\nif (!defined('MYSQLI_UNSIGNED_FLAG')) define('MYSQLI_UNSIGNED_FLAG', 32);\\nif (!defined('MYSQLI_ZEROFILL_FLAG')) define('MYSQLI_ZEROFILL_FLAG', 64);\\nif (!defined('MYSQLI_BINARY_FLAG')) define('MYSQLI_BINARY_FLAG', 128);\\nif (!defined('MYSQLI_ENUM_FLAG')) define('MYSQLI_ENUM_FLAG', 256);\\nif (!defined('MYSQLI_AUTO_INCREMENT_FLAG')) define('MYSQLI_AUTO_INCREMENT_FLAG', 512);\\nif (!defined('MYSQLI_TIMESTAMP_FLAG')) define('MYSQLI_TIMESTAMP_FLAG', 1024);\\nif (!defined('MYSQLI_SET_FLAG')) define('MYSQLI_SET_FLAG', 2048);\\nif (!defined('MYSQLI_NO_DEFAULT_VALUE_FLAG')) define('MYSQLI_NO_DEFAULT_VALUE_FLAG', 4096);\\nif (!defined('MYSQLI_ON_UPDATE_NOW_FLAG')) define('MYSQLI_ON_UPDATE_NOW_FLAG', 8192);\\nif (!defined('MYSQLI_PART_KEY_FLAG')) define('MYSQLI_PART_KEY_FLAG', 16384);\\nif (!defined('MYSQLI_NUM_FLAG')) define('MYSQLI_NUM_FLAG', 32768);\\nif (!defined('MYSQLI_GROUP_FLAG')) define('MYSQLI_GROUP_FLAG', 32768);\\n\\n/**\\n * A custom result class for the MySQL-on-SQLite driver.\\n *\\n * This implementation is based on the original PhpMyAdmin\\\\Dbal\\\\MysqliResult class.\\n *\\n * @see https://github.com/phpmyadmin/phpmyadmin/blob/142c0cf3be84c346174b730b6aa3ebcf44029256/src/Dbal/MysqliResult.php\\n */\\nclass Result implements ResultInterface {\\n\\t/** @var array */\\n\\tprivate $rows = array();\\n\\n\\t/** @var array */\\n\\tprivate $columns = array();\\n\\n\\t/** @var int */\\n\\tprivate $row_offset = 0;\\n\\n\\tpublic function __construct($rows, $columns) {\\n\\t\\t$this->rows = array();\\n\\t\\tif (is_array($rows)) {\\n\\t\\t\\tforeach ($rows as $row) {\\n\\t\\t\\t\\t$this->rows[] = (array) $row;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t$this->columns = $columns;\\n\\t}\\n\\n\\tpublic function fetchAllAssoc(): array {\\n\\t\\treturn $this->rows;\\n\\t}\\n\\n\\tpublic function fetchAllColumn(): array {\\n\\t\\treturn array_column($this->rows, 0);\\n\\t}\\n\\n\\tpublic function fetchAllKeyPair(): array {\\n\\t\\treturn array_combine(\\n\\t\\t\\tarray_column($this->rows, 0),\\n\\t\\t\\tarray_column($this->rows, 1)\\n\\t\\t);\\n\\t}\\n\\n\\tpublic function fetchAssoc(): array {\\n\\t\\t$row = $this->rows[$this->row_offset++] ?? false;\\n\\t\\tif ($row === false) {\\n\\t\\t\\treturn array();\\n\\t\\t}\\n\\t\\treturn $row;\\n\\t}\\n\\n\\tpublic function fetchRow(): array {\\n\\t\\t$row = $this->rows[$this->row_offset++] ?? false;\\n\\t\\tif ($row === false) {\\n\\t\\t\\treturn [];\\n\\t\\t}\\n\\t\\treturn array_values($row);\\n\\t}\\n\\n\\tpublic function fetchValue($field = 0) {\\n\\t\\tif (is_string($field)) {\\n $row = $this->fetchAssoc();\\n } else {\\n $row = $this->fetchRow();\\n }\\n\\t\\treturn $row[$field] ?? false;\\n\\t}\\n\\n\\tpublic function getFieldNames(): array {\\n\\t\\t$names = array();\\n\\t\\tforeach ($this->columns as $column) {\\n\\t\\t\\t$names[] = $column['name'];\\n\\t\\t}\\n\\t\\treturn $names;\\n\\t}\\n\\n\\tpublic function getFieldsMeta(): array {\\n\\t\\t$meta = array();\\n\\t\\tforeach ($this->columns as $column) {\\n\\t\\t\\t$flags = $column['flags'] ?? array();\\n\\n\\t\\t\\t// PhpMyAdmin expects MySQLi-like column metadata rather than PDO syntax.\\n\\t\\t\\t// The SQLite driver provides it in \\\"mysqli:\\\" prefixed metadata keys.\\n\\t\\t\\tforeach ($column as $key => $value) {\\n\\t\\t\\t\\tif (strpos($key, 'mysqli:') === 0) {\\n\\t\\t\\t\\t\\t$column[substr($key, 7)] = $value;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\t\\t\\t// Convert PDO-style flags array to MySQLi-style integer bitmask.\\n\\t\\t\\t// TODO: Remove this when the driver implements \\\"mysqli:flags\\\".\\n\\t\\t\\t$mysqli_flags = 0;\\n\\t\\t\\tforeach ($flags as $flag) {\\n\\t\\t\\t\\tswitch ($flag) {\\n\\t\\t\\t\\t\\tcase 'primary_key':\\n\\t\\t\\t\\t\\t\\t$mysqli_flags |= \\\\MYSQLI_PRI_KEY_FLAG;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\tcase 'unique_key':\\n\\t\\t\\t\\t\\t\\t$mysqli_flags |= \\\\MYSQLI_UNIQUE_KEY_FLAG;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\tcase 'not_null':\\n\\t\\t\\t\\t\\t\\t$mysqli_flags |= \\\\MYSQLI_NOT_NULL_FLAG;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\tcase 'auto_increment':\\n\\t\\t\\t\\t\\t\\t$mysqli_flags |= \\\\MYSQLI_AUTO_INCREMENT_FLAG;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\t$column['flags'] = $mysqli_flags;\\n\\n\\t\\t\\t$field = (object) $column;\\n\\t\\t\\t$meta[] = new FieldMetadata($field->type, $field->flags, $field);\\n\\t\\t}\\n\\t\\treturn $meta;\\n\\t}\\n\\n\\tpublic function getIterator(): Generator {\\n\\t\\t$this->row_offset = 0;\\n\\t\\tforeach ($this->rows as $row) {\\n\\t\\t\\tyield $row;\\n\\t\\t}\\n\\t}\\n\\n\\tpublic function numFields(): int {\\n\\t\\treturn count($this->columns);\\n\\t}\\n\\n\\tpublic function numRows() {\\n\\t\\treturn count($this->rows);\\n\\t}\\n\\n\\tpublic function seek(int $offset): bool {\\n\\t\\t$this->row_offset = $offset;\\n\\t\\tif ($this->row_offset >= count($this->rows)) {\\n\\t\\t\\treturn false;\\n\\t\\t}\\n\\t\\treturn true;\\n\\t}\\n}\\n\\n/**\\n * A custom DBI extension for the MySQL-on-SQLite driver.\\n *\\n * This implementation is based on the original PhpMyAdmin\\\\Dbal\\\\DbiMysqli class.\\n *\\n * @see https://github.com/phpmyadmin/phpmyadmin/blob/962857e4f63d42e38f11ff4d63f5e722018add76/libraries/classes/Dbal/DbiMysqli.php\\n */\\nclass DbiMysqli implements DbiExtension {\\n\\t/** @var WP_SQLite_Driver */\\n private $driver;\\n\\n\\t/** @var string */\\n\\tprivate $last_error_message = '';\\n\\n\\t/** @var int */\\n\\tprivate $last_error_number = 0;\\n\\n public function connect($user, $password, array $server) {\\n\\t\\tglobal $wp_env;\\n\\t\\t$pdo = new PDO('sqlite:' . $wp_env['db']['path']);\\n\\t\\t$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);\\n $this->driver = new WP_SQLite_Driver(\\n\\t\\t\\tnew WP_SQLite_Connection(array('pdo' => $pdo)),\\n\\t\\t\\t'wordpress'\\n\\t\\t);\\n\\t\\treturn $this->driver;\\n }\\n\\n public function selectDb($databaseName, $link): bool {\\n\\t\\t$link->query(sprintf('USE %s', $link->get_connection()->quote_identifier($databaseName)));\\n\\t\\treturn true;\\n }\\n\\n public function realQuery(string $query, $link, int $options) {\\n\\t\\ttry {\\n\\t\\t\\t$this->last_error_message = '';\\n\\t\\t\\t$this->last_error_number = 0;\\n\\t\\t\\t$result = $link->query($query);\\n\\t\\t} catch (Throwable $e) {\\n\\t\\t\\t$this->last_error_message = $e->getMessage();\\n\\t\\t\\t$this->last_error_number = $e->getCode();\\n\\t\\t\\treturn false;\\n\\t\\t}\\n\\t\\tif ($result === false) {\\n\\t\\t\\treturn false;\\n\\t\\t}\\n return new Result($result, $link->get_last_column_meta());\\n }\\n\\n public function realMultiQuery($link, $query): bool {\\n\\t\\treturn false; // Multi-query not implemented.\\n }\\n\\n public function moreResults($link): bool {\\n\\t\\treturn false; // Multi-query not implemented.\\n }\\n\\n public function nextResult($link): bool {\\n\\t\\treturn false; // Multi-query not implemented.\\n }\\n\\n public function storeResult($link) {\\n\\t\\treturn false; // Multi-query not implemented.\\n }\\n\\n public function getHostInfo($link) {\\n\\t\\treturn 'WorPress Playground connection';\\n }\\n\\n public function getProtoInfo($link) {\\n return 10;\\n }\\n\\n public function getClientInfo() {\\n\\t\\treturn 'mysql-on-sqlite 8.0.38';\\n }\\n\\n public function getError($link): string\\n {\\n\\t\\t$error_number = $this->last_error_number;\\n\\t\\t$error_message = $this->last_error_message;\\n\\t\\t$GLOBALS['errno'] = $error_number;\\n\\t\\tif ($error_number === 0 || $error_message === '') {\\n\\t\\t\\treturn '';\\n\\t\\t}\\n\\t\\treturn Utilities::formatError($error_number, $error_message);\\n }\\n\\n public function affectedRows($link) {\\n\\t\\t$value = $link->get_last_return_value();\\n\\t\\treturn is_int($value) ? $value : 0;\\n }\\n\\n public function escapeString($link, $string) {\\n\\t\\t// For some reason, using \\\"$link->get_connection()->quote($string)\\\"\\n\\t\\t// causes the strings to be double-quoted. Let's skip the quoting.\\n\\t\\treturn $string;\\n }\\n\\n public function prepare($link, string $query) {\\n throw new Exception('Not implemented');\\n }\\n}\\n\""],"names":["DbiMysqli"],"mappings":"gFAAA,MAAAA,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA"}