WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 7 years ago

#2317 closed enhancement (wontfix)

SQLite support for wp2.0

Reported by: tume Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.0
Component: General Keywords: sqlite
Focuses: Cc:

Description

Adds SQLite support to Wordpress 2.0. It's created against svn version of wp ( 20.01.2006 ).

My objective was to minimize the amount of modified code so it currently just parses the mysql specific statements and filters them out ( not necessarily the most efficients way to do it :).

I added file called wp-sqlite.php that takes care of the SQLite handling and I havent touched anywhere else in the existing code except some minor changes that hopefully dont affect mysql support or anything else.

This patch is currently in state of "works for me(tm)". I don't have time to test properly this, altough I'm running wp with sqlite in my on website. There might be and prorably are some bugs that I havent discovered e.g. I haven't checked any code for upgrade or backup so no idea if it works.

This patch isn't very finished and I myself don't really have much time to work with this so I hope someone will get something useful done with this patch.

Attachments (2)

sqlite_wp2.patch (32.1 KB) - added by tume 8 years ago.
SQLite support
sqlite+wordpress.2.0.2-2.diff (30.1 KB) - added by havarddahle 8 years ago.
Second patch. Code cleanup and syntactic errors removed.

Download all attachments as: .zip

Change History (13)

tume8 years ago

SQLite support

comment:1 tume8 years ago

Forget to say that I made this using php5 that comes with SQLite bundled in so to use SQLite in php4 you need to install the SQLite module and then load it. All functions should also work in php4 but if don't let me know. Mail can be send to tume@…

PS. And that patch is pretty big mesh, sorry for that.

comment:2 markjaquith8 years ago

Could this be done as a plugin?

comment:3 havarddahle8 years ago

I also don't need mysql, and tume's patch is certainly a big step in that direction. With some tweaking, I now run the latest WP and sqlite (on PHP 5.0.5-2ubuntu1.2 CGI).

I've attached a new diff based on his work, with the changes I had to do for it to work on my setup, using wp 2.0.2.

Note that I never seem to get the hang of creating diffs, so it might blow up your toaster and all that. However, it does apply cleanly for me:

  $ cd wordpress-2.0.2/
  $ patch --verbose -p1 < ../sqlite+wordpress.2.0.2-2.diff

Also, remember to give write permissions to the web user on the directory where you keep your sqlite database(s). Look at the comments in wp-config-sample.php.

tume's original patch had quite a few whitespace changes, and some syntactic errors, I've kept the whitespace and removed the errors. It is still rough, but it works.

NB. Note that categories are screwed up (I can't create them), but I have not yet determined whether it is browser related (Konqueror), sqlite related, or a big bad bug.

Have fun,

Hå-hå-håvard

havarddahle8 years ago

Second patch. Code cleanup and syntactic errors removed.

comment:4 havarddahle8 years ago

Update: I said categories are screwed up (I can't create them), and it's caused by a collision of category ids: new categories are added to the database with a cat_ID == 1, even though that id already exists.

I do not know why this happens, but tume's patch does do something to category ids. I have not had time to sort this out yet, let alone figure out why tume did that in his patch. Too many aliens in the front yard.

Now, where's that water hose...


comment:5 davidhouse8 years ago

Quick tip: if you use svn diff instead of bog-standard diff to create your patches, they normally apply fine with a patch -p0 < patchfile.

comment:6 foolswisdom8 years ago

  • Milestone changed from 2.5 to 2.2

comment:7 follow-up: cdavies8 years ago

I'm a big fan of this feature request, the attached patch still applies cleanly to 2.0.4, and I'm using it now. The broken categories bug was easy to fix, it was because the code inserts a value in to the cat_ID field. That field is marked as the primary key, and as an auto incrementing field.

I don't really know enough about mysql to tell if the original code is a defect or not, but here's a diff snippet that makes it work for sqlite.

--- wp-admin/admin-db.php       2006-10-20 01:59:48.400611520 +0100
+++ /home/cdavies/wordpress-sqlite/wp-admin/admin-db.php        2006-10-20 00:07:32.231664856 +0100
@@ -109,7 +109,7 @@
                $category_parent = 0;
 
        if (!$update) {
-               $wpdb->query("INSERT INTO $wpdb->categories (cat_name, category_nicename, category_description, category_parent) VALUES ('$cat_name', '$category_nicename', '$category_description', '$category_parent')");
+               $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('1', '$cat_name', '$category_nicename', '$category_description', '$category_parent')");
                $cat_ID = $wpdb->insert_id;
        } else {
                $wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent' WHERE cat_ID = '$cat_ID'");

comment:8 in reply to: ↑ 7 cdavies8 years ago

Oops, should have noticed I reversed the diff before posting that... never mind, just apply it reversed or do it by hand :)

comment:9 beoba7 years ago

Are there any patches available for 2.1?

comment:10 foolswisdom7 years ago

  • Milestone 2.2 deleted

comment:11 Nazgul7 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

It's been said that support for databases other than MySQL is plug-in territory.

Note: See TracTickets for help on using tickets.