Closed (fixed)
Project:
Hashcash
Version:
6.x-2.2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Oct 2009 at 21:06 UTC
Updated:
26 Oct 2009 at 14:50 UTC
Jump to comment: Most recent file
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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 601748-hashcash-undefined-formid-D6.patch | 874 bytes | dave reid |
Comments
Comment #1
sdrycroft commentedThanks 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?
Comment #2
dave reidI 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.
Comment #3
dave reidComment #4
sdrycroft commented