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.

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.

  1. <tstamp>
  2. </tstamp>

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.

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.

Drupal 7 Camp Introduction
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.

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 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 Question: Defining Constants

9th May 2011 - 4 minutes read time

Question

What does the following code do?

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









 

Answer

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

PHP Question: Class Methods

4th May 2011 - 4 minutes read time

Question

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

PHP Question: PHP Script Shape

1st May 2011 - 5 minutes read time

Question

Write a PHP script that will print out the following text in the correct diamond shape.

  1. *
  2. ***
  3. *****
  4. *******
  5. *********
  6. *********
  7. *******
  8. *****
  9. ***
  10. *