@wp-playground/tools 3.0.51
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.
- package/DbiMysqli-CmlcCdDi.js +344 -0
- package/DbiMysqli-CmlcCdDi.js.map +1 -0
- package/DbiMysqli-IfZRkV2V.cjs +341 -0
- package/DbiMysqli-IfZRkV2V.cjs.map +1 -0
- package/config.inc-BPj6j876.cjs +30 -0
- package/config.inc-BPj6j876.cjs.map +1 -0
- package/config.inc-Bc6yvduk.js +33 -0
- package/config.inc-Bc6yvduk.js.map +1 -0
- package/index.cjs +2 -0
- package/index.cjs.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +42 -0
- package/index.js.map +1 -0
- package/package.json +70 -0
- package/phpmyadmin/index.d.ts +15 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
const t = `<?php declare(strict_types = 1);
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A phpMyAdmin DBI extension for the MySQL-on-SQLite driver.
|
|
5
|
+
*
|
|
6
|
+
* This implementation is based on the original PhpMyAdmin\\Dbal\\DbiMysqli class.
|
|
7
|
+
* It is modified to use the MySQL-on-SQLite driver instead of MySQLi extension.
|
|
8
|
+
*
|
|
9
|
+
* @see https://github.com/phpmyadmin/phpmyadmin/blob/962857e4f63d42e38f11ff4d63f5e722018add76/libraries/classes/Dbal/DbiMysqli.php
|
|
10
|
+
* @see https://github.com/phpmyadmin/phpmyadmin/blob/142c0cf3be84c346174b730b6aa3ebcf44029256/src/Dbal/MysqliResult.php
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
namespace PhpMyAdmin\\Dbal;
|
|
14
|
+
|
|
15
|
+
use Closure;
|
|
16
|
+
use Exception;
|
|
17
|
+
use Generator;
|
|
18
|
+
use PDO;
|
|
19
|
+
use PhpMyAdmin\\FieldMetadata;
|
|
20
|
+
use PhpMyAdmin\\Query\\Utilities;
|
|
21
|
+
use Throwable;
|
|
22
|
+
use WP_SQLite_Connection;
|
|
23
|
+
use WP_SQLite_Driver;
|
|
24
|
+
|
|
25
|
+
// Load the SQLite driver.
|
|
26
|
+
require_once '/internal/shared/sqlite-database-integration/wp-pdo-mysql-on-sqlite.php';
|
|
27
|
+
|
|
28
|
+
// Supress the following phpMyAdmin warning:
|
|
29
|
+
// "The mysqlnd extension is missing. Please check your PHP configuration."
|
|
30
|
+
Closure::bind(
|
|
31
|
+
function () {
|
|
32
|
+
$this->errors = array_values(
|
|
33
|
+
array_filter(
|
|
34
|
+
$this->errors,
|
|
35
|
+
function ($error) {
|
|
36
|
+
$skip = (
|
|
37
|
+
strpos($error->getMessage(), 'mysqlnd') !== false
|
|
38
|
+
&& strpos($error->getMessage(), 'extension is missing') !== false
|
|
39
|
+
);
|
|
40
|
+
return !$skip;
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
$GLOBALS['errorHandler'],
|
|
46
|
+
$GLOBALS['errorHandler']
|
|
47
|
+
)();
|
|
48
|
+
|
|
49
|
+
// Ensure MySQLi type constants are defined for phpMyAdmin.
|
|
50
|
+
if (!defined('MYSQLI_TYPE_DECIMAL')) define('MYSQLI_TYPE_DECIMAL', 0);
|
|
51
|
+
if (!defined('MYSQLI_TYPE_TINY')) define('MYSQLI_TYPE_TINY', 1);
|
|
52
|
+
if (!defined('MYSQLI_TYPE_CHAR')) define('MYSQLI_TYPE_CHAR', 1);
|
|
53
|
+
if (!defined('MYSQLI_TYPE_SHORT')) define('MYSQLI_TYPE_SHORT', 2);
|
|
54
|
+
if (!defined('MYSQLI_TYPE_LONG')) define('MYSQLI_TYPE_LONG', 3);
|
|
55
|
+
if (!defined('MYSQLI_TYPE_FLOAT')) define('MYSQLI_TYPE_FLOAT', 4);
|
|
56
|
+
if (!defined('MYSQLI_TYPE_DOUBLE')) define('MYSQLI_TYPE_DOUBLE', 5);
|
|
57
|
+
if (!defined('MYSQLI_TYPE_NULL')) define('MYSQLI_TYPE_NULL', 6);
|
|
58
|
+
if (!defined('MYSQLI_TYPE_TIMESTAMP')) define('MYSQLI_TYPE_TIMESTAMP', 7);
|
|
59
|
+
if (!defined('MYSQLI_TYPE_LONGLONG')) define('MYSQLI_TYPE_LONGLONG', 8);
|
|
60
|
+
if (!defined('MYSQLI_TYPE_INT24')) define('MYSQLI_TYPE_INT24', 9);
|
|
61
|
+
if (!defined('MYSQLI_TYPE_DATE')) define('MYSQLI_TYPE_DATE', 10);
|
|
62
|
+
if (!defined('MYSQLI_TYPE_TIME')) define('MYSQLI_TYPE_TIME', 11);
|
|
63
|
+
if (!defined('MYSQLI_TYPE_DATETIME')) define('MYSQLI_TYPE_DATETIME', 12);
|
|
64
|
+
if (!defined('MYSQLI_TYPE_YEAR')) define('MYSQLI_TYPE_YEAR', 13);
|
|
65
|
+
if (!defined('MYSQLI_TYPE_NEWDATE')) define('MYSQLI_TYPE_NEWDATE', 14);
|
|
66
|
+
if (!defined('MYSQLI_TYPE_BIT')) define('MYSQLI_TYPE_BIT', 16);
|
|
67
|
+
if (!defined('MYSQLI_TYPE_VECTOR')) define('MYSQLI_TYPE_VECTOR', 242);
|
|
68
|
+
if (!defined('MYSQLI_TYPE_JSON')) define('MYSQLI_TYPE_JSON', 245);
|
|
69
|
+
if (!defined('MYSQLI_TYPE_NEWDECIMAL')) define('MYSQLI_TYPE_NEWDECIMAL', 246);
|
|
70
|
+
if (!defined('MYSQLI_TYPE_ENUM')) define('MYSQLI_TYPE_ENUM', 247);
|
|
71
|
+
if (!defined('MYSQLI_TYPE_SET')) define('MYSQLI_TYPE_SET', 248);
|
|
72
|
+
if (!defined('MYSQLI_TYPE_TINY_BLOB')) define('MYSQLI_TYPE_TINY_BLOB', 249);
|
|
73
|
+
if (!defined('MYSQLI_TYPE_MEDIUM_BLOB')) define('MYSQLI_TYPE_MEDIUM_BLOB', 250);
|
|
74
|
+
if (!defined('MYSQLI_TYPE_LONG_BLOB')) define('MYSQLI_TYPE_LONG_BLOB', 251);
|
|
75
|
+
if (!defined('MYSQLI_TYPE_BLOB')) define('MYSQLI_TYPE_BLOB', 252);
|
|
76
|
+
if (!defined('MYSQLI_TYPE_VAR_STRING')) define('MYSQLI_TYPE_VAR_STRING', 253);
|
|
77
|
+
if (!defined('MYSQLI_TYPE_STRING')) define('MYSQLI_TYPE_STRING', 243);
|
|
78
|
+
if (!defined('MYSQLI_TYPE_GEOMETRY')) define('MYSQLI_TYPE_GEOMETRY', 255);
|
|
79
|
+
|
|
80
|
+
// Ensure MySQLi flags constants are defined for phpMyAdmin.
|
|
81
|
+
if (!defined('MYSQLI_NOT_NULL_FLAG')) define('MYSQLI_NOT_NULL_FLAG', 1);
|
|
82
|
+
if (!defined('MYSQLI_PRI_KEY_FLAG')) define('MYSQLI_PRI_KEY_FLAG', 2);
|
|
83
|
+
if (!defined('MYSQLI_UNIQUE_KEY_FLAG')) define('MYSQLI_UNIQUE_KEY_FLAG', 4);
|
|
84
|
+
if (!defined('MYSQLI_MULTIPLE_KEY_FLAG')) define('MYSQLI_MULTIPLE_KEY_FLAG', 8);
|
|
85
|
+
if (!defined('MYSQLI_BLOB_FLAG')) define('MYSQLI_BLOB_FLAG', 16);
|
|
86
|
+
if (!defined('MYSQLI_UNSIGNED_FLAG')) define('MYSQLI_UNSIGNED_FLAG', 32);
|
|
87
|
+
if (!defined('MYSQLI_ZEROFILL_FLAG')) define('MYSQLI_ZEROFILL_FLAG', 64);
|
|
88
|
+
if (!defined('MYSQLI_BINARY_FLAG')) define('MYSQLI_BINARY_FLAG', 128);
|
|
89
|
+
if (!defined('MYSQLI_ENUM_FLAG')) define('MYSQLI_ENUM_FLAG', 256);
|
|
90
|
+
if (!defined('MYSQLI_AUTO_INCREMENT_FLAG')) define('MYSQLI_AUTO_INCREMENT_FLAG', 512);
|
|
91
|
+
if (!defined('MYSQLI_TIMESTAMP_FLAG')) define('MYSQLI_TIMESTAMP_FLAG', 1024);
|
|
92
|
+
if (!defined('MYSQLI_SET_FLAG')) define('MYSQLI_SET_FLAG', 2048);
|
|
93
|
+
if (!defined('MYSQLI_NO_DEFAULT_VALUE_FLAG')) define('MYSQLI_NO_DEFAULT_VALUE_FLAG', 4096);
|
|
94
|
+
if (!defined('MYSQLI_ON_UPDATE_NOW_FLAG')) define('MYSQLI_ON_UPDATE_NOW_FLAG', 8192);
|
|
95
|
+
if (!defined('MYSQLI_PART_KEY_FLAG')) define('MYSQLI_PART_KEY_FLAG', 16384);
|
|
96
|
+
if (!defined('MYSQLI_NUM_FLAG')) define('MYSQLI_NUM_FLAG', 32768);
|
|
97
|
+
if (!defined('MYSQLI_GROUP_FLAG')) define('MYSQLI_GROUP_FLAG', 32768);
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* A custom result class for the MySQL-on-SQLite driver.
|
|
101
|
+
*
|
|
102
|
+
* This implementation is based on the original PhpMyAdmin\\Dbal\\MysqliResult class.
|
|
103
|
+
*
|
|
104
|
+
* @see https://github.com/phpmyadmin/phpmyadmin/blob/142c0cf3be84c346174b730b6aa3ebcf44029256/src/Dbal/MysqliResult.php
|
|
105
|
+
*/
|
|
106
|
+
class Result implements ResultInterface {
|
|
107
|
+
/** @var array */
|
|
108
|
+
private $rows = array();
|
|
109
|
+
|
|
110
|
+
/** @var array */
|
|
111
|
+
private $columns = array();
|
|
112
|
+
|
|
113
|
+
/** @var int */
|
|
114
|
+
private $row_offset = 0;
|
|
115
|
+
|
|
116
|
+
public function __construct($rows, $columns) {
|
|
117
|
+
$this->rows = array();
|
|
118
|
+
if (is_array($rows)) {
|
|
119
|
+
foreach ($rows as $row) {
|
|
120
|
+
$this->rows[] = (array) $row;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
$this->columns = $columns;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public function fetchAllAssoc(): array {
|
|
127
|
+
return $this->rows;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
public function fetchAllColumn(): array {
|
|
131
|
+
return array_column($this->rows, 0);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public function fetchAllKeyPair(): array {
|
|
135
|
+
return array_combine(
|
|
136
|
+
array_column($this->rows, 0),
|
|
137
|
+
array_column($this->rows, 1)
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public function fetchAssoc(): array {
|
|
142
|
+
$row = $this->rows[$this->row_offset++] ?? false;
|
|
143
|
+
if ($row === false) {
|
|
144
|
+
return array();
|
|
145
|
+
}
|
|
146
|
+
return $row;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public function fetchRow(): array {
|
|
150
|
+
$row = $this->rows[$this->row_offset++] ?? false;
|
|
151
|
+
if ($row === false) {
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
return array_values($row);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public function fetchValue($field = 0) {
|
|
158
|
+
if (is_string($field)) {
|
|
159
|
+
$row = $this->fetchAssoc();
|
|
160
|
+
} else {
|
|
161
|
+
$row = $this->fetchRow();
|
|
162
|
+
}
|
|
163
|
+
return $row[$field] ?? false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
public function getFieldNames(): array {
|
|
167
|
+
$names = array();
|
|
168
|
+
foreach ($this->columns as $column) {
|
|
169
|
+
$names[] = $column['name'];
|
|
170
|
+
}
|
|
171
|
+
return $names;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
public function getFieldsMeta(): array {
|
|
175
|
+
$meta = array();
|
|
176
|
+
foreach ($this->columns as $column) {
|
|
177
|
+
$flags = $column['flags'] ?? array();
|
|
178
|
+
|
|
179
|
+
// PhpMyAdmin expects MySQLi-like column metadata rather than PDO syntax.
|
|
180
|
+
// The SQLite driver provides it in "mysqli:" prefixed metadata keys.
|
|
181
|
+
foreach ($column as $key => $value) {
|
|
182
|
+
if (strpos($key, 'mysqli:') === 0) {
|
|
183
|
+
$column[substr($key, 7)] = $value;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Convert PDO-style flags array to MySQLi-style integer bitmask.
|
|
188
|
+
// TODO: Remove this when the driver implements "mysqli:flags".
|
|
189
|
+
$mysqli_flags = 0;
|
|
190
|
+
foreach ($flags as $flag) {
|
|
191
|
+
switch ($flag) {
|
|
192
|
+
case 'primary_key':
|
|
193
|
+
$mysqli_flags |= \\MYSQLI_PRI_KEY_FLAG;
|
|
194
|
+
break;
|
|
195
|
+
case 'unique_key':
|
|
196
|
+
$mysqli_flags |= \\MYSQLI_UNIQUE_KEY_FLAG;
|
|
197
|
+
break;
|
|
198
|
+
case 'not_null':
|
|
199
|
+
$mysqli_flags |= \\MYSQLI_NOT_NULL_FLAG;
|
|
200
|
+
break;
|
|
201
|
+
case 'auto_increment':
|
|
202
|
+
$mysqli_flags |= \\MYSQLI_AUTO_INCREMENT_FLAG;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
$column['flags'] = $mysqli_flags;
|
|
207
|
+
|
|
208
|
+
$field = (object) $column;
|
|
209
|
+
$meta[] = new FieldMetadata($field->type, $field->flags, $field);
|
|
210
|
+
}
|
|
211
|
+
return $meta;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
public function getIterator(): Generator {
|
|
215
|
+
$this->row_offset = 0;
|
|
216
|
+
foreach ($this->rows as $row) {
|
|
217
|
+
yield $row;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
public function numFields(): int {
|
|
222
|
+
return count($this->columns);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
public function numRows() {
|
|
226
|
+
return count($this->rows);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
public function seek(int $offset): bool {
|
|
230
|
+
$this->row_offset = $offset;
|
|
231
|
+
if ($this->row_offset >= count($this->rows)) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* A custom DBI extension for the MySQL-on-SQLite driver.
|
|
240
|
+
*
|
|
241
|
+
* This implementation is based on the original PhpMyAdmin\\Dbal\\DbiMysqli class.
|
|
242
|
+
*
|
|
243
|
+
* @see https://github.com/phpmyadmin/phpmyadmin/blob/962857e4f63d42e38f11ff4d63f5e722018add76/libraries/classes/Dbal/DbiMysqli.php
|
|
244
|
+
*/
|
|
245
|
+
class DbiMysqli implements DbiExtension {
|
|
246
|
+
/** @var WP_SQLite_Driver */
|
|
247
|
+
private $driver;
|
|
248
|
+
|
|
249
|
+
/** @var string */
|
|
250
|
+
private $last_error_message = '';
|
|
251
|
+
|
|
252
|
+
/** @var int */
|
|
253
|
+
private $last_error_number = 0;
|
|
254
|
+
|
|
255
|
+
public function connect($user, $password, array $server) {
|
|
256
|
+
$pdo = new PDO('sqlite:/wordpress/wp-content/database/.ht.sqlite');
|
|
257
|
+
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
258
|
+
$this->driver = new WP_SQLite_Driver(
|
|
259
|
+
new WP_SQLite_Connection(array('pdo' => $pdo)),
|
|
260
|
+
'wordpress'
|
|
261
|
+
);
|
|
262
|
+
return $this->driver;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
public function selectDb($databaseName, $link): bool {
|
|
266
|
+
$link->query(sprintf('USE %s', $link->get_connection()->quote_identifier($databaseName)));
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
public function realQuery(string $query, $link, int $options) {
|
|
271
|
+
try {
|
|
272
|
+
$this->last_error_message = '';
|
|
273
|
+
$this->last_error_number = 0;
|
|
274
|
+
$result = $link->query($query);
|
|
275
|
+
} catch (Throwable $e) {
|
|
276
|
+
$this->last_error_message = $e->getMessage();
|
|
277
|
+
$this->last_error_number = $e->getCode();
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
if ($result === false) {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
return new Result($result, $link->get_last_column_meta());
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
public function realMultiQuery($link, $query): bool {
|
|
287
|
+
return false; // Multi-query not implemented.
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
public function moreResults($link): bool {
|
|
291
|
+
return false; // Multi-query not implemented.
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
public function nextResult($link): bool {
|
|
295
|
+
return false; // Multi-query not implemented.
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
public function storeResult($link) {
|
|
299
|
+
return false; // Multi-query not implemented.
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
public function getHostInfo($link) {
|
|
303
|
+
return 'WorPress Playground connection';
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
public function getProtoInfo($link) {
|
|
307
|
+
return 10;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
public function getClientInfo() {
|
|
311
|
+
return 'mysql-on-sqlite 8.0.38';
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
public function getError($link): string
|
|
315
|
+
{
|
|
316
|
+
$error_number = $this->last_error_number;
|
|
317
|
+
$error_message = $this->last_error_message;
|
|
318
|
+
$GLOBALS['errno'] = $error_number;
|
|
319
|
+
if ($error_number === 0 || $error_message === '') {
|
|
320
|
+
return '';
|
|
321
|
+
}
|
|
322
|
+
return Utilities::formatError($error_number, $error_message);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
public function affectedRows($link) {
|
|
326
|
+
$value = $link->get_last_return_value();
|
|
327
|
+
return is_int($value) ? $value : 0;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
public function escapeString($link, $string) {
|
|
331
|
+
// For some reason, using "$link->get_connection()->quote($string)"
|
|
332
|
+
// causes the strings to be double-quoted. Let's skip the quoting.
|
|
333
|
+
return $string;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
public function prepare($link, string $query) {
|
|
337
|
+
throw new Exception('Not implemented');
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
`;
|
|
341
|
+
export {
|
|
342
|
+
t as default
|
|
343
|
+
};
|
|
344
|
+
//# sourceMappingURL=DbiMysqli-CmlcCdDi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DbiMysqli-CmlcCdDi.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.\\nrequire_once '/internal/shared/sqlite-database-integration/wp-pdo-mysql-on-sqlite.php';\\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\\t$pdo = new PDO('sqlite:/wordpress/wp-content/database/.ht.sqlite');\\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;"}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=`<?php declare(strict_types = 1);
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A phpMyAdmin DBI extension for the MySQL-on-SQLite driver.
|
|
5
|
+
*
|
|
6
|
+
* This implementation is based on the original PhpMyAdmin\\Dbal\\DbiMysqli class.
|
|
7
|
+
* It is modified to use the MySQL-on-SQLite driver instead of MySQLi extension.
|
|
8
|
+
*
|
|
9
|
+
* @see https://github.com/phpmyadmin/phpmyadmin/blob/962857e4f63d42e38f11ff4d63f5e722018add76/libraries/classes/Dbal/DbiMysqli.php
|
|
10
|
+
* @see https://github.com/phpmyadmin/phpmyadmin/blob/142c0cf3be84c346174b730b6aa3ebcf44029256/src/Dbal/MysqliResult.php
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
namespace PhpMyAdmin\\Dbal;
|
|
14
|
+
|
|
15
|
+
use Closure;
|
|
16
|
+
use Exception;
|
|
17
|
+
use Generator;
|
|
18
|
+
use PDO;
|
|
19
|
+
use PhpMyAdmin\\FieldMetadata;
|
|
20
|
+
use PhpMyAdmin\\Query\\Utilities;
|
|
21
|
+
use Throwable;
|
|
22
|
+
use WP_SQLite_Connection;
|
|
23
|
+
use WP_SQLite_Driver;
|
|
24
|
+
|
|
25
|
+
// Load the SQLite driver.
|
|
26
|
+
require_once '/internal/shared/sqlite-database-integration/wp-pdo-mysql-on-sqlite.php';
|
|
27
|
+
|
|
28
|
+
// Supress the following phpMyAdmin warning:
|
|
29
|
+
// "The mysqlnd extension is missing. Please check your PHP configuration."
|
|
30
|
+
Closure::bind(
|
|
31
|
+
function () {
|
|
32
|
+
$this->errors = array_values(
|
|
33
|
+
array_filter(
|
|
34
|
+
$this->errors,
|
|
35
|
+
function ($error) {
|
|
36
|
+
$skip = (
|
|
37
|
+
strpos($error->getMessage(), 'mysqlnd') !== false
|
|
38
|
+
&& strpos($error->getMessage(), 'extension is missing') !== false
|
|
39
|
+
);
|
|
40
|
+
return !$skip;
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
$GLOBALS['errorHandler'],
|
|
46
|
+
$GLOBALS['errorHandler']
|
|
47
|
+
)();
|
|
48
|
+
|
|
49
|
+
// Ensure MySQLi type constants are defined for phpMyAdmin.
|
|
50
|
+
if (!defined('MYSQLI_TYPE_DECIMAL')) define('MYSQLI_TYPE_DECIMAL', 0);
|
|
51
|
+
if (!defined('MYSQLI_TYPE_TINY')) define('MYSQLI_TYPE_TINY', 1);
|
|
52
|
+
if (!defined('MYSQLI_TYPE_CHAR')) define('MYSQLI_TYPE_CHAR', 1);
|
|
53
|
+
if (!defined('MYSQLI_TYPE_SHORT')) define('MYSQLI_TYPE_SHORT', 2);
|
|
54
|
+
if (!defined('MYSQLI_TYPE_LONG')) define('MYSQLI_TYPE_LONG', 3);
|
|
55
|
+
if (!defined('MYSQLI_TYPE_FLOAT')) define('MYSQLI_TYPE_FLOAT', 4);
|
|
56
|
+
if (!defined('MYSQLI_TYPE_DOUBLE')) define('MYSQLI_TYPE_DOUBLE', 5);
|
|
57
|
+
if (!defined('MYSQLI_TYPE_NULL')) define('MYSQLI_TYPE_NULL', 6);
|
|
58
|
+
if (!defined('MYSQLI_TYPE_TIMESTAMP')) define('MYSQLI_TYPE_TIMESTAMP', 7);
|
|
59
|
+
if (!defined('MYSQLI_TYPE_LONGLONG')) define('MYSQLI_TYPE_LONGLONG', 8);
|
|
60
|
+
if (!defined('MYSQLI_TYPE_INT24')) define('MYSQLI_TYPE_INT24', 9);
|
|
61
|
+
if (!defined('MYSQLI_TYPE_DATE')) define('MYSQLI_TYPE_DATE', 10);
|
|
62
|
+
if (!defined('MYSQLI_TYPE_TIME')) define('MYSQLI_TYPE_TIME', 11);
|
|
63
|
+
if (!defined('MYSQLI_TYPE_DATETIME')) define('MYSQLI_TYPE_DATETIME', 12);
|
|
64
|
+
if (!defined('MYSQLI_TYPE_YEAR')) define('MYSQLI_TYPE_YEAR', 13);
|
|
65
|
+
if (!defined('MYSQLI_TYPE_NEWDATE')) define('MYSQLI_TYPE_NEWDATE', 14);
|
|
66
|
+
if (!defined('MYSQLI_TYPE_BIT')) define('MYSQLI_TYPE_BIT', 16);
|
|
67
|
+
if (!defined('MYSQLI_TYPE_VECTOR')) define('MYSQLI_TYPE_VECTOR', 242);
|
|
68
|
+
if (!defined('MYSQLI_TYPE_JSON')) define('MYSQLI_TYPE_JSON', 245);
|
|
69
|
+
if (!defined('MYSQLI_TYPE_NEWDECIMAL')) define('MYSQLI_TYPE_NEWDECIMAL', 246);
|
|
70
|
+
if (!defined('MYSQLI_TYPE_ENUM')) define('MYSQLI_TYPE_ENUM', 247);
|
|
71
|
+
if (!defined('MYSQLI_TYPE_SET')) define('MYSQLI_TYPE_SET', 248);
|
|
72
|
+
if (!defined('MYSQLI_TYPE_TINY_BLOB')) define('MYSQLI_TYPE_TINY_BLOB', 249);
|
|
73
|
+
if (!defined('MYSQLI_TYPE_MEDIUM_BLOB')) define('MYSQLI_TYPE_MEDIUM_BLOB', 250);
|
|
74
|
+
if (!defined('MYSQLI_TYPE_LONG_BLOB')) define('MYSQLI_TYPE_LONG_BLOB', 251);
|
|
75
|
+
if (!defined('MYSQLI_TYPE_BLOB')) define('MYSQLI_TYPE_BLOB', 252);
|
|
76
|
+
if (!defined('MYSQLI_TYPE_VAR_STRING')) define('MYSQLI_TYPE_VAR_STRING', 253);
|
|
77
|
+
if (!defined('MYSQLI_TYPE_STRING')) define('MYSQLI_TYPE_STRING', 243);
|
|
78
|
+
if (!defined('MYSQLI_TYPE_GEOMETRY')) define('MYSQLI_TYPE_GEOMETRY', 255);
|
|
79
|
+
|
|
80
|
+
// Ensure MySQLi flags constants are defined for phpMyAdmin.
|
|
81
|
+
if (!defined('MYSQLI_NOT_NULL_FLAG')) define('MYSQLI_NOT_NULL_FLAG', 1);
|
|
82
|
+
if (!defined('MYSQLI_PRI_KEY_FLAG')) define('MYSQLI_PRI_KEY_FLAG', 2);
|
|
83
|
+
if (!defined('MYSQLI_UNIQUE_KEY_FLAG')) define('MYSQLI_UNIQUE_KEY_FLAG', 4);
|
|
84
|
+
if (!defined('MYSQLI_MULTIPLE_KEY_FLAG')) define('MYSQLI_MULTIPLE_KEY_FLAG', 8);
|
|
85
|
+
if (!defined('MYSQLI_BLOB_FLAG')) define('MYSQLI_BLOB_FLAG', 16);
|
|
86
|
+
if (!defined('MYSQLI_UNSIGNED_FLAG')) define('MYSQLI_UNSIGNED_FLAG', 32);
|
|
87
|
+
if (!defined('MYSQLI_ZEROFILL_FLAG')) define('MYSQLI_ZEROFILL_FLAG', 64);
|
|
88
|
+
if (!defined('MYSQLI_BINARY_FLAG')) define('MYSQLI_BINARY_FLAG', 128);
|
|
89
|
+
if (!defined('MYSQLI_ENUM_FLAG')) define('MYSQLI_ENUM_FLAG', 256);
|
|
90
|
+
if (!defined('MYSQLI_AUTO_INCREMENT_FLAG')) define('MYSQLI_AUTO_INCREMENT_FLAG', 512);
|
|
91
|
+
if (!defined('MYSQLI_TIMESTAMP_FLAG')) define('MYSQLI_TIMESTAMP_FLAG', 1024);
|
|
92
|
+
if (!defined('MYSQLI_SET_FLAG')) define('MYSQLI_SET_FLAG', 2048);
|
|
93
|
+
if (!defined('MYSQLI_NO_DEFAULT_VALUE_FLAG')) define('MYSQLI_NO_DEFAULT_VALUE_FLAG', 4096);
|
|
94
|
+
if (!defined('MYSQLI_ON_UPDATE_NOW_FLAG')) define('MYSQLI_ON_UPDATE_NOW_FLAG', 8192);
|
|
95
|
+
if (!defined('MYSQLI_PART_KEY_FLAG')) define('MYSQLI_PART_KEY_FLAG', 16384);
|
|
96
|
+
if (!defined('MYSQLI_NUM_FLAG')) define('MYSQLI_NUM_FLAG', 32768);
|
|
97
|
+
if (!defined('MYSQLI_GROUP_FLAG')) define('MYSQLI_GROUP_FLAG', 32768);
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* A custom result class for the MySQL-on-SQLite driver.
|
|
101
|
+
*
|
|
102
|
+
* This implementation is based on the original PhpMyAdmin\\Dbal\\MysqliResult class.
|
|
103
|
+
*
|
|
104
|
+
* @see https://github.com/phpmyadmin/phpmyadmin/blob/142c0cf3be84c346174b730b6aa3ebcf44029256/src/Dbal/MysqliResult.php
|
|
105
|
+
*/
|
|
106
|
+
class Result implements ResultInterface {
|
|
107
|
+
/** @var array */
|
|
108
|
+
private $rows = array();
|
|
109
|
+
|
|
110
|
+
/** @var array */
|
|
111
|
+
private $columns = array();
|
|
112
|
+
|
|
113
|
+
/** @var int */
|
|
114
|
+
private $row_offset = 0;
|
|
115
|
+
|
|
116
|
+
public function __construct($rows, $columns) {
|
|
117
|
+
$this->rows = array();
|
|
118
|
+
if (is_array($rows)) {
|
|
119
|
+
foreach ($rows as $row) {
|
|
120
|
+
$this->rows[] = (array) $row;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
$this->columns = $columns;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public function fetchAllAssoc(): array {
|
|
127
|
+
return $this->rows;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
public function fetchAllColumn(): array {
|
|
131
|
+
return array_column($this->rows, 0);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public function fetchAllKeyPair(): array {
|
|
135
|
+
return array_combine(
|
|
136
|
+
array_column($this->rows, 0),
|
|
137
|
+
array_column($this->rows, 1)
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public function fetchAssoc(): array {
|
|
142
|
+
$row = $this->rows[$this->row_offset++] ?? false;
|
|
143
|
+
if ($row === false) {
|
|
144
|
+
return array();
|
|
145
|
+
}
|
|
146
|
+
return $row;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public function fetchRow(): array {
|
|
150
|
+
$row = $this->rows[$this->row_offset++] ?? false;
|
|
151
|
+
if ($row === false) {
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
return array_values($row);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public function fetchValue($field = 0) {
|
|
158
|
+
if (is_string($field)) {
|
|
159
|
+
$row = $this->fetchAssoc();
|
|
160
|
+
} else {
|
|
161
|
+
$row = $this->fetchRow();
|
|
162
|
+
}
|
|
163
|
+
return $row[$field] ?? false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
public function getFieldNames(): array {
|
|
167
|
+
$names = array();
|
|
168
|
+
foreach ($this->columns as $column) {
|
|
169
|
+
$names[] = $column['name'];
|
|
170
|
+
}
|
|
171
|
+
return $names;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
public function getFieldsMeta(): array {
|
|
175
|
+
$meta = array();
|
|
176
|
+
foreach ($this->columns as $column) {
|
|
177
|
+
$flags = $column['flags'] ?? array();
|
|
178
|
+
|
|
179
|
+
// PhpMyAdmin expects MySQLi-like column metadata rather than PDO syntax.
|
|
180
|
+
// The SQLite driver provides it in "mysqli:" prefixed metadata keys.
|
|
181
|
+
foreach ($column as $key => $value) {
|
|
182
|
+
if (strpos($key, 'mysqli:') === 0) {
|
|
183
|
+
$column[substr($key, 7)] = $value;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Convert PDO-style flags array to MySQLi-style integer bitmask.
|
|
188
|
+
// TODO: Remove this when the driver implements "mysqli:flags".
|
|
189
|
+
$mysqli_flags = 0;
|
|
190
|
+
foreach ($flags as $flag) {
|
|
191
|
+
switch ($flag) {
|
|
192
|
+
case 'primary_key':
|
|
193
|
+
$mysqli_flags |= \\MYSQLI_PRI_KEY_FLAG;
|
|
194
|
+
break;
|
|
195
|
+
case 'unique_key':
|
|
196
|
+
$mysqli_flags |= \\MYSQLI_UNIQUE_KEY_FLAG;
|
|
197
|
+
break;
|
|
198
|
+
case 'not_null':
|
|
199
|
+
$mysqli_flags |= \\MYSQLI_NOT_NULL_FLAG;
|
|
200
|
+
break;
|
|
201
|
+
case 'auto_increment':
|
|
202
|
+
$mysqli_flags |= \\MYSQLI_AUTO_INCREMENT_FLAG;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
$column['flags'] = $mysqli_flags;
|
|
207
|
+
|
|
208
|
+
$field = (object) $column;
|
|
209
|
+
$meta[] = new FieldMetadata($field->type, $field->flags, $field);
|
|
210
|
+
}
|
|
211
|
+
return $meta;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
public function getIterator(): Generator {
|
|
215
|
+
$this->row_offset = 0;
|
|
216
|
+
foreach ($this->rows as $row) {
|
|
217
|
+
yield $row;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
public function numFields(): int {
|
|
222
|
+
return count($this->columns);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
public function numRows() {
|
|
226
|
+
return count($this->rows);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
public function seek(int $offset): bool {
|
|
230
|
+
$this->row_offset = $offset;
|
|
231
|
+
if ($this->row_offset >= count($this->rows)) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* A custom DBI extension for the MySQL-on-SQLite driver.
|
|
240
|
+
*
|
|
241
|
+
* This implementation is based on the original PhpMyAdmin\\Dbal\\DbiMysqli class.
|
|
242
|
+
*
|
|
243
|
+
* @see https://github.com/phpmyadmin/phpmyadmin/blob/962857e4f63d42e38f11ff4d63f5e722018add76/libraries/classes/Dbal/DbiMysqli.php
|
|
244
|
+
*/
|
|
245
|
+
class DbiMysqli implements DbiExtension {
|
|
246
|
+
/** @var WP_SQLite_Driver */
|
|
247
|
+
private $driver;
|
|
248
|
+
|
|
249
|
+
/** @var string */
|
|
250
|
+
private $last_error_message = '';
|
|
251
|
+
|
|
252
|
+
/** @var int */
|
|
253
|
+
private $last_error_number = 0;
|
|
254
|
+
|
|
255
|
+
public function connect($user, $password, array $server) {
|
|
256
|
+
$pdo = new PDO('sqlite:/wordpress/wp-content/database/.ht.sqlite');
|
|
257
|
+
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
258
|
+
$this->driver = new WP_SQLite_Driver(
|
|
259
|
+
new WP_SQLite_Connection(array('pdo' => $pdo)),
|
|
260
|
+
'wordpress'
|
|
261
|
+
);
|
|
262
|
+
return $this->driver;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
public function selectDb($databaseName, $link): bool {
|
|
266
|
+
$link->query(sprintf('USE %s', $link->get_connection()->quote_identifier($databaseName)));
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
public function realQuery(string $query, $link, int $options) {
|
|
271
|
+
try {
|
|
272
|
+
$this->last_error_message = '';
|
|
273
|
+
$this->last_error_number = 0;
|
|
274
|
+
$result = $link->query($query);
|
|
275
|
+
} catch (Throwable $e) {
|
|
276
|
+
$this->last_error_message = $e->getMessage();
|
|
277
|
+
$this->last_error_number = $e->getCode();
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
if ($result === false) {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
return new Result($result, $link->get_last_column_meta());
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
public function realMultiQuery($link, $query): bool {
|
|
287
|
+
return false; // Multi-query not implemented.
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
public function moreResults($link): bool {
|
|
291
|
+
return false; // Multi-query not implemented.
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
public function nextResult($link): bool {
|
|
295
|
+
return false; // Multi-query not implemented.
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
public function storeResult($link) {
|
|
299
|
+
return false; // Multi-query not implemented.
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
public function getHostInfo($link) {
|
|
303
|
+
return 'WorPress Playground connection';
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
public function getProtoInfo($link) {
|
|
307
|
+
return 10;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
public function getClientInfo() {
|
|
311
|
+
return 'mysql-on-sqlite 8.0.38';
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
public function getError($link): string
|
|
315
|
+
{
|
|
316
|
+
$error_number = $this->last_error_number;
|
|
317
|
+
$error_message = $this->last_error_message;
|
|
318
|
+
$GLOBALS['errno'] = $error_number;
|
|
319
|
+
if ($error_number === 0 || $error_message === '') {
|
|
320
|
+
return '';
|
|
321
|
+
}
|
|
322
|
+
return Utilities::formatError($error_number, $error_message);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
public function affectedRows($link) {
|
|
326
|
+
$value = $link->get_last_return_value();
|
|
327
|
+
return is_int($value) ? $value : 0;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
public function escapeString($link, $string) {
|
|
331
|
+
// For some reason, using "$link->get_connection()->quote($string)"
|
|
332
|
+
// causes the strings to be double-quoted. Let's skip the quoting.
|
|
333
|
+
return $string;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
public function prepare($link, string $query) {
|
|
337
|
+
throw new Exception('Not implemented');
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
`;exports.default=t;
|
|
341
|
+
//# sourceMappingURL=DbiMysqli-IfZRkV2V.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DbiMysqli-IfZRkV2V.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.\\nrequire_once '/internal/shared/sqlite-database-integration/wp-pdo-mysql-on-sqlite.php';\\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\\t$pdo = new PDO('sqlite:/wordpress/wp-content/database/.ht.sqlite');\\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"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=`<?php declare(strict_types = 1);
|
|
2
|
+
|
|
3
|
+
// Configure session save path for Playground environment.
|
|
4
|
+
$session_dir = '/tmp/phpmyadmin-sessions';
|
|
5
|
+
if (!is_dir($session_dir)) {
|
|
6
|
+
mkdir($session_dir, 0700, true);
|
|
7
|
+
}
|
|
8
|
+
session_save_path($session_dir);
|
|
9
|
+
|
|
10
|
+
// Enable development environment to display detailed error messages.
|
|
11
|
+
$cfg['environment'] = 'development';
|
|
12
|
+
|
|
13
|
+
// Playground-specific configuration.
|
|
14
|
+
$cfg['CheckConfigurationPermissions'] = false;
|
|
15
|
+
$cfg['VersionCheck'] = false;
|
|
16
|
+
$cfg['ShowCreateDb'] = false;
|
|
17
|
+
$cfg['ShowChgPassword'] = false;
|
|
18
|
+
|
|
19
|
+
// Cookie authentication secret.
|
|
20
|
+
$cfg['blowfish_secret'] = 'r/g+J#&)L2&p!z5gUS)d(vEU#KAynq#g';
|
|
21
|
+
|
|
22
|
+
// Server configuration
|
|
23
|
+
$cfg['Servers'][1]['host'] = '127.0.0.1';
|
|
24
|
+
$cfg['Servers'][1]['auth_type'] = 'config';
|
|
25
|
+
$cfg['Servers'][1]['user'] = 'root';
|
|
26
|
+
$cfg['Servers'][1]['password'] = '';
|
|
27
|
+
$cfg['Servers'][1]['AllowNoPassword'] = true;
|
|
28
|
+
$cfg['Servers'][1]['compress'] = false;
|
|
29
|
+
`;exports.default=e;
|
|
30
|
+
//# sourceMappingURL=config.inc-BPj6j876.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.inc-BPj6j876.cjs","sources":["../../../../packages/playground/tools/src/phpmyadmin/config.inc.php?raw"],"sourcesContent":["export default \"<?php declare(strict_types = 1);\\n\\n// Configure session save path for Playground environment.\\n$session_dir = '/tmp/phpmyadmin-sessions';\\nif (!is_dir($session_dir)) {\\n mkdir($session_dir, 0700, true);\\n}\\nsession_save_path($session_dir);\\n\\n// Enable development environment to display detailed error messages.\\n$cfg['environment'] = 'development';\\n\\n// Playground-specific configuration.\\n$cfg['CheckConfigurationPermissions'] = false;\\n$cfg['VersionCheck'] = false;\\n$cfg['ShowCreateDb'] = false;\\n$cfg['ShowChgPassword'] = false;\\n\\n// Cookie authentication secret.\\n$cfg['blowfish_secret'] = 'r/g+J#&)L2&p!z5gUS)d(vEU#KAynq#g';\\n\\n// Server configuration\\n$cfg['Servers'][1]['host'] = '127.0.0.1';\\n$cfg['Servers'][1]['auth_type'] = 'config';\\n$cfg['Servers'][1]['user'] = 'root';\\n$cfg['Servers'][1]['password'] = '';\\n$cfg['Servers'][1]['AllowNoPassword'] = true;\\n$cfg['Servers'][1]['compress'] = false;\\n\""],"names":["config_inc"],"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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const e = `<?php declare(strict_types = 1);
|
|
2
|
+
|
|
3
|
+
// Configure session save path for Playground environment.
|
|
4
|
+
$session_dir = '/tmp/phpmyadmin-sessions';
|
|
5
|
+
if (!is_dir($session_dir)) {
|
|
6
|
+
mkdir($session_dir, 0700, true);
|
|
7
|
+
}
|
|
8
|
+
session_save_path($session_dir);
|
|
9
|
+
|
|
10
|
+
// Enable development environment to display detailed error messages.
|
|
11
|
+
$cfg['environment'] = 'development';
|
|
12
|
+
|
|
13
|
+
// Playground-specific configuration.
|
|
14
|
+
$cfg['CheckConfigurationPermissions'] = false;
|
|
15
|
+
$cfg['VersionCheck'] = false;
|
|
16
|
+
$cfg['ShowCreateDb'] = false;
|
|
17
|
+
$cfg['ShowChgPassword'] = false;
|
|
18
|
+
|
|
19
|
+
// Cookie authentication secret.
|
|
20
|
+
$cfg['blowfish_secret'] = 'r/g+J#&)L2&p!z5gUS)d(vEU#KAynq#g';
|
|
21
|
+
|
|
22
|
+
// Server configuration
|
|
23
|
+
$cfg['Servers'][1]['host'] = '127.0.0.1';
|
|
24
|
+
$cfg['Servers'][1]['auth_type'] = 'config';
|
|
25
|
+
$cfg['Servers'][1]['user'] = 'root';
|
|
26
|
+
$cfg['Servers'][1]['password'] = '';
|
|
27
|
+
$cfg['Servers'][1]['AllowNoPassword'] = true;
|
|
28
|
+
$cfg['Servers'][1]['compress'] = false;
|
|
29
|
+
`;
|
|
30
|
+
export {
|
|
31
|
+
e as default
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=config.inc-Bc6yvduk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.inc-Bc6yvduk.js","sources":["../../../../packages/playground/tools/src/phpmyadmin/config.inc.php?raw"],"sourcesContent":["export default \"<?php declare(strict_types = 1);\\n\\n// Configure session save path for Playground environment.\\n$session_dir = '/tmp/phpmyadmin-sessions';\\nif (!is_dir($session_dir)) {\\n mkdir($session_dir, 0700, true);\\n}\\nsession_save_path($session_dir);\\n\\n// Enable development environment to display detailed error messages.\\n$cfg['environment'] = 'development';\\n\\n// Playground-specific configuration.\\n$cfg['CheckConfigurationPermissions'] = false;\\n$cfg['VersionCheck'] = false;\\n$cfg['ShowCreateDb'] = false;\\n$cfg['ShowChgPassword'] = false;\\n\\n// Cookie authentication secret.\\n$cfg['blowfish_secret'] = 'r/g+J#&)L2&p!z5gUS)d(vEU#KAynq#g';\\n\\n// Server configuration\\n$cfg['Servers'][1]['host'] = '127.0.0.1';\\n$cfg['Servers'][1]['auth_type'] = 'config';\\n$cfg['Servers'][1]['user'] = 'root';\\n$cfg['Servers'][1]['password'] = '';\\n$cfg['Servers'][1]['AllowNoPassword'] = true;\\n$cfg['Servers'][1]['compress'] = false;\\n\""],"names":["config_inc"],"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;"}
|
package/index.cjs
ADDED
|
@@ -0,0 +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-IfZRkV2V.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
|
+
//# sourceMappingURL=index.cjs.map
|
package/index.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../packages/playground/tools/src/phpmyadmin/index.ts"],"sourcesContent":["import type { StepDefinition } from '@wp-playground/blueprints';\n\nexport const PHPMYADMIN_VERSION = '5.2.3';\nexport const PHPMYADMIN_DOWNLOAD_URL = `https://files.phpmyadmin.net/phpMyAdmin/${PHPMYADMIN_VERSION}/phpMyAdmin-${PHPMYADMIN_VERSION}-english.zip`;\nexport const PHPMYADMIN_INSTALL_PATH = '/tools/phpmyadmin';\nexport const PHPMYADMIN_ENTRY_PATH =\n\t'/index.php?route=/database/structure&db=wordpress';\n\n/**\n * Returns the blueprint steps needed to install phpMyAdmin in Playground.\n *\n * This installs phpMyAdmin and applies the following modifications:\n * 1. Inject a \"config.inc.php\" file to configure phpMyAdmin for Playground.\n * 2. Inject a \"DbiMysqli.php\" file to implement the MySQL-on-SQLite driver.\n *\n * @returns Blueprint steps to install phpMyAdmin in Playground.\n */\nexport async function getPhpMyAdminInstallSteps(): Promise<StepDefinition[]> {\n\treturn [\n\t\t{\n\t\t\tstep: 'unzip',\n\t\t\tzipFile: {\n\t\t\t\tresource: 'url',\n\t\t\t\turl: PHPMYADMIN_DOWNLOAD_URL,\n\t\t\t},\n\t\t\textractToPath: '/tmp',\n\t\t},\n\t\t{\n\t\t\tstep: 'mkdir',\n\t\t\tpath: PHPMYADMIN_INSTALL_PATH,\n\t\t},\n\t\t{\n\t\t\tstep: 'mv',\n\t\t\tfromPath: `/tmp/phpMyAdmin-${PHPMYADMIN_VERSION}-english`,\n\t\t\ttoPath: PHPMYADMIN_INSTALL_PATH,\n\t\t},\n\t\t{\n\t\t\tstep: 'writeFile',\n\t\t\tpath: `${PHPMYADMIN_INSTALL_PATH}/libraries/classes/Dbal/DbiMysqli.php`,\n\t\t\t/* @ts-ignore */\n\t\t\tdata: (await import('./DbiMysqli.php?raw')).default as string,\n\t\t},\n\t\t{\n\t\t\tstep: 'writeFile',\n\t\t\tpath: `${PHPMYADMIN_INSTALL_PATH}/config.inc.php`,\n\t\t\t/* @ts-ignore */\n\t\t\tdata: (await import('./config.inc.php?raw')).default as string,\n\t\t},\n\t];\n}\n"],"names":["PHPMYADMIN_VERSION","PHPMYADMIN_DOWNLOAD_URL","PHPMYADMIN_INSTALL_PATH","PHPMYADMIN_ENTRY_PATH","getPhpMyAdminInstallSteps"],"mappings":"gFAEO,MAAMA,EAAqB,QACrBC,EAA0B,2CAA2CD,CAAkB,eAAeA,CAAkB,eACxHE,EAA0B,oBAC1BC,EACZ,oDAWD,eAAsBC,GAAuD,CAC5E,MAAO,CACN,CACC,KAAM,QACN,QAAS,CACR,SAAU,MACV,IAAKH,CAAA,EAEN,cAAe,MAAA,EAEhB,CACC,KAAM,QACN,KAAMC,CAAA,EAEP,CACC,KAAM,KACN,SAAU,mBAAmBF,CAAkB,WAC/C,OAAQE,CAAA,EAET,CACC,KAAM,YACN,KAAM,GAAGA,CAAuB,wCAEhC,MAAO,MAAM,QAAA,QAAA,EAAA,KAAA,IAAA,QAAO,0BAAqB,IAAG,OAAA,EAE7C,CACC,KAAM,YACN,KAAM,GAAGA,CAAuB,kBAEhC,MAAO,MAAM,QAAA,QAAA,EAAA,KAAA,IAAA,QAAO,2BAAsB,IAAG,OAAA,CAC9C,CAEF"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './phpmyadmin';
|
package/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const p = "5.2.3", e = `https://files.phpmyadmin.net/phpMyAdmin/${p}/phpMyAdmin-${p}-english.zip`, t = "/tools/phpmyadmin", i = "/index.php?route=/database/structure&db=wordpress";
|
|
2
|
+
async function a() {
|
|
3
|
+
return [
|
|
4
|
+
{
|
|
5
|
+
step: "unzip",
|
|
6
|
+
zipFile: {
|
|
7
|
+
resource: "url",
|
|
8
|
+
url: e
|
|
9
|
+
},
|
|
10
|
+
extractToPath: "/tmp"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
step: "mkdir",
|
|
14
|
+
path: t
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
step: "mv",
|
|
18
|
+
fromPath: `/tmp/phpMyAdmin-${p}-english`,
|
|
19
|
+
toPath: t
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
step: "writeFile",
|
|
23
|
+
path: `${t}/libraries/classes/Dbal/DbiMysqli.php`,
|
|
24
|
+
/* @ts-ignore */
|
|
25
|
+
data: (await import("./DbiMysqli-CmlcCdDi.js")).default
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
step: "writeFile",
|
|
29
|
+
path: `${t}/config.inc.php`,
|
|
30
|
+
/* @ts-ignore */
|
|
31
|
+
data: (await import("./config.inc-Bc6yvduk.js")).default
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
e as PHPMYADMIN_DOWNLOAD_URL,
|
|
37
|
+
i as PHPMYADMIN_ENTRY_PATH,
|
|
38
|
+
t as PHPMYADMIN_INSTALL_PATH,
|
|
39
|
+
p as PHPMYADMIN_VERSION,
|
|
40
|
+
a as getPhpMyAdminInstallSteps
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../packages/playground/tools/src/phpmyadmin/index.ts"],"sourcesContent":["import type { StepDefinition } from '@wp-playground/blueprints';\n\nexport const PHPMYADMIN_VERSION = '5.2.3';\nexport const PHPMYADMIN_DOWNLOAD_URL = `https://files.phpmyadmin.net/phpMyAdmin/${PHPMYADMIN_VERSION}/phpMyAdmin-${PHPMYADMIN_VERSION}-english.zip`;\nexport const PHPMYADMIN_INSTALL_PATH = '/tools/phpmyadmin';\nexport const PHPMYADMIN_ENTRY_PATH =\n\t'/index.php?route=/database/structure&db=wordpress';\n\n/**\n * Returns the blueprint steps needed to install phpMyAdmin in Playground.\n *\n * This installs phpMyAdmin and applies the following modifications:\n * 1. Inject a \"config.inc.php\" file to configure phpMyAdmin for Playground.\n * 2. Inject a \"DbiMysqli.php\" file to implement the MySQL-on-SQLite driver.\n *\n * @returns Blueprint steps to install phpMyAdmin in Playground.\n */\nexport async function getPhpMyAdminInstallSteps(): Promise<StepDefinition[]> {\n\treturn [\n\t\t{\n\t\t\tstep: 'unzip',\n\t\t\tzipFile: {\n\t\t\t\tresource: 'url',\n\t\t\t\turl: PHPMYADMIN_DOWNLOAD_URL,\n\t\t\t},\n\t\t\textractToPath: '/tmp',\n\t\t},\n\t\t{\n\t\t\tstep: 'mkdir',\n\t\t\tpath: PHPMYADMIN_INSTALL_PATH,\n\t\t},\n\t\t{\n\t\t\tstep: 'mv',\n\t\t\tfromPath: `/tmp/phpMyAdmin-${PHPMYADMIN_VERSION}-english`,\n\t\t\ttoPath: PHPMYADMIN_INSTALL_PATH,\n\t\t},\n\t\t{\n\t\t\tstep: 'writeFile',\n\t\t\tpath: `${PHPMYADMIN_INSTALL_PATH}/libraries/classes/Dbal/DbiMysqli.php`,\n\t\t\t/* @ts-ignore */\n\t\t\tdata: (await import('./DbiMysqli.php?raw')).default as string,\n\t\t},\n\t\t{\n\t\t\tstep: 'writeFile',\n\t\t\tpath: `${PHPMYADMIN_INSTALL_PATH}/config.inc.php`,\n\t\t\t/* @ts-ignore */\n\t\t\tdata: (await import('./config.inc.php?raw')).default as string,\n\t\t},\n\t];\n}\n"],"names":["PHPMYADMIN_VERSION","PHPMYADMIN_DOWNLOAD_URL","PHPMYADMIN_INSTALL_PATH","PHPMYADMIN_ENTRY_PATH","getPhpMyAdminInstallSteps"],"mappings":"AAEO,MAAMA,IAAqB,SACrBC,IAA0B,2CAA2CD,CAAkB,eAAeA,CAAkB,gBACxHE,IAA0B,qBAC1BC,IACZ;AAWD,eAAsBC,IAAuD;AAC5E,SAAO;AAAA,IACN;AAAA,MACC,MAAM;AAAA,MACN,SAAS;AAAA,QACR,UAAU;AAAA,QACV,KAAKH;AAAA,MAAA;AAAA,MAEN,eAAe;AAAA,IAAA;AAAA,IAEhB;AAAA,MACC,MAAM;AAAA,MACN,MAAMC;AAAA,IAAA;AAAA,IAEP;AAAA,MACC,MAAM;AAAA,MACN,UAAU,mBAAmBF,CAAkB;AAAA,MAC/C,QAAQE;AAAA,IAAA;AAAA,IAET;AAAA,MACC,MAAM;AAAA,MACN,MAAM,GAAGA,CAAuB;AAAA;AAAA,MAEhC,OAAO,MAAM,OAAO,yBAAqB,GAAG;AAAA,IAAA;AAAA,IAE7C;AAAA,MACC,MAAM;AAAA,MACN,MAAM,GAAGA,CAAuB;AAAA;AAAA,MAEhC,OAAO,MAAM,OAAO,0BAAsB,GAAG;AAAA,IAAA;AAAA,EAC9C;AAEF;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wp-playground/tools",
|
|
3
|
+
"version": "3.0.51",
|
|
4
|
+
"description": "Tools for WordPress Playground",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/WordPress/wordpress-playground"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://developer.wordpress.org/playground",
|
|
10
|
+
"author": "The WordPress contributors",
|
|
11
|
+
"license": "GPL-2.0-or-later",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./index.cjs",
|
|
14
|
+
"module": "./index.js",
|
|
15
|
+
"types": "index.d.ts",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=20.18.3",
|
|
18
|
+
"npm": ">=10.1.0"
|
|
19
|
+
},
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"import": "./index.js",
|
|
23
|
+
"require": "./index.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public",
|
|
29
|
+
"directory": "../../../dist/packages/playground/tools"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@zip.js/zip.js": "2.7.57",
|
|
33
|
+
"ajv": "8.12.0",
|
|
34
|
+
"async-lock": "1.4.1",
|
|
35
|
+
"clean-git-ref": "2.0.1",
|
|
36
|
+
"crc-32": "1.2.2",
|
|
37
|
+
"diff3": "0.0.4",
|
|
38
|
+
"express": "4.22.0",
|
|
39
|
+
"ignore": "5.3.2",
|
|
40
|
+
"ini": "4.1.2",
|
|
41
|
+
"minimisted": "2.0.1",
|
|
42
|
+
"octokit": "3.1.2",
|
|
43
|
+
"pako": "1.0.10",
|
|
44
|
+
"pify": "4.0.1",
|
|
45
|
+
"readable-stream": "3.6.2",
|
|
46
|
+
"selfsigned": "5.5.0",
|
|
47
|
+
"sha.js": "2.4.12",
|
|
48
|
+
"simple-get": "4.0.1",
|
|
49
|
+
"wasm-feature-detect": "1.8.0",
|
|
50
|
+
"ws": "8.18.3",
|
|
51
|
+
"yargs": "17.7.2",
|
|
52
|
+
"@wp-playground/blueprints": "3.0.51"
|
|
53
|
+
},
|
|
54
|
+
"packageManager": "npm@10.9.2",
|
|
55
|
+
"overrides": {
|
|
56
|
+
"rollup": "^4.34.6",
|
|
57
|
+
"react": "18.3.1",
|
|
58
|
+
"react-dom": "18.3.1",
|
|
59
|
+
"typescript": "5.4.5",
|
|
60
|
+
"@playwright/test": "1.55.1",
|
|
61
|
+
"ws": "8.18.3",
|
|
62
|
+
"tmp": "0.2.5",
|
|
63
|
+
"form-data": "^4.0.4",
|
|
64
|
+
"lodash": "^4.17.23",
|
|
65
|
+
"glob": "^9.3.0"
|
|
66
|
+
},
|
|
67
|
+
"optionalDependencies": {
|
|
68
|
+
"fs-ext": "2.1.1"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { StepDefinition } from '@wp-playground/blueprints';
|
|
2
|
+
export declare const PHPMYADMIN_VERSION = "5.2.3";
|
|
3
|
+
export declare const PHPMYADMIN_DOWNLOAD_URL = "https://files.phpmyadmin.net/phpMyAdmin/5.2.3/phpMyAdmin-5.2.3-english.zip";
|
|
4
|
+
export declare const PHPMYADMIN_INSTALL_PATH = "/tools/phpmyadmin";
|
|
5
|
+
export declare const PHPMYADMIN_ENTRY_PATH = "/index.php?route=/database/structure&db=wordpress";
|
|
6
|
+
/**
|
|
7
|
+
* Returns the blueprint steps needed to install phpMyAdmin in Playground.
|
|
8
|
+
*
|
|
9
|
+
* This installs phpMyAdmin and applies the following modifications:
|
|
10
|
+
* 1. Inject a "config.inc.php" file to configure phpMyAdmin for Playground.
|
|
11
|
+
* 2. Inject a "DbiMysqli.php" file to implement the MySQL-on-SQLite driver.
|
|
12
|
+
*
|
|
13
|
+
* @returns Blueprint steps to install phpMyAdmin in Playground.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getPhpMyAdminInstallSteps(): Promise<StepDefinition[]>;
|