Plugin Directory

Changeset 3084383

Timestamp:
05/10/2024 07:30:52 AM (3 months ago)
Author:
aristath
Message:

v2.1.10

Location:
sqlite-database-integration/trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • sqlite-database-integration/trunk/admin-page.php

    r3007929 r3084383  
    5959                <?php if ( defined( 'PERFLAB_SQLITE_DB_DROPIN_VERSION' ) ) : ?>
    6060                    <div class="notice notice-warning">
    61                     <p>
     61                        <p>
     62                            <?php
     63                            printf(
     64                                /* translators: %s: db.php drop-in path */
     65                                esc_html__( 'An older %s file was detected. Please click the button below to update the file.', 'sqlite-database-integration' ),
     66                                '<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>'
     67                            );
     68                            ?>
     69                        </p>
     70                    </div>
     71                    <a class="button button-primary" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=sqlite-integration&confirm-install&upgrade-from-pl' ), 'sqlite-install' ) ); ?>">
    6272                        <?php
    6373                        printf(
    6474                            /* translators: %s: db.php drop-in path */
    65                             esc_html__( 'An older %s file was detected. Please click the button below to update the file.', 'sqlite-database-integration' ),
     75                            esc_html__( '', 'sqlite-database-integration' ),
    6676                            '<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>'
    6777                        );
    6878                        ?>
    69                     </p>
    70                 </div>
    71                 <a class="button button-primary" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=sqlite-integration&confirm-install&upgrade-from-pl' ), 'sqlite-install' ) ); ?>">
    72                     <?php
    73                     printf(
    74                         /* translators: %s: db.php drop-in path */
    75                         esc_html__( 'Update %s file', 'sqlite-database-integration' ),
    76                         '<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>'
    77                     );
    78                     ?>
    79                 </a>
     79                    </a>
    8080                <?php else : ?>
    8181                    <div class="notice notice-error">
  • sqlite-database-integration/trunk/load.php

    r3071334 r3084383  
    44 * Description: SQLite database driver drop-in.
    55 * Author: The WordPress Team
    6  * Version: 2.1.9
     6 * Version: 2.1.
    77 * Requires PHP: 7.0
    88 * Textdomain: sqlite-database-integration
     
    1515define( 'SQLITE_MAIN_FILE', __FILE__ );
    1616
     17
    1718require_once __DIR__ . '/admin-page.php';
    1819require_once __DIR__ . '/activate.php';
  • sqlite-database-integration/trunk/readme.txt

    r3071334 r3084383  
    55Tested up to:      6.4
    66Requires PHP:      5.6
    7 Stable tag:        2.1.9
     7Stable tag:        2.1.
    88License:           GPLv2 or later
    99License URI:       https://www.gnu.org/licenses/gpl-2.0.html
  • sqlite-database-integration/trunk/wp-includes/sqlite/class-wp-sqlite-translator.php

    r3071334 r3084383  
    11291129         * SQLite does not support this behavior, so we need to add the `ON CONFLICT REPLACE` clause to the column definition.
    11301130         */
    1131         if ($field->not_null) {
     1131        if () {
    11321132            $definition .= ' ON CONFLICT REPLACE';
    11331133        }
     
    11351135         * The value of DEFAULT can be NULL. PHP would print this as an empty string, so we need a special case for it.
    11361136         */
    1137         if (null === $field->default) {
     1137        if () {
    11381138            $definition .= ' DEFAULT NULL';
    1139         } else if (false !== $field->default) {
     1139        } else) {
    11401140            $definition .= ' DEFAULT ' . $field->default;
    1141         } else if ($field->not_null) {
     1141        } else) {
    11421142            /**
    11431143             * If the column is NOT NULL, we need to provide a default value to match WPDB behavior caused by removing the STRICT_TRANS_TABLES mode.
    11441144             */
    1145             if ('text' === $field->sqlite_data_type) {
     1145            if () {
    11461146                $definition .= ' DEFAULT \'\'';
    1147             } else if (in_array($field->sqlite_data_type, array('integer', 'real'), true)) {
     1147            } else) {
    11481148                $definition .= ' DEFAULT 0';
    11491149            }
     
    14391439            }
    14401440
     1441
     1442
     1443
     1444
    14411445            $this->rewriter->consume();
    14421446        }
     
    14501454            $params                            = array();
    14511455        } elseif (
    1452             strpos( $updated_query, '@@SESSION.sql_mode' ) !== false
    1453             || strpos( $updated_query, 'CONVERT( ' ) !== false
     1456            // Examples: @@SESSION.sql_mode, @@GLOBAL.max_allowed_packet, @@character_set_client
     1457            preg_match( '/@@((SESSION|GLOBAL)\s*\.\s*)?\w+\b/i', $updated_query ) === 1 ||
     1458            strpos( $updated_query, 'CONVERT( ' ) !== false
    14541459        ) {
    14551460            /*
     
    14921497
    14931498    /**
     1499
     1500
     1501
     1502
     1503
     1504
     1505
     1506
     1507
     1508
     1509
     1510
     1511
     1512
     1513
     1514
     1515
     1516
     1517
     1518
     1519
     1520
     1521
     1522
     1523
     1524
     1525
     1526
     1527
     1528
     1529
     1530
     1531
     1532
     1533
     1534
     1535
     1536
     1537
     1538
     1539
     1540
     1541
     1542
     1543
     1544
     1545
     1546
     1547
     1548
     1549
     1550
     1551
     1552
     1553
     1554
     1555
     1556
     1557
     1558
     1559
     1560
     1561
     1562
     1563
    14941564     * Executes a TRUNCATE statement.
    14951565     */
     
    15161586        $this->rewriter->skip();
    15171587        $this->table_name = $this->rewriter->consume()->value;
    1518         $stmt             = $this->execute_sqlite_query(
     1588        $this->set_results_from_fetched_data(
     1589            $this->describe( $this->table_name )
     1590        );
     1591        if ( ! $this->results ) {
     1592            throw new PDOException( 'Table not found' );
     1593        }
     1594    }
     1595
     1596    /**
     1597     * Executes a SELECT statement.
     1598     *
     1599     * @param string $table_name The table name.
     1600     *
     1601     * @return array
     1602     */
     1603    private function describe( $table_name ) {
     1604        return $this->execute_sqlite_query(
    15191605            "SELECT
    15201606                `name` as `Field`,
     
    15251611                    END
    15261612                ) as `Null`,
    1527                 IFNULL(
     1613                (
    15281614                    d.`mysql_type`,
    15291615                    (
     
    15451631                    END
    15461632                ) as `Key`
    1547                 FROM pragma_table_info(\"$this->table_name\") p
     1633                FROM pragma_table_info(\"$table_name\") p
    15481634                LEFT JOIN " . self::DATA_TYPES_CACHE_TABLE . " d
    1549                 ON d.`table` = \"$this->table_name\"
     1635                ON d.`table` = \"$table_name\"
    15501636                AND d.`column_or_index` = p.`name`
    15511637                ;
    15521638            "
    1553         );
    1554         $this->set_results_from_fetched_data(
    1555             $stmt->fetchAll( $this->pdo_fetch_mode )
    1556         );
    1557         if ( ! $this->results ) {
    1558             throw new PDOException( 'Table not found' );
    1559         }
     1639        )
     1640        ->fetchAll( $this->pdo_fetch_mode );
    15601641    }
    15611642
    15621643    /**
    15631644     * Executes an UPDATE statement.
     1645
     1646
     1647
     1648
     1649
     1650
     1651
     1652
     1653
    15641654     */
    15651655    private function execute_update() {
    1566         $this->rewriter->consume(); // Update.
    1567 
    1568         $params = array();
     1656        $this->rewriter->consume(); // Consume the UPDATE keyword.
     1657        $has_where                 = false;
     1658        $needs_closing_parenthesis = false;
     1659        $params                    = array();
    15691660        while ( true ) {
    15701661            $token = $this->rewriter->peek();
    15711662            if ( ! $token ) {
     1663
     1664
     1665
     1666
     1667
     1668
     1669
     1670
     1671
     1672
     1673
     1674
     1675
     1676
     1677
     1678
     1679
     1680
     1681
     1682
     1683
     1684
     1685
     1686
     1687
     1688
     1689
     1690
     1691
     1692
     1693
    15721694                break;
    15731695            }
     
    15951717            $this->rewriter->consume();
    15961718        }
     1719
     1720
     1721
     1722
     1723
     1724
    15971725        $this->rewriter->consume_all();
    15981726
     
    16001728        $this->execute_sqlite_query( $updated_query, $params );
    16011729        $this->set_result_from_affected_rows();
     1730
     1731
     1732
     1733
     1734
     1735
     1736
     1737
     1738
     1739
     1740
     1741
     1742
     1743
     1744
     1745
     1746
     1747
     1748
     1749
     1750
     1751
     1752
     1753
     1754
     1755
     1756
     1757
     1758
     1759
     1760
     1761
     1762
    16021763    }
    16031764
     
    31003261            case 'COLUMNS FROM':
    31013262                $table_name = $this->rewriter->consume()->token;
    3102                 $stmt       = $this->execute_sqlite_query(
    3103                     "PRAGMA table_info(\"$table_name\");"
    3104                 );
    3105                 /* @todo we may need to add the Extra column if anybdy needs it. 'auto_increment' is the value */
    3106                 $name_map = array(
    3107                     'name'       => 'Field',
    3108                     'type'       => 'Type',
    3109                     'dflt_value' => 'Default',
    3110                     'cid'        => null,
    3111                     'notnull'    => null,
    3112                     'pk'         => null,
    3113                 );
    3114                 $columns  = $stmt->fetchAll( $this->pdo_fetch_mode );
    3115                 $columns  = array_map(
    3116                     function ( $row ) use ( $name_map ) {
    3117                         $new       = array();
    3118                         $is_object = is_object( $row );
    3119                         $row       = $is_object ? (array) $row : $row;
    3120                         foreach ( $row as $k => $v ) {
    3121                             $k = array_key_exists( $k, $name_map ) ? $name_map [ $k ] : $k;
    3122                             if ( $k ) {
    3123                                 $new[ $k ] = $v;
    3124                             }
    3125                         }
    3126                         if ( array_key_exists( 'notnull', $row ) ) {
    3127                             $new['Null'] = ( '1' === $row ['notnull'] ) ? 'NO' : 'YES';
    3128                         }
    3129                         if ( array_key_exists( 'pk', $row ) ) {
    3130                             $new['Key'] = ( '1' === $row ['pk'] ) ? 'PRI' : '';
    3131                         }
    3132                         return $is_object ? (object) $new : $new;
    3133                     },
    3134                     $columns
    3135                 );
    3136                 $this->set_results_from_fetched_data( $columns );
     3263
     3264                $this->set_results_from_fetched_data( $this->get_columns_from( $table_name ) );
    31373265                return;
    31383266
     
    32093337                return;
    32103338
     3339
     3340
     3341
     3342
     3343
     3344
     3345
     3346
     3347
     3348
     3349
     3350
     3351
     3352
     3353
     3354
     3355
     3356
     3357
     3358
     3359
     3360
     3361
     3362
     3363
     3364
     3365
     3366
     3367
     3368
     3369
     3370
     3371
     3372
     3373
     3374
     3375
     3376
     3377
     3378
     3379
     3380
     3381
     3382
     3383
    32113384            case 'TABLE STATUS':  // FROM `database`.
    3212                 // Match the optional [{FROM | IN} db_name]
     3385                // Match the optional [{FROM | IN} db_name]
    32133386                $database_expression = $this->rewriter->consume();
    3214                 if ( $database_expression->token === 'FROM' || $database_expression->token === 'IN' ) {
     3387                if ( ) {
    32153388                    $this->rewriter->consume();
    32163389                    $database_expression = $this->rewriter->consume();
     
    32193392                $pattern = '%';
    32203393                // [LIKE 'pattern' | WHERE expr]
    3221                 if($database_expression->token === 'LIKE') {
     3394                if) {
    32223395                    $pattern = $this->rewriter->consume()->value;
    3223                 } else if($database_expression->token === 'WHERE') {
     3396                } else) {
    32243397                    // @TODO Support me please.
    3225                 } else if($database_expression->token !== ';') {
    3226                     throw new Exception( 'Syntax error: Unexpected token ' . $database_expression->token .' in query '. $this->mysql_query );
     3398                } else) {
     3399                    throw new Exception( 'Syntax error: Unexpected token ' . $database_expression->token .. $this->mysql_query );
    32273400                }
    32283401
     
    32533426                        AND name LIKE :pattern
    32543427                    ORDER BY name",
    3255 
    32563428                    array(
    32573429                        ':pattern' => $pattern,
    32583430                    )
    32593431                );
    3260                 $tables = $this->strip_sqlite_system_tables( $stmt->fetchAll( $this->pdo_fetch_mode ) );
     3432                $tables = $this->strip_sqlite_system_tables( $stmt->fetchAll( $this->pdo_fetch_mode ) );
    32613433                foreach ( $tables as $table ) {
    32623434                    $table_name  = $table->Name; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
     
    33053477                }
    33063478        }
     3479
     3480
     3481
     3482
     3483
     3484
     3485
     3486
     3487
     3488
     3489
     3490
     3491
     3492
     3493
     3494
     3495
     3496
     3497
     3498
     3499
     3500
     3501
     3502
     3503
     3504
     3505
     3506
     3507
     3508
     3509
     3510
     3511
     3512
     3513
     3514
     3515
     3516
     3517
     3518
     3519
     3520
     3521
     3522
     3523
    33073524    }
    33083525
  • sqlite-database-integration/trunk/wp-includes/sqlite/install-functions.php

    r3015055 r3084383  
    3232    }
    3333
    34     $translator = new WP_SQLite_Translator( $pdo, $GLOBALS['table_prefix'] );
     34    $translator = new WP_SQLite_Translator( $pdo );
    3535    $query      = null;
    3636
Note: See TracChangeset for help on using the changeset viewer.