Posts

Pages

pages

WordPress had a point release update earlier this week, 4.4.1. And it broke my website.

The pagination at the bottom of the site would not work. It would only return to the front page of the site.

I use the Enfold theme for this website so I thought I should check there first. And, sure enough, lots of sites were reporting the same problem.

I logged a support request and I was asked to try a lot of code changes. No joy. Nothing worked.

Finally, it became evident that the root cause was not in the theme itself but somewhere in the core of the most recent release of WordPress. You can find the rather curious thread about that particular bug here. It makes for some fascinating reading about how open source issues are identified, tracked and resolved.

Funny how little things have changed. We still have to write code not unlike how we did several decades ago.

I was looking at some old C code that I had written back in the early 1990s — over 25 years ago. I had written a text editor and here is one of the functions from my source code:

EditFileC

And here is the PHP code that I had to change in the WordPress core to regain the pagination function for the blog. I needed to remove the section of code with the comment “Old Post Paging” and replace it with the new section of code “New Post Paging”:

FixPaginationPHP

That PHP code does not look very elegant to me. Whenever I see multiple AND operators in a conditional statement with further nested conditional statements I get a bit nervous. It looks like a quick patch. It works but it doesn’t look very refined.

WordPress is largely built on PHP and PHP is very similar in syntax to C. The PHP code, though, just looks a bit “thick” to my eye.

C is still an incredibly elegant and poetic programming language. I always enjoyed producing compact, efficient software in C.

Dennis Ritchie was a genius.

Apache, MySQL, PHP and WordPress

I’ll be doing some work with WordPress on another musician’s website. WordPress is an open source content management system. The blog you are reading is powered by WordPress.

Typically, a WordPress blog is driven by a LAMP server: Linux, Apache, MySQL and PHP. Because I run a Mac, I can host a WordPress environment on my local machine. I can use a Mac as if it were a LAMP server.

Apache is enabled by simply turning on Web Sharing under the Sharing option of System Preferences. Or, if you are a diehard Unix geek, you can bring up the Terminal app and enter:

sudo apachectl start

Make sure you have your root password handy.

PHP is installed in Mac OS X by default, but not enabled. To enable it, the Apache 2 configuration file, which is located at /etc/apache2/httpd.conf, has to be edited. There is a line which loads the PHP 5 module, which looks like this:

#LoadModule php5_module libexec/apache2/libphp5.so

Remove the comment symbol, #, and save the file. And restart Apache.

sudo apachectl restart

I had to download MySQL and install it myself. Not the most user friendly database install. And, even though I had the database up and running, my local install of WordPress would not connect to the database. It turns out that I had to edit a line in the wp-config.php file to replace localhost with a default IP address:

define(‘DB_HOST’,’127.0.0.1′);

After a few hours of Unix hacking, I had a full WordPress development machine on my Mac. Just like using a LAMP server on my ISP. For whatever reason, it felt good to still be able to hack around Unix, Apache, MySQL, PHP and WordPress.

I am a hopeless geek.