Auto-updater for PDO For WordPress

wouldn’t it be a good idea to have a plugin or similar functionality within PDO for WordPress that checks periodically for new versions? I’m finding that now the plugin is posted on wp.org i’m getting more bug reports – which is great. as a result there are new releases of the code every couple of days. some way of polling the wp server for updates would be clever.

i wonder whether i can do this by creating an actual plugin within the code?

Any ideas on how to do this would be gratefully received.

7 Comments

TomasSeptember 30th, 2008 at 11:26 am

Hello Justin,
I didn’t find an email on these pages, so I post a comment here.
I found 2 bugs in the PDO for WordPress plugin (version 1.02):
1) documentation: before the installation process starts, you must create manually dir wp-content/database and set it writable (chmod 777) for all.
2) function preg_last_error used on one place in the code is new in PHP 5.2. Documentation says, that 5.0+ is required. Either correct the documentation or get rid of the function.

Tomas

JustinSeptember 30th, 2008 at 11:37 am

thanks for your feedback Tomas.

the installer should create the directory for you if, like most setups, the web process has write ability to the wp-content directory. You are right that, if your system is not set up like this, you will need to do it manually. The error feedback from the script should say something helpful. I will update if it does not.

You are also right on the preg_last_error(). I use this in the sqlite schema creation and will also be using it in the dbdelta replacement function. It is not at all necessary other than for debugging and i will add a function exists check in the next version.

Please feel free to post your comments and feedback rather than email them. I also have an experimental new version available that uses more php rather than PCRE functions. There is a performance enhancement (subjectively verified but unmeasured). It also corrects a number of minor defects with date handling routines in the WP Core. Let me know if you want to try it out.

Jusitn

TomasOctober 6th, 2008 at 2:18 pm

Hello Justin, here are my several more comments:
ad 1 (database folder) – the standard installation (2.6.2) has drwxr-xr-x permissions on wp-content, so it didn’t create the folder database. It is a minor issue as I can create the folder manually.

ad 2 (preg_last_error) I just replaced the calling of preg_last_error with zero. I hope I didn’t break something important.

I had a problem with archives function in wordpress. Using the sqlite database, it simply does not work. The critical part of the query is created in file wp-includes/query.php, lines 884 to 894.
Here is an excerpt from the debug file:
Raw query: Select count(*) from wp_posts WHERE 1=1 AND YEAR(wp_posts.post_date)=2008 AND MONTH(wp_posts.post_date)=01 AND …..

Rewritten: Select count(*) from wp_posts WHERE 1=1 AND strftime(‘%Y’,wp_posts.post_date) =2008 AND strftime(‘%m’,wp_posts.post_date) =01 ….

Notice that the numbers 2008 and 01 are not quoted and the sqlite founds nothing. When I added the quotes in the original WP file, it worked well. I think there is probably difference in the return values of functions YEAR and MONTH on one side and strftime() on the other side. I don’t know how hard it would be to do proper handling in the Sqlite PDO driver. Sqlite is almost typeless, which may lead to problems.

JustinOctober 6th, 2008 at 2:25 pm

Tomas – you’ve uncovered a bug that is mostly in the WP core rather than my code. it is not seen normally as mysql is pretty type agnostic when running comparison queries. it is because sqlite is typeless that it enforces comparison operations more strictly.

i have code that is untested but that others have reported successfully fixes this problem. i’ve discussed it elsewhere on this blog too. I’m happy to send you a copy if you would be willing to provide feedback.

the preg_last_error is used only for debugging. i was getting some problematic recursive errors on the processing of complex create statements, and wanted to see what was going on. it is not necessary in ordinary usage.

TomasMarch 25th, 2009 at 9:52 pm

Hello Justin, after several months I eventually managed to do some progress on my WordPress page. At first I published a post with a guide how to solve the problem with archive function from my comment above. URL is http://linux.fjfi.cvut.cz/~tomik/personal/?p=61 , you can find another 2 post about wordpress there.

Second: I tried to upgrade to WP 2.7.1 and I get error message:

Warning: mysql_get_server_info(): supplied argument is not a valid MySQL-Link resource in /home/tomik/public_html/wordpress/wp-includes/wp-db.php on line 982

It seems that something has changed in WP. Do you plan to publish any new version of PDO?

JustinMarch 25th, 2009 at 10:08 pm

@Tomas:
indeed, something has changed in WP. and it breaks older versions of my plugin.
I have emailed you an alternative version

MatthieuMarch 31st, 2009 at 5:14 pm

hi justin,can i get the new version please please please? :)

Leave a comment

Your comment