Coder Social home page Coder Social logo

wp-sqlite-db's Introduction

wp-sqlite-db

Test Packagist Packagist

A single file drop-in for using a SQLite database with WordPress. Based on the original SQLite Integration plugin.

Installation

Quick Start

  • Clone or download this repository
  • Copy src/db.php into the root of your site's wp-content directory

Via Composer

  • composer require koodimonni/composer-dropin-installer
  • Add the configuration to your project's composer.json under the extra key
"extra": {
    "dropin-paths": {
        "wp-content/": ["package:aaemnnosttv/wp-sqlite-db:src/db.php"]
    }
}
  • composer require aaemnnosttv/wp-sqlite-db

Overview

Once the drop-in is installed, no other configuration is necessary, but some things are configurable.

By default, the SQLite database is located in wp-content/database/.ht.sqlite, but you can change this using a few constants.

define('DB_DIR', '/absolute/custom/path/to/directory/for/sqlite/database/file/');
define('DB_FILE', 'custom_filename_for_sqlite_database');

Credit

This project is based on the SQLite Integration plugin by Kojima Toshiyasu.

wp-sqlite-db's People

Contributors

aaemnnosttv avatar benharri avatar dingo-d avatar ironprogrammer avatar mati75 avatar mcaskill avatar mwguerra avatar stefanos82 avatar tlaverdure avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wp-sqlite-db's Issues

PHP 8.1 support

Just opening the issue to be aware of the potential issues with dynamic properties in the package. I got the report in my package which describes the issue and a solution:

dingo-d/wp-pest#2 (comment)

Adding annotation is the simple solution, the better solution would be to fix all the dynamically created properties ofc.

Is it necessary for this package to be a dropin and use installers?

The composer installers is great for bedrock type development, but other than that it's kinda problematic to use as a direct dependency.

My use case is that I need to set up an in-memory DB for testing purposes only, and I'd like to use this package, but whenever my package gets pulled in the project repo, the composer installers will automatically create a wp-content folder with this package in it.

Adding

"extra": {
    "installer-disable": [
      "wordpress"
    ]
  }

only works when I run composer install in my package, not when somebody installs my package (they'd need to disable the installer in their project manually for that to work I guess).

Is there any way this can be circumvented?

don't work on Mac OS Mojave.

OS: macOS Mojave comes with Apache,php,sqlite pre-installed.
Apache/2.4.41 (Unix) Nov 9 2019 07:53:54
PHP 7.3.9 (cli) (built: Nov 9 2019 08:08:13) ( NTS )
SQLite version 3.28.0 2019-04-15

Error: WordPress 6.5 requires MySQL 5.5.5 or higher

I've been using this plugin for many years now at my website. But Wordpress 6.5 came out a few days ago and started giving me this new error which I've never seen before.

I decided to set up a separate instance locally with a blank Wordpress site after adding the db.php file. The initial questions go through, but after asking all the questions when I click on 'Install Wordpress' I get this error -

Error: WordPress 6.5 requires MySQL 5.5.5 or higher

Any suggestions would help

PHP 8.1(.3) support

I am getting this:

Deprecated: Return type of WP_SQLite_DB\PDOEngine::beginTransaction() should either be compatible with PDO::beginTransaction(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/danielruf/projects/run-local-wordpress/wp-content/db.php on line 2429

Suggestion: Remove unnecessary PHP 5.3.2 support from datediff implementation

Since WordPress supports the minimum PHP 5.6 and that will change quite soon, why not improve code from

public function datediff($start, $end)
{
    if (version_compare(PHP_VERSION, '5.3.2', '==')) {
        $start_date = strtotime($start);
        $end_date = strtotime($end);
        $interval = floor(($start_date - $end_date) / (3600 * 24));

        return $interval;
    } else {
        $start_date = new DateTime($start);
        $end_date = new DateTime($end);
        $interval = $end_date->diff($start_date, false);

        return $interval->format('%r%a');
    }
}

to

public function datediff($start, $end)
{
    $start_date = new DateTime($start);
    $end_date = new DateTime($end);
    $interval = $end_date->diff($start_date, false);

    return $interval->format('%r%a');
}

Shorter and cleaner.

Implement WAL support in v2

Hey @aaemnnosttv, I can see you work on v2.

Is it possible to add WAL support in it?

Based on your feedback in #3 I have added it myself and works as expected, at least on standard websites.

I have implemented a simple logic that goes like this:

define('DISALLOW_FILE_EDIT', true);

Should be added in wp-config.php; its implementation in db.php goes as follows:

$GLOBALS['wpdb'] = new WP_SQLite_DB\wpsqlitedb();

    if ( defined( 'ENABLE_SQLITE_WAL' ) && ENABLE_SQLITE_WAL === true ) {
        $GLOBALS['wpdb']->query('PRAGMA journal_mode = WAL');
    } else {
        $GLOBALS['wpdb']->query('PRAGMA journal_mode = DELETE');
    }

I have placed it at the very end right before the last closing curly bracket.

I would like to use a better way though than using the $GLOBAL.

Any suggestion?

Documentation / Examples for Docker

Would you be open to a PR providing documentation / examples of how to set up a wordpress instance in a docker container using wp-sqlite-db?

site-health error

Hi,
Accessing the page /wp-admin/site-health.php I got this error:

Screen Shot 2022-09-10 at 10 54 49

Changing database location

Please forgive me for such a rookie issue. Not a fan of asking questions here, but I am stuck.

"By default, the SQLite database is located in wp-content/database/.ht.sqlite, but you can change this using a few constants."

define('DB_DIR', '/absolute/custom/path/to/directory/for/sqlite/database/file/');
define('DB_FILE', 'custom_filename_for_sqlite_database');

I assume this goes into wp-config.php and not db.php ?

wp-sqlite-db is a game changer for using WP in classroom environment since we cannot run mySQL.

Thank you!

Notices when activating WooCommerce

Notice: Undefined property: ObjectArray::$column_name in .../wp-content/db.php on line 2389
Notice: Undefined property: ObjectArray::$column_name in .../wp-content/db.php on line 2389
Notice: Undefined property: ObjectArray::$column_name in .../wp-content/db.php on line 2389
Notice: Undefined property: ObjectArray::$column_name in .../wp-content/db.php on line 2389
Notice: Undefined property: ObjectArray::$column_name in .../wp-content/db.php on line 2389
Notice: Undefined property: ObjectArray::$column_name in .../wp-content/db.php on line 2389
Warning: count(): Parameter must be an array or an object that implements Countable in .../wp-content/db.php on line 2291
Warning: count(): Parameter must be an array or an object that implements Countable in .../wp-content/db.php on line 2291

Errors when updating options (SQLSTATE[23000]: Integrity constraint violation)

It looks like there are errors when you try to save some options on the backend.

From what I can see, schema for option_value is TEXT NOT NULL but the query executed try to set value to NULL.

Steps to reproduce: In the backend, go to Settings -> Discussion, deselect any option and try to save.

Wordpress Debug Output:

WordPress database error: [
 
Queries made or created this session were

    Raw query: UPDATE `wp_options` SET `option_value` = NULL WHERE `option_name` = 'default_pingback_flag'
    Rewritten: UPDATE wp_options SET option_value = NULL WHERE option_name = 'default_pingback_flag'
    With Placeholders: UPDATE wp_options SET option_value = NULL WHERE option_name = :param_0
    Prepare: UPDATE wp_options SET option_value = NULL WHERE option_name = :param_0
    Executing: array ( 0 => 'default_pingback_flag', )

Error occurred at line 1723 in Function execute_query.
Error message was: Error while executing query! Error message was: SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: wp_options.option_value

] 
UPDATE `wp_options` SET `option_value` = NULL WHERE `option_name` = 'default_pingback_flag' 

debug.txt:

Line 1723, Function: execute_query, Message: Error while executing query! Error message was: SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: wp_posts.comment_status 
Line 1723, Function: execute_query, Message: Error while executing query! Error message was: SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: wp_options.option_value 

WordPress version: 5.6.2
PHP version: 7.4

Note: When WP_DEBUG is set to false it just fails to update the options silently.

Drop in db.php to fresh installation?

I'm trying to start a new wordpress 6.1.1 site today, using sqlite instead of mysql.

Steps to recreate:
Downloaded https://wordpress.org/latest.zip
Extracted to root web directory
Downloaded db.php file
Copied db.php file to wp-content directory
Started Wordpress installation by surfing to the site.
Selected language, clicked continue
Prompt about database info appears, click Let's Go!
Database connection form appears, as if a mysql database is expected. Since there is no mysql database, anything I enter into the form results in 'Error establishing database connection'

Checking the directory, there was no wp-content/database directory created. I created it, but this had the same result.

If it matters, I am using nginx and php 8.1 on ubuntu 20.04. Sqlite and sqlite3 are both already installed. I have used the deprecated Sqlite Integration plugin on this same server before, and I remember the installation skipped over the database section.

Did I miss something? What should I have done differently?

Thank you for any help you can provide! :)

DESC alias for DESCRIBE?

@aaemnnosttv Lines 3183 to 3186 say DESC is an alias for DESCRIBE.

Does not this conflict with DESC for sorting?

As far as I know, both SQLite and MySQL / MariaDB support EXPLAIN which for MySQL / MariaDB is a synonym for DESCRIBE.

Is there a particular reason we use this alias?

Fatal error: Uncaught Error: Call to a member function prepare() on null

after stetting the plugin I got theses error messages

Fatal error: Uncaught Error: Call to a member function prepare() on null in /var/www/vide2/wp-content/db.php:1645 Stack trace: #0 /var/www/vide2/wp-content/db.php(1408): WP_SQLite_DB\PDOEngine->prepare_query() #1 /var/www/vide2/wp-content/db.php(2741): WP_SQLite_DB\PDOEngine->query() #2 /var/www/vide2/wp-includes/wp-db.php(2696): WP_SQLite_DB\wpsqlitedb->query() #3 /var/www/vide2/wp-includes/option.php(238): wpdb->get_results() #4 /var/www/vide2/wp-includes/functions.php(1723): wp_load_alloptions() #5 /var/www/vide2/wp-includes/load.php(709): is_blog_installed() #6 /var/www/vide2/wp-settings.php(159): wp_not_installed() #7 /var/www/vide2/wp-config.php(100): require_once('/var/www/vide2/...') #8 /var/www/vide2/wp-load.php(37): require_once('/var/www/vide2/...') #9 /var/www/vide2/wp-blog-header.php(13): require_once('/var/www/vide2/...') #10 /var/www/vide2/index.php(17): require('/var/www/vide2/...') #11 {main} thrown in /var/www/vide2/wp-content/db.php on line 1645

Fatal error: Uncaught Error: Call to a member function prepare() on null in /var/www/vide2/wp-content/db.php:1645 Stack trace: #0 /var/www/vide2/wp-content/db.php(1408): WP_SQLite_DB\PDOEngine->prepare_query() #1 /var/www/vide2/wp-content/db.php(2741): WP_SQLite_DB\PDOEngine->query() #2 /var/www/vide2/wp-includes/wp-db.php(2696): WP_SQLite_DB\wpsqlitedb->query() #3 /var/www/vide2/wp-includes/option.php(238): wpdb->get_results() #4 /var/www/vide2/wp-includes/option.php(117): wp_load_alloptions() #5 /var/www/vide2/wp-includes/l10n.php(69): get_option() #6 /var/www/vide2/wp-includes/l10n.php(137): get_locale() #7 /var/www/vide2/wp-includes/l10n.php(828): determine_locale() #8 /var/www/vide2/wp-includes/class-wp-fatal-error-handler.php(46): load_default_textdomain() #9 [internal function]: WP_Fatal_Error_Handler->handle() #10 {main} thrown in /var/www/vide2/wp-content/db.php on line 1645

php v8 (via docker `php:fpm-alpine`) failing

any chance of a fix?

eg:

2021/02/28 21:37:52 [error] 13#13: *3 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Declaration of WP_SQLite_DB\PDOEngine::query($statement, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) must be compatible with PDO::query(string $query, ?int $fetchMode = null, mixed ...$fetchModeArgs) in /usr/share/nginx/html/wp-content/db.php on line 1336" while reading response header from upstream, client: 127.0.0.1, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:5000"

db_connect method not being overridden

I'm new to wordpress. I'm getting the following error when initializing the database over the wordpress web setup tool:

Wed Sep 14 15:51:38 2022] [::1]:45770 [500]: POST /wp-admin/setup-config.php?step=2 - Uncaught Error: Call to undefined function mysql_connect() in /home/mio/code/wordpress/wp-includes/wp-db.php:1788
Stack trace:
#0 /home/mio/code/wordpress/wp-admin/setup-config.php(308): wpdb->db_connect()
#1 {main}
  thrown in /home/mio/code/wordpress/wp-includes/wp-db.php on line 1788

it seems as though wp-db.php isn't being overridden by db.php (line 1788 is within the db_connect method of wp-db.php and not of db.php) I used composer to install the plugin, which copied db.php to ./wp-content/db.php.

Plugin Table Creation Error

I've been using this project with the WP2Static static site generator plugin. It mostly works but one table isn't created when the plugin is activated. I thought it was an issue with the plugin itself using ANSI-SQL incompatible with SQLite but the other tables also use incompatible SQL successfully.

Unless I've misunderstood I assume wp-sqlite-db converts the MySQL dialect into SQLite compatible SQL. The following doesn't work for whatever reason:

CREATE TABLE wp_wp2static_log (
  id mediumint(9) NOT NULL AUTO_INCREMENT,
  time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  log TEXT NOT NULL,
  PRIMARY KEY  (id)
)

This only affects the log table so the plugin works. Obviously this is easy to change in the plugin itself but I'd prefer to get wp-sqlite-db's conversion process working correctly.

There is also a second issue with one of the log queries not running correctly (after I've manually created the table):

SELECT CONCAT_WS(': ', time, log) FROM wp_wp2static_log

Again, the above SQL is easily fixed but I'd prefer to make the alteration in wp-sqlite-db and convert the CONCAT_WS function correctly into something SQLite understands.

Any help appreciated :-)

query error when deleting all transients

[Sun Feb 27 14:02:33 2022] WordPress-Datenbank-Fehler <div style="clear:both">&nbsp;</div><div class="queries" style="clear:both; margin_bottom:2px; border: red dotted thin;">Queries made or created this session were<br/>
	<ol>
		<li>Raw query:
DELETE a, b FROM wp_options a, wp_options b
			WHERE a.option_name LIKE '_transient_%'
			AND a.option_name NOT LIKE '_transient_timeout_%'
			AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )
			AND b.option_value < 1645966953</li>
		<li>Rewritten:
DELETE a, b FROM wp_options a, wp_options b
			WHERE a.option_name LIKE '_transient_%'
			AND a.option_name NOT LIKE '_transient_timeout_%'
			AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )
			AND b.option_value < 1645966953</li>
		<li>With Placeholders:
DELETE a, b FROM wp_options a, wp_options b
			WHERE a.option_name LIKE  :param_0 
			AND a.option_name NOT LIKE  :param_1 
			AND b.option_name = CONCAT(  :param_2 , SUBSTRING( a.option_name, 12 ) )
			AND b.option_value < 1645966953</li>
		<li>Prepare:
DELETE a, b FROM wp_options a, wp_options b
			WHERE a.option_name LIKE  :param_0 
			AND a.option_name NOT LIKE  :param_1 
			AND b.option_name = CONCAT(  :param_2 , SUBSTRING( a.option_name, 12 ) )
			AND b.option_value < 1645966953</li>
	</ol>
Error message was: Problem preparing the PDO SQL Statement.  Error was: SQLSTATE[HY000]: General error: 1 near "a": syntax error

SQL Error on WordPress Site Health Page with Custom Table Prefix

When using a custom table prefix, a SQL error occurs while accessing the Site Health page in the WordPress admin area. The error appears to be related to querying table information.

Steps to Reproduce

  1. Set up WordPress with a custom table prefix
  2. Activate the WP SQLite DB plugin
  3. Navigate to Tools > Site Health in the WordPress admin
  4. Observe the SQL error

Error Message

WordPress database error:

Queries made or created this session were

- Raw query: SELECT TABLE_NAME AS 'table', TABLE_ROWS AS 'rows', SUM(data_length + index_length) as 'bytes' FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'null-db-name' AND TABLE_NAME IN ('custom_comments','custom_options','custom_posts','custom_terms','custom_users') GROUP BY TABLE_NAME;
- Rewritten: SELECT TABLE_NAME AS 'table', TABLE_ROWS AS 'rows', SUM(data_length + index_length) as 'bytes' FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'null-db-name' AND TABLE_NAME IN ('custom_comments','custom_options','custom_posts','custom_terms','custom_users') GROUP BY TABLE_NAME;
- With Placeholders: SELECT TABLE_NAME AS :param_0 , TABLE_ROWS AS :param_1 , SUM(data_length + index_length) as :param_2 FROM information_schema.TABLES WHERE TABLE_SCHEMA = :param_3 AND TABLE_NAME IN ( :param_4 , :param_5 , :param_6 , :param_7 , :param_8 ) GROUP BY TABLE_NAME;
- Prepare: SELECT TABLE_NAME AS :param_0 , TABLE_ROWS AS :param_1 , SUM(data_length + index_length) as :param_2 FROM information_schema.TABLES WHERE TABLE_SCHEMA = :param_3 AND TABLE_NAME IN ( :param_4 , :param_5 , :param_6 , :param_7 , :param_8 ) GROUP BY TABLE_NAME;

Error occurred at line 1644 in Function prepare_query.
Error message was: Problem preparing the PDO SQL Statement. Error was: SQLSTATE[HY000]: General error: 1 near ":param_0": syntax error 

#0 /home/username/public_html/wp-content/db.php(2746): WP_SQLite_DB\PDOEngine->get_error_message() 
#1 /home/username/public_html/wp-includes/class-wpdb.php(3141): WP_SQLite_DB\wpsqlitedb->query('SELECT TABLE_NA...') 
#2 /home/username/public_html/wp-admin/includes/class-wp-site-health.php(3568): wpdb->get_results('SELECT TABLE_NA...', 'OBJECT_K') 
#3 /home/username/public_html/wp-admin/includes/class-wp-site-health.php(2538): WP_Site_Health->should_suggest_persistent_object_cache() 
#4 /home/username/public_html/wp-admin/includes/class-wp-site-health.php(194): WP_Site_Health->get_test_persistent_object_cache() 
#5 /home/username/public_html/wp-admin/includes/class-wp-site-health.php(139): WP_Site_Health->perform_test(Array) 
#6 /home/username/public_html/wp-includes/class-wp-hook.php(324): WP_Site_Health->enqueue_scripts('site-health.php') 
#7 /home/username/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) 
#8 /home/username/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) 
#9 /home/username/public_html/wp-admin/admin-header.php(118): do_action('admin_enqueue_s...', 'site-health.php') 
#10 /home/username/public_html/wp-admin/site-health.php(96): require_once('/home/username/p...') 

SELECT TABLE_NAME AS 'table', TABLE_ROWS AS 'rows', SUM(data_length + index_length) as 'bytes' FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'null-db-name' AND TABLE_NAME IN ('custom_comments','custom_options','custom_posts','custom_terms','custom_users') GROUP BY TABLE_NAME;

Additional Information

  • WordPress Version: 6.6.2
  • Plugin Version: 1.3.2
  • PHP Version: 8.3.10

Support the full WordPress PHPUnit test suite

This issue has been solved in the WordPress/sqlite-database-integration plugin, which is available in WordPress Plugin Directory. I'll leave it open here for posterity.


The problem

A lot of WordPress unit tests fail with the SQLite plugin is installed.

The root cause is the method of rewriting MySQL queries to SQLite queries: regular expressions and string lookups. It's hard to support the variety of SQL queries used in WordPress using these tools. I explored patching this plugin in WordPress Playground, but there's too many cases to cover โ€“ I included a few examples of failing queries at the bottom of this description.

Proposed solution

Parsing MySQL queries and using contextual information would make this plugin much more bulletproof.

Some queries are hard to reason about with tools like preg_replace or strpos:

-- Valid SQL inside quotes
INSERT INTO wp_options VALUES ('ON DUPLICATE KEY UPDATE') 

-- Four "datetime" occurrences, each with a different meaning:
CREATE TABLE test ( `datetime` datetime NOT NULL, KEY datetime ( datetime ) )

-- Comma inside a string value derails one of the explode(",") calls
UPDATE wp_options SET option_value=','

In contrast, applying the SQL grammar would make rewriting these queries much easier:

// 'ON DUPLICATE KEY' can't be mistaken for SQL keyword:
[
    'INSERT INTO' => [
        'table' => 'wp_options',
        'values' => ['ON DUPLICATE KEY UPDATE']
    ]
]

// It's clear how to treat each part of the query:
[
    'CREATE TABLE' => [
        'name' => 'test',
        'fields' => [
            'datetime' => [
                'type' => 'datetime',
                'notnull' => true
            ]
        ],
        'keys' => [
            'datetime' => ['datetime']
        ]
    ]
]

// There's no risk of mistaking the inserted "," for a field separator:
[
    'UPDATE' => [
        'table' => 'wp_options',
        'set' => [
            'option_value' => ','
        ]
    ]
]

How to parse SQL queries?

Full parsing may not be needed. Even the array representation from the examples above may be too much. Creating many objects, arrays, and function calls for each SQL query would make WordPress extremely slow. There's a faster alternative.

Consider WP_HTML_Tag_Processor, a new WordPress API that enables adding, removing, and updating HTML attributes. It never turns the input HTML into a tree. Instead, it consumes the input HTML string one tag and one attribute at a time, and uses the contextual information to build the output HTML:

$w = new WP_HTML_Tag_Processor( '<a href="#" class="button"></a>' );
$w->next_tag( 'a' );
$w->remove_attribute( 'href' );
echo $w->get_updated_html();
// Outputs: <a class="button"></a>
// No tree was constructed. Instead, the processor used the HTML parsing rules
// to find the start and end of href="#", and then excluded that attribute from
// the output HTML

Perhaps the same technique could be used to rewrite MySQL queries?

For example:

$mysql = "CREATE TABLE test ( `datetime` datetime NOT NULL, KEY datetime ( datetime ) )";
$sqlite = '';

$at = 0;
$max = strlen($sql);
while($at < $max) {
    $last_at = $at;

    // Find the first character that's not " ", "\t", or "("
    $at += strcspn($mysql, "\t (", $at);

    // Find out what token we're looking at now:
    $token = consume_token($mysql, $at);
    if ( $token === 'CREATE TABLE' ) {
        // If it's a CREATE TABLE query, append the correct SQLite
        // command to the output string:
        $sqlite .= 'CREATE TABLE ';

        // Expect the table name to at the first non-whitespace character
        $at += strcspn($mysql, " \t", $at);
        $table_name_starts = $at;

        // Skip backticks
        if($query[$at] === "`") {
            ++$at;
        }

        // Expect the table name to consist of alnum
        $at += strspn($mysql, "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789", $at);

        // Skip backticks
        if($query[$at] === "`") {
            ++$at;
        }

        $table_name_ends = $at;
        $table_name = substr($mysql, $table_name_starts, $table_name_ends - $table_name_starts );
        if ( !$table_name ) {
          return false; // Syntax error
        }

        // Append a quoted table name to the output query
        $sqlite .= '"' . $table_name . '"';

        // Find and skip the '('
        $at += strcspn($mysql, '(', $at) + 1;

        // Consume the field name and definition
        // ...        
    } else if($token === 'SELECT' ) {
        // Consume a SELECT query
    } else if // ...
}

// Consume CREATE

Too low-level? Here's a higher-level idea:

preg_match(
    '^(INSERT|CREATE|UPDATE|SELECT)\s+',
    $query,
    &$matches,
    PREG_OFFSET_CAPTURE,
    $at
);

Use preg_match to capture the next token, but nothing else. The parser would still move forward a single token at a time and make decisions based on what it just captured. The idea is to never write a regexp for the entire query. It's more readable than the lower-level counterparts, still reasonably fast, and only treats one token at a time. Also โ€“ if it works, it could be replaced by a lower-level implementation relatively easily.

While I am proposing a major change, I specifically don't mean a full rewrite. This plugin got a lot of things right:

  • Data types are mapped
  • Different types of queries are recognized and treated separately
  • When 1<=>1 translation isn't possible, this plugin translates a MySQL query to a series of SQLite queries

The existing work is an excellent foundation and I only propose to take it to the next level.

Finally, thank you for maintaining this plugin @aaemnnosttv! It made WordPress Playground possible.

Failing queries

Here's a few examples of queries that didn't work for me at one point or another:

DELETE a, b FROM wp_options a, wp_options b
	WHERE a.option_name LIKE '_transient_%'
	AND a.option_name NOT LIKE '_transient_timeout_%'
	AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )
	AND b.option_value < 1675613957

CREATE TABLE wp_wc_download_log (
		download_log_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
		timestamp datetime NOT NULL,
		permission_id BIGINT UNSIGNED NOT NULL,
		user_id BIGINT UNSIGNED NULL,
		user_ip_address VARCHAR(100) NULL DEFAULT '',
		PRIMARY KEY  (download_log_id),
		KEY permission_id (permission_id),
		KEY timestamp (timestamp)

CREATE TABLE test ( timestamp datetime NOT NULL, KEY timestamp ( timestamp ) )

ALTER TABLE wp_wc_product_download_directories CHANGE COLUMN `url` url varchar(256) NOT NULL

ALTER TABLE wp_woocommerce_downloadable_product_permissions ADD PRIMARY KEY  (`permission_id`)

cc @aristath @felixarntz @dmsnell @gziolo

Undefined array key ... on line 3493

I get these errors with a fresh installation of WordPress, default theme, no plugins.
Hiawatha 11.1, PHP 8.1.4, SQLite 3.37.0, WordPress 5.9.3

[24-Apr-2022 20:32:01 Europe/Bucharest] PHP Warning:  Undefined array key "option_name" in /var/www/2-5/wp-content/db.php on line 3493
[24-Apr-2022 20:32:01 Europe/Bucharest] PHP Warning:  Undefined array key "option_value" in /var/www/2-5/wp-content/db.php on line 3493
[24-Apr-2022 20:32:01 Europe/Bucharest] PHP Warning:  Undefined array key "autoload" in /var/www/2-5/wp-content/db.php on line 3493

Thanks.

Problem with woocommerce creating wp_wc_download_log

In my WooCommerce status, I get the following message:

Missing base tables: peiramasqlitewp_wc_download_log. Some WooCommerce functionality may not work as expected.

As you can see I see a custom prefix and I don't know whether it plays role or not.

Here's the actual schema for the missing table:

CREATE TABLE `wp_wc_download_log` (
  `download_log_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `timestamp` datetime NOT NULL,
  `permission_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned DEFAULT NULL,
  `user_ip_address` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT '',
  PRIMARY KEY (`download_log_id`),
  KEY `permission_id` (`permission_id`),
  KEY `timestamp` (`timestamp`),
  CONSTRAINT `fk_wp_wc_download_log_permission_id` FOREIGN KEY (`permission_id`) REFERENCES `wp_woocommerce_downloadable_product_permissions` (`permission_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

What could possibly causing the problem from creating the table?

Install fails: "Your PHP installation appears to be missing the MySQL extension which is required by WordPress."

Hi,

thank you very much for the update on the Wordpress SQLite integration plugin! Just tried to setup a new site with the latest Wordpress and your db.php and when running the Wordpress install.php I just get the error "Your PHP installation appears to be missing the MySQL extension which is required by WordPress." Obviously I'd like to run the Wordpress site with SQLite, not with MySQL. Do I really have to install MySQL first or can I bypass the requirements check somehow?

Compatibility Issues with Serverless

I'm trying to replace MySQL with SQLite, but I've encountered a troublesome issue and I hope to get your help.

My environment is Tencent Cloud's Serverless, which generates a temporary workspace when it runs. The absolute path for WordPress is /var/user/.

However, files and directories under this temporary workspace don't have write permissions, so mounting an additional file storage system (CFS) is required. The local path /var/user/wp-content corresponds to the remote path /mnt/wp-content.

Besides, I need to add define('WP_CONTENT_DIR', '/mnt/wp-content'); and define('DB_DIR', '/mnt/wp-content/database');. to the wp-config.php file.

My current problem is that if I want to use SQLite, I need to remove define('WP_CONTENT_DIR', '/mnt/wp-content');, otherwise, WordPress will only use MySQL. But if I remove define('WP_CONTENT_DIR', '/mnt/wp-content');, the /wp-content directory doesn't have write permissions, causing issues with uploading images, downloading plugins, and so on.

Tagging version with PHP 8.2 support?

Is there anything we can help to speed up the version that will support 8.2? I had to use master branch because of failures on the CI regarding composer installers (v1 is the default in the last tagged version).

I keep getting deprecation notices on 8.2

Creation of dynamic property WP_SQLite_DB\ObjectArray::$Table is deprecated

And other properties. I know #50 was merged, but no version was tagged.

Is there a to do list of tasks that should be fixed before new version is released?

WooCommerce Fatal Errors

I don't know whether it relates to #3 or not, but now I get these fatal errors in WooCommerce > Status > Logs:

2020-05-28T15:39:58+00:00 CRITICAL Uncaught Error: Call to a member function format() on null in /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php:79
Stack trace:
#0 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php(52): ActionScheduler_wcSystemStatus->get_action_status_date()
#1 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php(27): ActionScheduler_wcSystemStatus->get_oldest_and_newest()
#2 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_AdminView.php(50): ActionScheduler_wcSystemStatus->render()
#3 /var/www/html/peiramaSQLite/app/wp-includes/class-wp-hook.php(287): ActionScheduler_AdminView->system_status_report()
#4 /var/www/html/peiramaSQLite/app/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters()
#5 /var/www/html/peiramaSQLi in /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php on line 79

2020-05-28T15:42:11+00:00 CRITICAL Uncaught Error: Call to a member function format() on null in /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php:79
Stack trace:
#0 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php(52): ActionScheduler_wcSystemStatus->get_action_status_date()
#1 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php(27): ActionScheduler_wcSystemStatus->get_oldest_and_newest()
#2 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_AdminView.php(50): ActionScheduler_wcSystemStatus->render()
#3 /var/www/html/peiramaSQLite/app/wp-includes/class-wp-hook.php(287): ActionScheduler_AdminView->system_status_report()
#4 /var/www/html/peiramaSQLite/app/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters()
#5 /var/www/html/peiramaSQLi in /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php on line 79

2020-05-28T16:52:50+00:00 CRITICAL Uncaught Error: Call to a member function format() on null in /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php:79
Stack trace:
#0 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php(52): ActionScheduler_wcSystemStatus->get_action_status_date()
#1 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php(27): ActionScheduler_wcSystemStatus->get_oldest_and_newest()
#2 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_AdminView.php(50): ActionScheduler_wcSystemStatus->render()
#3 /var/www/html/peiramaSQLite/app/wp-includes/class-wp-hook.php(287): ActionScheduler_AdminView->system_status_report()
#4 /var/www/html/peiramaSQLite/app/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters()
#5 /var/www/html/peiramaSQLi in /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php on line 79

DB maintenance fail

When things in WP (posts, pages, etc) are trashed, then deleted permanently they stil continue to exist in database with a different status, and they are not appearing anymore in WP as garbage. I don't know if this is the normal behaviour for this drop in, but I think this is a problem since database will continue to grow. The original Sqlite Integration had an internal tool working just fine and maintaining the database clean.

Site Health Page Fatal Error

I'm getting this error when I try to open the Site Health menu under Tools. Is it possible to add a filter for this?

2021-12-10 10:03:10: (mod_fastcgi.c.451) FastCGI-stderr:Stack trace:
2021-12-10 10:03:10: (mod_fastcgi.c.451) FastCGI-stderr:#0 /var/www/example.com/wp-admin/includes/class-wp-site-health.php(1163): WP_Site_Health->prepare_sql_data()
2021-12-10 10:03:10: (mod_fastcgi.c.451) FastCGI-stderr:#1 /var/www/example.com/wp-admin/includes/class-wp-site-health.php(192): WP_Site_Health->get_test_sql_server()
2021-12-10 10:03:10: (mod_fastcgi.c.451) FastCGI-stderr:#2 /var/www/example.com/wp-admin/includes/class-wp-site-health.php(137): WP_Site_Health->perform_test()
2021-12-10 10:03:10: (mod_fastcgi.c.451) FastCGI-stderr:#3 /var/www/example.com/wp-includes/class-wp-hook.php(303): WP_Site_Health->enqueue_scripts()
2021-12-10 10:03:10: (mod_fastcgi.c.451) FastCGI-stderr:#4 /var/www/example.com/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters()
2021-12-10 10:03:10: (mod_fastcgi.c.451) FastCGI-stderr:#5 /var/www/example.com/wp-includes/plugin.php(470): WP_Hook->do_action()
2021-12-10 10:03:10: (mod_fastcgi.c.451) FastCGI-stderr:#6 /var/www/example.com/wp-admin/admin-header.php(102): do_action()
2021-12-10 10:03:10: (mod_fastcgi.c.451) FastCGI-stderr:#7 /var/www/example.com/wp-admin...

WordPress 6.1 adds new method call wpdb->db_server_info() in dbDelta

The SQLite drop in is missing the implementation of function db_server_info() {}.

	    /**
	     * Retrieves full database server information.
	     *
	     * @since 5.5.0
	     *
	     * @return string|false Server info on success, false on failure.
	     */
	    public function db_server_info() {
		    return 'somestring';
	    }

Interesting suggestion by a WP Core member

Seems like @aristath had suggested the SQLite support for WordPress.

It would be nice if Ari came here to share some thoughts based on existing feedback we have thus far provided via tickets.

This particular ticket of mine #4 is what interests me the most; I have some customers that sell 15 to 20 items only and would be an overkill to depend on MySQL / MariaDB when I can easily use SQLite.

All in all, I'm very excited to see this suggestion and I would like to see it in WP core!

By the way @aristath,

image

I have solved this, at least when I tested it locally (see #20), with WAL enabled worked without a problem.

Posts in missed schedule state when host time is not UTC

Thank you for this sqlite port!

When the host time is not UTC (for instance Europe/Paris), new posts can't be published. Instead, they're instantly in a missed schedule state.

Changing the WP timezone from Settings > General > Timezone doesn't solve the issue.

WooCommerce fatal errror

Any idea how to fix this?

Fatal error: Uncaught RuntimeException: Fout bij opslaan actie: Fout bij opslaan actie:

ย 
Queries made or created this session were
  1. Raw query: INSERT INTO wp_actionscheduler_actions ( hook, status, scheduled_date_gmt, scheduled_date_local, schedule, group_id, args ) SELECT 'woocommerce_cleanup_draft_orders', 'pending', '2023-02-22 19:31:16', '2023-02-22 19:31:16', 'O:32:"ActionScheduler_IntervalSchedule":5:{s:22:"\0*\0scheduled_timestamp";i:1677094276;s:18:"\0*\0first_timestamp";i:1677094276;s:13:"\0*\0recurrence";i:86400;s:49:"\0ActionScheduler_IntervalSchedule\0start_timestamp";i:1677094276;s:53:"\0ActionScheduler_IntervalSchedule\0interval_in_seconds";i:86400;}', 0, '[]' FROM DUAL WHERE ( SELECT NULL FROM DUAL ) IS NULL
  2. Rewritten: INSERT INTO wp_actionscheduler_actions ( hook, status, scheduled_date_gmt, scheduled_date_local, schedule, group_id, args ) SELECT 'woocommerce_cleanup_draft_orders', 'pending', '2023-02-22 19:31:16', '2023-02-22 19:31:16', 'O:32:"ActionScheduler_IntervalSchedule":5:{s:22:"\0*\0scheduled_timestamp";i:1677094276;s:18:"\0*\0first_timestamp";i:1677094276;s:13:"\0*\0recurrence";i:86400;s:49:"\0ActionScheduler_IntervalSchedule\0start_timestamp";i:1677094276;s:53:"\0ActionScheduler_IntervalSchedule\0interval_in_seconds";i:86400;}', 0, '[]' FROM DUAL WHERE ( SELECT NULL FROM DUAL ) IS NULL
  3. With Placeholders: INSERT INTO wp_actionscheduler_actions ( hook, status, scheduled_date_gmt, scheduled_date_local, schedule, group_id, args ) SELECT :param_0 , :param_1 , :param_2 , :param_3 , :param_4 , 0, :param_5 FROM DUAL WHERE ( SELECT NULL FROM DUAL ) IS NULL
  4. Prepare: INSERT INTO wp_actionscheduler_actions ( hook, status, scheduled_date_gmt, scheduled_date_local, schedule, group_id, args ) SELECT :param_0 , :param_1 , :param_2 , :param_3 , :param_4 , 0, :param_5 FROM DUAL WHERE ( SELECT NULL FROM DUAL ) IS NULL
Error occurred at line 1644 in Function prepare_query.
Error message was: Problem preparing the PDO SQL Statement. Error was: SQLSTATE[HY000]: General error: 1 no such table: DUAL
#0 /www/wwwroot/website.com/wp-content/db.php(2746): WP_SQLite_DB\PDOEngine->get_error_message() #1 /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php(101): WP_SQLite_DB\wpsqlitedb->query('...') #2 /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php(62): ActionScheduler_DBStore->save_action_to_db(Object(ActionScheduler_Action), NULL, false) #3 /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/action-scheduler/classes/migration/ActionScheduler_DBStoreMigrator.php(31): ActionScheduler_DBStore->save_action(Object(ActionScheduler_Action), NULL) #4 /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/action-scheduler/classes/data-stores/ActionScheduler_HybridStore.php(242): ActionScheduler_DBStoreMigrator->save_action(Object(ActionScheduler_Action), NULL) #5 /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_ActionFactory.php(244): ActionScheduler_HybridStore->save_action(Object(ActionScheduler_Action)) #6 /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_ActionFactory.php(151): ActionScheduler_ActionFactory->store(Object(ActionScheduler_Action)) #7 /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/action-scheduler/functions.php(122): ActionScheduler_ActionFactory->recurring_unique('...', Array, false, 86400, '', false) #8 /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Domain/Services/DraftOrders.php(65): as_schedule_recurring_action(false, 86400, '...') #9 /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Domain/Services/DraftOrders.php(57): Automattic\WooCommerce\Blocks\Domain\Services\DraftOrders->maybe_create_cronjobs() #10 /www/wwwroot/website.com/wp-includes/class-wp-hook.php(308): Automattic\WooCommerce\Blocks\Domain\Services\DraftOrders->install('') #11 /www/wwwroot/website.com/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array) #12 /www/wwwroot/website.com/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #13 /www/wwwroot/website.com/wp-admin/admin.php(175): do_action('...') #14 /www/wwwroot/website.com/wp-admin/index.php(10): require_once('...') 
in /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/action-scheduler/classes/migration/ActionScheduler_DBStoreMigrator.php:44 Stack trace: #0 /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/action-scheduler/classes/data-stores/ActionScheduler_HybridStore.php(242): ActionScheduler_DBStoreMigrator->save_action() #1 /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_ActionFactory.php(244): ActionScheduler_HybridStore->save_action() #2 /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_ActionFactory.php(151): ActionScheduler_ActionFactory->store() #3 /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/action-scheduler/functions.php(122): ActionScheduler_ActionFactory->recurring_unique() #4 /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Domain/Services/DraftOrders.php(65): as_schedule_recurring_action() #5 /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Domain/Services/DraftOrders.php(57): Automattic\WooCommerce\Blocks\Domain\Services\DraftOrders->maybe_create_cronjobs() #6 /www/wwwroot/website.com/wp-includes/class-wp-hook.php(308): Automattic\WooCommerce\Blocks\Domain\Services\DraftOrders->install() #7 /www/wwwroot/website.com/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters() #8 /www/wwwroot/website.com/wp-includes/plugin.php(517): WP_Hook->do_action() #9 /www/wwwroot/website.com/wp-admin/admin.php(175): do_action() #10 /www/wwwroot/website.com/wp-admin/index.php(10): require_once('...') #11 {main} thrown in /www/wwwroot/website.com/wp-content/plugins/woocommerce/packages/action-scheduler/classes/migration/ActionScheduler_DBStoreMigrator.php on line 44

General error: 5 database is locked

Hi,
I have been testing the db.php on Azure Web Apps Free Plan for a few hours, but I can't get it to work. When making a fresh installation I got the below error. It happens exactly in make_db_sqlite() function. I even moved the $pdo->beginTransaction(); and $pdo->commit(); lines inside the foreach loops to have them executed more often, but it doesn't help. The database size is 0 byte after this error. Do you have any clue?

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 5 database is locked in /home/site/wwwroot/wp-content/db.php:4815
Stack trace:itle=Title --admin_user=hede --admin_password=test --admin_em--allow-root
#0 /home/site/wwwroot/wp-content/db.php(4815): PDO->commit()
#1 /home/site/wwwroot/wp-content/db.php(4862): WP_SQLite_DB\make_db_sqlite()
#2 phar:///home/site/bin/wp-cli.phar/vendor/wp-cli/core-command/src/Core_Command.php(631): wp_install('Title', 'hede', '[email protected]...', true, '', 'hedehot')
#3 phar:///home/site/bin/wp-cli.phar/vendor/wp-cli/core-command/src/Core_Command.php(414): Core_Command->do_install(Array)
#4 [internal function]: Core_Command->install(Array, Array)
#5 phar:///home/site/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(98): call_user_func(Array, Array, Array)
#6 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
#7 phar:///home/site/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(451): call_user_func(Object(Closure), Array, Array)
#8 phar:///home/s in /home/site/wwwroot/wp-content/db.php on line 4815
Error: There has been a critical error on your website.Learn more about debugging in WordPress. There has been a critical error on your website.

Multisite fatal error

When I try activate multisite network, script return error:

Uncaught Error: Class 'WP_SQLite_DB\DateInterval' not found in /home/mati75/websites/sqlite.local/wp-content/db.php:517                                                        
Stack trace:
#0 [internal function]: WP_SQLite_DB\PDOSQLiteUDFS->date_sub()
#1 /home/mati75/websites/sqlite.local/wp-content/db.php(1692): PDOStatement->execute()
#2 /home/mati75/websites/sqlite.local/wp-content/db.php(1408): WP_SQLite_DB\PDOEngine->execute_query()
#3 /home/mati75/websites/sqlite.local/wp-content/db.php(2740): WP_SQLite_DB\PDOEngine->query()
#4 /home/mati75/websites/sqlite.local/wp-includes/wp-db.php(2593): WP_SQLite_DB\wpsqlitedb->query()
#5 /home/mati75/websites/sqlite.local/wp-admin/includes/network.php(72): wpdb->get_row()
#6 /home/mati75/websites/sqlite.local/wp-admin/includes/network.php(189): allow_subdirectory_install()
#7 /home/mati75/websites/sqlite.local/wp-admin/network.php(116): network_step1()
#8 {main}
  thrown in /home/mati75/websites/sqlite.local/wp-content/db.php on line 517

on SQLite Integration plugin by Kojima Toshiyasu it works fine.

To make wordpress 6.1 work with this project

To make wordpress 6.1 it work with sqlite:

Change wp-admin/includes/upgrade.php:47: function wp_install

        /* begin wp-sqlite-db changes */
        // make_db_current_silent();
        WP_SQLite_DB\make_db_sqlite();
        /* end wp-sqlite-db changes */

Replace/update wp-includes/load.php function require_wp_db()

function require_wp_db() {
	global $wpdb;

	require_once ABSPATH . WPINC . '/wp-db.php';
	if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) {
		require_once WP_CONTENT_DIR . '/db.php';
	}

	/* begin wp-sqlite-db changes */
	if(!($wpdb instanceof  WP_SQLite_DB\wpsqlitedb)) {
		$wpdb = new WP_SQLite_DB\wpsqlitedb();
	}
	/* end wp-sqlite-db changes */

	if ( isset( $wpdb ) ) {
		return;
	}
	$dbuser     = defined( 'DB_USER' ) ? DB_USER : '';
	$dbpassword = defined( 'DB_PASSWORD' ) ? DB_PASSWORD : '';
	$dbname     = defined( 'DB_NAME' ) ? DB_NAME : '';
	$dbhost     = defined( 'DB_HOST' ) ? DB_HOST : '';

	$wpdb = new wpdb( $dbuser, $dbpassword, $dbname, $dbhost );
}

HY000SQLSTATE[HY000]: General error: 1 near "group": syntax error

I get an error while trying to access the WooCommerce All Products page. The page ends up timing out, and it looks like this plugin is stuck in an infinite loop here.

HY000SQLSTATE[HY000]: General error: 1 near "group": syntax error

SELECT a.*, g.slug AS group FROM wp_actionscheduler_actions a LEFT JOIN wp_actionscheduler_groups g ON a.group_id=g.group_id WHERE a.action_id=260

I get the same error if I try to execute this query directly from sqlite3. It is a problem with AS group. If I remove AS group, the query succeeds fine.

I'm under the impression that SQLite has support for AS, but it's not working here ๐Ÿ˜„

The problem is that this query is coming from WooCommerce, so I don't necessarily want to go modify that plugin. Looking for advice:

  • Is this fixable in the plugin?
  • Is there a more certain exit condition for this do...while loop?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.