Using latest stable 6.x-2.1 build I noticed this error occasionally in my site's log:

Missing argument 1 for hashcash_get_hashcash() in /home/.katona/davereid20/drupal-6/sites/all/modules/hashcash/hashcash.module on line 70.

I suspect it has something to do with the hook_menu entry because it does not enforce that there must be a argument passed to hashcash_get_hashcash():

function hashcash_menu(){
  ...
  $items['hashcash'] = array(
    'title' => 'Get Hashcash',
    'description' => 'Returns the start part of a hashcash string',
    'page callback' => 'hashcash_get_hashcash',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK
  );
  ...
}

function hashcash_get_hashcash($form_id){
 ...
}

If the $form_id isn't mandatory, then you should add a default value to it like the following:

function hashcash_get_hashcash($form_id = ''){
 ...
}

If the $form_id parameter must *always* be present, then you should use something more like the following:

function hashcash_menu(){
  ...
  $items['hashcash/%'] = array(
    'title' => 'Get Hashcash',
    'description' => 'Returns the start part of a hashcash string',
    'page callback' => 'hashcash_get_hashcash',
    'page arguments' => array(1),
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK
  );
  ...
}

I'm guessing the latter is probably the preferred option since it doesn't make sense if $form_id is always desired.

Comments

sdrycroft’s picture

Thanks for this David, you're right, the code should be the same as your second example. What concerns me a little more though, is why is the URL http://example.com/hashcash being retrieved? If I change the code, then that will only replace the PHP warning messages with 404 Not found errors, and doesn't fix the underlying problem. Can you possibly check to see on what page the error is being produced, and with what form?

dave reid’s picture

StatusFileSize
new874 bytes

I should have mentioned that it looked like it was accessed directly since there was no referring page and the error said it came from the /hashcash path. I 404 error would be much preferred.

dave reid’s picture

Status: Active » Needs review
sdrycroft’s picture

Version: 6.x-2.1 » 6.x-2.2
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.