Wordpress with Sqlite

I’m testing out wordpress with sqlite, it seems to work pretty well so far.
I’ve got it in a patch file format, and added some fixes to make it work with PHP4.


diff -Pbu -r /home/private/wordpress/data/.htaccess ./data/.htaccess
--- /home/private/wordpress/data/.htaccess	Thu Jan  1 00:00:00 1970
+++ ./data/.htaccess	Mon Sep 10 00:51:43 2007
@@ -0,0 +1,2 @@
+order deny,allow
+deny from all
Binary files /home/private/wordpress/data/wordpress.db and ./data/wordpress.db differ
diff -Pbu -r /home/private/wordpress/wp-admin/install.php ./wp-admin/install.php
--- /home/private/wordpress/wp-admin/install.php	Fri Jun 15 17:45:21 2007
+++ ./wp-admin/install.php	Mon Sep 10 00:17:47 2007
@@ -1,6 +1,8 @@
 < ?php
 define('WP_INSTALLING', true);
 if (!file_exists('../wp-config.php')) {
+  /* otherwise plugin/did_action relies on wp-settings.php which relies on wp-config.php */
+  function did_action($name) { return FALSE; }
   require_once('../wp-includes/functions.php');

diff -Pbu -r /home/private/wordpress/wp-admin/upgrade-functions.php ./wp-admin/upgrade-functions.php
--- /home/private/wordpress/wp-admin/upgrade-functions.php	Thu May 10 16:31:49 2007
+++ ./wp-admin/upgrade-functions.php	Sun Sep  9 15:09:16 2007
@@ -1101,6 +1101,9 @@
 }

 function wp_check_mysql_version() {
+
+    return;
+
 	global $wp_version;

 	// Make sure the server has MySQL 4.0
diff -Pbu -r /home/private/wordpress/wp-admin/upgrade-schema.php ./wp-admin/upgrade-schema.php
--- /home/private/wordpress/wp-admin/upgrade-schema.php	Thu Apr 19 22:26:52 2007
+++ ./wp-admin/upgrade-schema.php	Sun Sep  9 23:40:46 2007
@@ -3,7 +3,9 @@

 $charset_collate = '';

-if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) {
+// sqlite doesn't require this
+$SQLITE = TRUE;
+if ( !$SQLITE && version_compare(mysql_get_server_info(), '4.1.0', '>=') ) {
 	if ( ! empty($wpdb->charset) )
 		$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
 	if ( ! empty($wpdb->collate) )
diff -Pbu -r /home/private/wordpress/wp-config.php ./wp-config.php
--- /home/private/wordpress/wp-config.php	Mon Sep 10 00:57:23 2007
+++ ./wp-config.php	Mon Sep 10 00:33:07 2007
@@ -7,7 +7,8 @@
 define('DB_CHARSET', 'utf8');
 define('DB_COLLATE', '');

-define('DB_FILE', '/var/www/htdocs/wordpress.db');    // The full path of the database
+$dbfile = dirname(__FILE__) . '/data/wordpress.db';
+define('DB_FILE', $dbfile);    // The full path of the database
 //make sure the directory and the file is **writeable** by the web server

 // You can have multiple installations in one database if you give each a unique prefix
diff -Pbu -r /home/private/wordpress/wp-content/db.php ./wp-content/db.php
--- /home/private/wordpress/wp-content/db.php	Mon Sep 10 00:57:37 2007
+++ ./wp-content/db.php	Sun Sep  9 15:18:10 2007
@@ -688,4 +688,22 @@
 }
 $wpdb = new wpdb( DB_FILE );

-?>
+/* PHP 4 compatibility */
+if (!function_exists('sqlite_fetch_object'))
+{
+ function sqlite_fetch_object($resource, $classname=null, $ctor=array(), $decode_binary=FALSE)
+ {
+   $arr = sqlite_fetch_array($resource, SQLITE_ASSOC);
+   return is_array($arr)? (object) $arr: null;
+
+ }
+}
+
+if (!function_exists('str_ireplace')) {
+    function str_ireplace($needle, $str, $haystack) {
+        $needle = preg_quote($needle, '/');
+        return preg_replace("/$needle/i", $str, $haystack);
+    }
+}
+/* end PHP 4 compatibility */
+

One Response to “Wordpress with Sqlite”

  1. vince writes:

    Hey there,

    This is Vince from SocialRank.

    We’re launching a new Web 2.0 site dedicated to python and we have started indexing your blog posts as part of our content filter.

    I’d like to send you an invite to a beta preview. Can you get back to me with your email address.

    Mine is vince@SocialRank.com

    Thanks
    Vince

Leave a Reply