When Pigs Fly

Diogenes's picture

When Pigs Fly is actually a Drupal sandbox project. Someday it may become an official Drupal contributed module, but don't hold your breath.

Though there are contributed Modules on the Drupal.org website that are far more useless than this one, the chances are high that When Pigs Fly will never quite make it there. 

Nonetheless, there are some developers that may find this useful, if only for the practical jokes you can play on a fellow Drupal developers.

Motivation

When Pigs Fly (WPF) was created to help explain why no Drupal API functions are suitable for installation of a module that creates a page with a reconfigurable url. 

Consider the following implementation of hook_menu():

function wpf_menu() {
  return array($url => array(
    'title' => 'When Pigs Fly',
    'description' => 'Demonstration of potential url conflicts',
    'page callback' => 'pigsfly_now', 
    'access callback' => TRUE,
  ));
}

where $url is a drupal system variable that can be changed by someone with sufficient privileges. Before it can be changed to a new value, it is prudent to verify that the requested url is NOT already in use, just like a user name.

A lot of Drupal developers may be a bit surprised to find the standard installation of a new contributed module does not check for potential url conflicts between different implementations of hook_menu().

What is WPF?

It creates a single silly page for demonstration purposes. Review the code first -- thankfully, there isn't much.

The WPF module has a companion module called Baboons Beware (BB) that is almost exactly the same. The idea is to enable one, then the other, then both.


You can download both modules (the complete Aardvark package) here: wpf-7.x-wtf.tar.gz or wpf-7.x-wtf.zip or download each module separately from the respective git repository.

Both modules do almost exactly the same thing with the same designated url -- /whenpigsfly.  Both modules brazenly assume that this url is available. Both modules have almost exactly the same implementation of hook_menu().

How NOT to use WPF

The README.txt file has detailed instructions on HOW NOT TO USE these modules. It also suggests a few other exercises that  may surprise some. The objective is to help developers become aware of potential url conflicts within Drupal.

Both WPF and BB modules have a bonus hook_help() implementation which is Help but no help at all. The code reveals nothing; it has to be experienced to really appreciate the true meaning of that last sentence. But it does demonstrate a novel way to use implement hook_help().

Hack away and have some fun with your fellow developers. It will be a learning experience that might prove useful someday.