Saturday, August 22, 2009

Drupal to Wordpress migration and sitemaps generation

For a website that I'm managing with friends I am planning to migrate from Drupal to Wordpress so I have used the following link that describes a nice way how to do it.

Note: everything done here has been made on a server running Ubuntu.

Then I have installed the Sitemaps generator plugin for wordpress.

After the configuration of the plugin I have encountered several issues.

The first one was that the plugin was not able to generate the sitemaps file for my blog (6000 posts) and was returning the following error :

Fatal error
: Allowed memory size of 33554432 bytes exhausted (tried to allocate 71 bytes) in /home/xxx/public_html/ntfr/wp-includes/plugin.php on line 302

So I first tried to upgrade my Apache configuration by updating the variable memory_limit to 64M in /etc/php5/apache2/php.ini and then restart Apache but I was still facing the same problem.

Then I have tried to add the following code to the wp-config.php file but the problem was still there:
define('WP_MEMORY_LIMIT', '64M');

The next step was to take a look at the plugin code and I have made a change to the sitemap.php file in the LoadPlugin function by upgrading memory_limit to 64M. The code changed is below:


1
2
3 function LoadPlugin() {
4
5 $mem = abs(intval(@ini_get('memory_limit')));
6 if($mem && $mem < 32) {
7 @ini_set('memory_limit', '64M');
8 }
9
10 $time = abs(intval(@ini_get("max_execution_time")));
11 if($time != 0 && $time < 120) {
12 @set_time_limit(120);
13 }
14
15 if(!class_exists("GoogleSitemapGenerator")) {
16
17 $path = trailingslashit(dirname(__FILE__));
18
19 if(!file_exists( $path . 'sitemap-core.php')) return false;
20 require_once($path. 'sitemap-core.php');
21 }
22
23 GoogleSitemapGenerator::Enable();
24 return true;
25 }
26



Thanks to all the changes described above I was able to generate a Google Sitemaps for my wordpress blog but the content of the file was not ok for me due to the fact that last modification of the posts was not correct. The migration from drupal to wordpress is not filling the following fields of the wp_posts table :
  • post_modified
  • post_date_gmt
  • post_modified_gmt
So here is the sql code to that (in my case my server is in Paris but you will have to replace it to your timezone):
UPDATE wp_posts SET post_modified = post_date;
UPDATE wp_posts SET post_date_gmt = convert_tz(post_date, 'Europe/Paris', 'GMT');
UPDATE wp_posts SET post_modified_gmt = convert_tz(post_modified, 'Europe/Paris', 'GMT');

Note: before using convert_tz you will have to setup mysql timezones by typing the following command:

mysql_tzinfo_to_sql /usr/share/zoneinfo/ | mysql -u root mysql -p

Sunday, July 12, 2009

Ubuntu 9.04 and Intel Corporation PRO/Wireless 4965 AG or AGN

Since my update to Ubuntu 9.04 I was experiencing lots of wifi connections problems.

Into the logs I was getting messages such as:
  • Kill switch must be turned off for wireless networking to work.
  • ADDRCONF(NETDEV_UP): wlan0: link is not ready
  • ...
It was really boring but a solution to all wifi connections problems with the "Intel Corporation PRO/Wireless 4965 AG or AGN" controller is available by installing the package linux-backports-modules-jaunty (you will have to add the jaunty-backports repository to your software sources). Then reboot and voila.