PluginProbe
SQLite Database Integration / 2.2.0
SQLite Database Integration v2.2.0
3.0.2 3.0.1 trunk 2.1.13 2.1.14 2.1.15 2.1.16 2.2.0 2.2.1 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.17 2.2.18 2.2.19 2.2.2 2.2.20 2.2.21 2.2.22 2.2.23 2.2.3 All 32 releases
← All changes | wp-includes/sqlite/class-wp-sqlite-db.php +15 -69 2.2.162.2.0 View file →
@@ -306,17 +306,22 @@
306 306 if ( isset( $GLOBALS['@pdo'] ) ) {
307 307 $pdo = $GLOBALS['@pdo'];
308 308 }
309 309 if ( defined( 'WP_SQLITE_AST_DRIVER' ) && WP_SQLITE_AST_DRIVER ) {
310 - if ( null === $this->dbname || '' === $this->dbname ) {
311 - $this->bail(
312 - 'The database name was not set. The SQLite driver requires a database name to be set to emulate MySQL information schema tables.',
313 - 'db_connect_fail'
314 - );
315 - return false;
316 - }
317 -
318 - require_once __DIR__ . '/../../wp-pdo-mysql-on-sqlite.php';
310 + require_once __DIR__ . '/../../wp-includes/parser/class-wp-parser-grammar.php';
311 + require_once __DIR__ . '/../../wp-includes/parser/class-wp-parser.php';
312 + require_once __DIR__ . '/../../wp-includes/parser/class-wp-parser-node.php';
313 + require_once __DIR__ . '/../../wp-includes/parser/class-wp-parser-token.php';
314 + require_once __DIR__ . '/../../wp-includes/mysql/class-wp-mysql-token.php';
315 + require_once __DIR__ . '/../../wp-includes/mysql/class-wp-mysql-lexer.php';
316 + require_once __DIR__ . '/../../wp-includes/mysql/class-wp-mysql-parser.php';
317 + require_once __DIR__ . '/../../wp-includes/sqlite-ast/class-wp-sqlite-connection.php';
318 + require_once __DIR__ . '/../../wp-includes/sqlite-ast/class-wp-sqlite-configurator.php';
319 + require_once __DIR__ . '/../../wp-includes/sqlite-ast/class-wp-sqlite-driver.php';
320 + require_once __DIR__ . '/../../wp-includes/sqlite-ast/class-wp-sqlite-driver-exception.php';
321 + require_once __DIR__ . '/../../wp-includes/sqlite-ast/class-wp-sqlite-information-schema-builder.php';
322 + require_once __DIR__ . '/../../wp-includes/sqlite-ast/class-wp-sqlite-information-schema-exception.php';
323 + require_once __DIR__ . '/../../wp-includes/sqlite-ast/class-wp-sqlite-information-schema-reconstructor.php';
319 324 $this->ensure_database_directory( FQDB );
320 325
321 326 try {
322 327 $connection = new WP_SQLite_Connection(
@@ -394,14 +399,8 @@
394 399 * @return int|bool Boolean true for CREATE, ALTER, TRUNCATE and DROP queries. Number of rows
395 400 * affected/selected for all other queries. Boolean false on error.
396 401 */
397 402 public function query( $query ) {
398 - // Query Monitor integration:
399 - $query_monitor_active = defined( 'SQLITE_QUERY_MONITOR_LOADED' ) && SQLITE_QUERY_MONITOR_LOADED;
400 - if ( $query_monitor_active && $this->show_errors ) {
401 - $this->hide_errors();
402 - }
403 -
404 403 if ( ! $this->ready ) {
405 404 return false;
406 405 }
407 406
@@ -419,11 +418,8 @@
419 418
420 419 // Keep track of the last query for debug.
421 420 $this->last_query = $query;
422 421
423 - // Save the query count before running another query.
424 - $last_query_count = count( $this->queries ?? array() );
425 -
426 422 /*
427 423 * @TODO: WPDB uses "$this->check_current_query" to check table/column
428 424 * charset and strip all invalid characters from the query.
429 425 * This is an involved process that we can bypass for SQLite,
@@ -473,37 +469,8 @@
473 469 $this->num_rows = $num_rows;
474 470 $return_val = $num_rows;
475 471 }
476 472
477 - // Query monitor integration:
478 - if ( $query_monitor_active && class_exists( 'QM_Backtrace' ) ) {
479 - if ( did_action( 'qm/cease' ) ) {
480 - $this->queries = array();
481 - }
482 -
483 - $i = $last_query_count;
484 - if ( ! isset( $this->queries[ $i ] ) ) {
485 - return $return_val;
486 - }
487 -
488 - $this->queries[ $i ]['trace'] = new QM_Backtrace();
489 - if ( ! isset( $this->queries[ $i ][3] ) ) {
490 - $this->queries[ $i ][3] = $this->time_start;
491 - }
492 -
493 - if ( $this->last_error && ! $this->suppress_errors ) {
494 - $this->queries[ $i ]['result'] = new WP_Error( 'qmdb', $this->last_error );
495 - } else {
496 - $this->queries[ $i ]['result'] = (int) $return_val;
497 - }
498 -
499 - // Add SQLite query data.
500 - if ( $this->dbh instanceof WP_SQLite_Driver ) {
501 - $this->queries[ $i ]['sqlite_queries'] = $this->dbh->get_last_sqlite_queries();
502 - } else {
503 - $this->queries[ $i ]['sqlite_queries'] = $this->dbh->executed_sqlite_queries;
504 - }
505 - }
506 473 return $return_val;
507 474 }
508 475
509 476 /**
@@ -553,30 +520,9 @@
553 520 protected function load_col_info() {
554 521 if ( $this->col_info ) {
555 522 return;
556 523 }
557 - if ( $this->dbh instanceof WP_SQLite_Driver ) {
558 - $this->col_info = array();
559 - foreach ( $this->dbh->get_last_column_meta() as $column ) {
560 - $this->col_info[] = (object) array(
561 - 'name' => $column['name'],
562 - 'orgname' => $column['mysqli:orgname'],
563 - 'table' => $column['table'],
564 - 'orgtable' => $column['mysqli:orgtable'],
565 - 'def' => '', // Unused, always ''.
566 - 'db' => $column['mysqli:db'],
567 - 'catalog' => 'def', // Unused, always 'def'.
568 - 'max_length' => 0, // As of PHP 8.1, this is always 0.
569 - 'length' => $column['len'],
570 - 'charsetnr' => $column['mysqli:charsetnr'],
571 - 'flags' => $column['mysqli:flags'],
572 - 'type' => $column['mysqli:type'],
573 - 'decimals' => $column['precision'],
574 - );
575 - }
576 - } else {
577 - $this->col_info = $this->dbh->get_columns();
578 - }
524 + $this->col_info = $this->dbh->get_columns();
579 525 }
580 526
581 527 /**
582 528 * Method to return what the database can do.