-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hook in sqlite install before initial WP setup #7
Comments
I ran into the same problem. I've been looking at the code in the plugin's activation function. I'm wondering if there's some way to perform the same steps manually to get the sqlite support configured before initializing WP for the first time. |
So from my experience making docker images using the wp-sqlite-db dropin, the process would look something like this:
for the wp-sqlite-db based docker image I use, I include a custom version of |
@jeff-cannapress do you have an example of a dockerfile that does this? |
@patmood Here's the contents of the Dockerfile I used to get it working...
Note that I had to manually make the changes @jeff-cannapress mentioned to If the authors of the patch feel like things are stable enough and folks are interested in testing it out via Docker, I'd be happy to publish the image. |
@patmood I dont have one using the currently under-development plugin. However here is the version I use for local development based on the wp-sqlite-db plugin: This integrates adminer for database access via a shared volume in docker-compose. If all you're looking for is to spin up a site without a mysql instance: https://github.com/jeff-cannapress/wp_sqlite_docker/blob/main/.docker/wordpress/Dockerfile is the docker file |
For those interested, this is a Docker file I've used to build a Docker container containing Wordpress, Nginx and SQL database integration. Mostly based on https://github.com/TrafeX/docker-wordpress/blob/master/Dockerfile and this thread / links (Wordpress 6.1.1, plugin in 1.2.2). See https://github.com/TrafeX/docker-wordpress for the other referenced files.
|
For those interested: here's a Github repository for getting Wordpress with SQLite setup in Docker without any need for MySQL https://github.com/mdbraber/docker-wordpress-sqlite |
As long as SQLite is in the form of a plugin, there is no straight-forward way to setup a new site without using MySQL - unless you manually go through the steps in the original post. I do keep a branch of WP with SQLite integration if you would like to test that though... You can find it in WordPress/wordpress-develop#3220 and it basically integrates the classes and functions from this plugin, as well as add some changes to the install screen to make it easy to actually install a new WP site using SQLite 👍 |
The SQLite project got neglected for a couple of months because of the upcoming WP 6.3 release, we needed to focus on that. I'll try to get back on the horse and see what we can do for these things 👍 |
I just discovered this plugin and am excited to hear it's being worked on! I'm using this plugin on Windows with wp-phpunit for removing dependence on Docker for my test environment. Link: https://github.com/ZachWatkins/wordpress-theme/blob/main/test/phpunit/bootstrap.php Implementation
"repositories": [
{
"url": "https://github.com/wordpress/sqlite-database-integration.git",
"type": "git"
}
],
"scripts": {
"test": [
"@putenv WP_SQLITE_MODE=enabled",
"./vendor/bin/phpunit"
],
}
// Activate or deactivate WordPress SQLite Database Integration plugin.
if ( 'enabled' === getenv( 'WP_SQLITE_MODE' ) ) {
if ( ! is_dir( dirname( __DIR__, 2 ) . '/wordpress/wp-content/' ) ) {
mkdir( dirname( __DIR__, 2 ) . '/wordpress/wp-content/' );
}
file_put_contents(
dirname( __DIR__, 2 ) . '/wordpress/wp-content/db.php',
str_replace(
array(
'{SQLITE_IMPLEMENTATION_FOLDER_PATH}',
'{SQLITE_PLUGIN}',
),
array(
dirname( __DIR__, 2 ) . '/vendor/wordpress/sqlite-database-integration',
'sqlite-database-integration/load.php',
),
file_get_contents( dirname( __DIR__, 2 ) . '/vendor/wordpress/sqlite-database-integration/db.copy' )
)
);
/**
* Activate plugin.
*/
tests_add_filter(
'muplugins_loaded',
function () {
require dirname( __DIR__, 2 ) . '/vendor/wordpress/sqlite-database-integration/load.php';
}
);
} else {
// Undo changes if necessary.
if ( file_exists( dirname( __DIR__, 2 ) . '/wordpress/wp-content/db.php' ) ) {
unlink( dirname( __DIR__, 2 ) . '/wordpress/wp-content/db.php' );
$remaining_files = array_diff(
scandir( dirname( __DIR__, 2 ) . '/wordpress/wp-content/' ),
array( '..', '.' )
);
if ( empty( $remaining_files ) ) {
rmdir( dirname( __DIR__, 2 ) . '/wordpress/wp-content/' );
}
}
} |
We want people to use WordPress on the Raspberry Pi, so wanted an easy process to use this plugin without needing the MySQL server. Thank you @mdbraber for the docker file. I used it as a guide to create a more generic installation process. I think SQLite as an alternative holds much potential! |
chmod 777 for database file is a tragic security failure |
Fair, I will spend the weekend sorting out the right permissions and revise. |
Played a bit more with the plugin. I understand the SQLite requirements that is causing people to do 777 on the database folder and file. However I have changed the blog post to mimic what the plugin does,
Happy to improve further but probably need guidance from the team. |
I've resumed working on a solution which can initialize this plugin and run Would you accept a pull request if I found a way to make the plugin easier to provide this functionality natively? If it turns out that the replacement Use CaseIf someone has no experience with WordPress, I want them to have a plugin template repository they can install and run in a few CLI commands: .bin/install-php-and-composer.sh
composer install
.bin/prepare-wordpress-directory.sh
php -S localhost:8080 -t wordpress IssueIt's difficult to determine when to run the wp_install() function from another plugin while avoiding running core WordPress functions that attempt to access the MySQL database, thus resulting in a database access error. Non-PHP SolutionRunning |
I ran in this issue too and decided to create this little script: https://github.com/luizbills/create-wordpress-sqlite My goal was to be able to quickly install a WordPress on Termux (just out of curiosity). |
I'm surprised that no none has brought up WP-CLI for this. Wouldn't it be cool if you could just do something like |
I reckon you've thought of this, but, I'm blocked in testing because I think I'm forced through a traditional WP install.
I want to:
It looks like I have to:
Am I missing anything? Too early to the party -- that flow is coming?
The text was updated successfully, but these errors were encountered: