WordPress Logo

Logging Errors In WordPress

21st June 2011 - 3 minutes read time

To debug WordPress many sites will tell you to add the WP_DEBUG setting on its own to your wp-config.php file, but this can be quite harmful as many server configurations will start showing PHP errors and warning messages on your site pages. Most sites will also log any errors to some form or error log, but this isn't always the best place for them to go.

It is possible to add a set of debug options that will allow WordPress to log any errors or warnings to a file. Open up your wp-config.php file and add the following lines of code above the line that says "/* That's all, stop editing! Happy blogging. */". Any changes to this file should always go above this line so that you can keep track of them.

Drupal Logo

Drupal 7 Queues API

15th June 2011 - 26 minutes read time

The Drupal 7 Queues API is a few feature of Drupal and provides a first in first out data structure that is used internally by Drupal itself and can be completely customised.

The Queues API isn't just a part of the codebase of Drupal, it is used internally as part of several different processes. The Batch API, which allows lots of things to be done at once, is built upon the Queues API and provides some customised queue classes. I won't be going into the batch API in this post, but I might cover it in later posts.

The new cron system in Drupal 7 uses the Queues API heavily. It works by allowing other modules to create queue items during their normal hook_cron() calls, which are then run afterwards. Each module that wants to include an item in the system cron queue can do so by implementing a hook called hook_cron_queue_info(), which tells cron what function to callback when the queue items are retrieved.

Phing Logo

Getting Time And Date Values In Phing

10th June 2011 - 5 minutes read time

The tstamp task in Phing can be used to generate a timestamp that can be used anywhere within the current project. The default behaviour of tstamp is to create the properties DSTAMP, TSTAMP and TODAY, which contain time and date values. All you need to do is include the tstamp XML tag in your project somewhere.


The properties DSTAMP, TSTAMP and TODAY use the PHP strftime() function as a basis for formatting the time. The following table shows the value of each property.

Drupal Logo

Drupal7Camp Leeds 2011: A Review

25th May 2011 - 25 minutes read time

This weekend I attended the Druapl7Camp 2011 in Leeds and so I booked a hotel room for the weekend and managed to find the right place on Saturday morning. I was one of the first to arrive and was able to greet people as the came through the door. With coffee flowing nicely and the wifi appearing to be stable we all set down to the first session.

Image removed.
Photo By Richard Burford

Day 1

Install Party/Webfaction Demo
Steve Cowie

Logging In As Superuser In Drupal 6 SimpleTest

19th May 2011 - 4 minutes read time

Sometimes the most complex part of using SimpleTest is making sure that everything is working as it should before you start your tests. This means setting up the correct modules and creating the correct content types in advance. Because SimpleTest works by issuing CURL requests to pages the most reliable way of doing certain tasks is to use the administration forms as you normally would. Taking an example, if you want to enable a block from a module you should submit the block form, adding the blocks you need to the various different regions this like.

// Enable the different blocks
$blocks = array(
    'my_awesome_block' => 'header'

$this->drupalPost('admin/build/block', $blocks, 'Save blocks');

However, if you haven't given the current user 'administer blocks' access, or have forgotten to log them in, then you will get an access denied error when you try to do this.

Drupal Logo

Drupal7Camp Leeds 2011 This Weekend

17th May 2011 - 2 minutes read time

ImageThis weekend (21st-22nd May) will be the Drupal7Camp 2011 in Leeds and I have organised myself tickets and hotel to attend. Drupal7Camp is a barcamp that is devoted Drupal 7, and so will consist of talks and sessions from the attendees. As a result the actual sessions list will not be decided until the day and will also consist of some informal discussions and workshops.

I will be representing #! code at the event (probably with my #! code t-shirt) and will be giving a session on the use of the new queues functionality in Drupal 7.

Drupal Logo

Drupal 6 Upload Module Reference Warnings

16th May 2011 - 4 minutes read time

I was testing out a new Drupal project build and found this strange error when uploading files to nodes using the Upload module. This error produced a lot of warning messages that appeared on the screen (in the process alarming my project manager) but appeared to have no impact on the actual function of the module, or the file uploaded. Essentially, when a file was uploaded the following errors were produced.

PHP Logo

PHP Question: Defining Constants

9th May 2011 - 4 minutes read time


What does the following code do?

define("MY_CONSTANT", array(1,2,3,4,5));



If this code is run it will produce the following error:

Warning: Constants may only evaluate to scalar values in test.php on line x

This is because only scalar values can be assigned to constants. A scalar value is any integer, float, string or boolean value and does not include arrays, objects or resources. Trying to set any non-scalar value as a constant will produce this error.

PHP Logo

PHP Question: Class Methods

4th May 2011 - 4 minutes read time


What is the difference between these two lines of code and can you produce the background code used for them?