Hi All,

Please take a look at this...

www.fenella.net

...which is currently giving a "Warning: Missing argument 5 for drupal_error_handler() in..." error.

I got this error on Drupal V6.5 so upgraded to 6.6 whereupon it vanished only to reappear a few days later. Does anyone have any idea why this might be?

Cheers,
Nigel

Comments

ludo1960’s picture

I'm not an expert but:

line 583 in common.inc

* Error levels:
* - 0 = Log errors to database.
* - 1 = Log errors to database and to screen.
*/

Check your settings.php maybe there is something there about error levels

gpk’s picture

Actually line 583 is this: http://cvs.drupal.org/viewvc.py/drupal/drupal/includes/common.inc?annota...

Looks like PHP is invoking the error handler but not supplying the (optional) fifth argument. You may have found a bug in Drupal. What happens if you make a backup of includes/common.inc and then modify line 583 to read:

	function drupal_error_handler($errno, $message, $filename, $line, $context = NULL) {

I'm guessing the real error occurring on the site will get logged to the watchdog log.

gpk
----
www.alexoria.co.uk

ludo1960’s picture

At least I tried to help...was pretty close though!

alan d.’s picture

The $filename, $line, $context should all be optional. @see http://php.net/set-error-handler

Eg:

<?php
handler  ( int $errno  , string $errstr  [, string $errfile  [, int $errline  [, array $errcontext  ]]] )
?>

Alan Davison
www.caignwebs.com.au

Alan Davison
gpk’s picture

Yes, presumably that means all 3 should have defaults specified?

I'm hoping that the op will post back as to whether the suggested change helped, then we can get this fixed in core.

gpk
----
www.alexoria.co.uk

NigelFK’s picture

As directed I changed line 583 to this...

function drupal_error_handler($errno, $message, $filename, $line, $context = NULL) {

...and it seems to work!

Regards,
Nigel

gpk’s picture

Glad that's fixed it, presumably you got some errors in your dblog/watchdog?

gpk
----
www.alexoria.co.uk

NigelFK’s picture

Sorry, I'm a newbie...where do I look for these logs?

gpk’s picture

Administer -> Reports -> Recent log entries

gpk
----
www.alexoria.co.uk

NigelFK’s picture

I've checked and there are a LOT of (trivial) entries in the log and it might take quite a while to find the necessary entries. But, if it is important I'll do it so let me know if I should.

Regards,
Nigel

gpk’s picture

All I was getting at was that your original problem was caused by a PHP error (this is why Drupal's error handler was being invoked) which could indicate a problem with your site. Any such errors are logged to the "Recent log entries page" - try filtering by PHP messages if you are concerned.

gpk
----
www.alexoria.co.uk

NigelFK’s picture

Okay, thanks. This is a log entry (one of many) for the error...

parse_url(http:///index.php?q=admin/reports/request-test) [function.parse-url]: Unable to parse url in /hsphere/local/home/nigelfra/fenella.fraserker.com/includes/common.inc on line 436.

To my inexperienced eye it looks like the sort of thing I would have expected given the above diagnosis.

Cheers,
Nigel

gpk’s picture

That's odd .. there seems to be an extra / after the http:

Actually the domain name is missing. I guess it should be fenella.net? Looks like this may be a Windows-related issue. Have you defined $base_url in your settings.php file (usually that line is commented out)? If not then maybe Drupal is calculating it incorrectly.

gpk
----
www.alexoria.co.uk

jacklemon’s picture

Thanks, the same worked for me too.

However, when you google for that error message you will notice that they all seem to stem from the same isp system: /hsphere/local/home/
so whatever hsphere is, it's causing this error message.

NigelFK’s picture

Yes, the domain name is fenella.net

I guess that hsphere must be the Host Excellence server that I'm running the site on. I will draw their support team's attention to this thread and see if they can shed any light on the problem.

Cheers,
Nigel

direkt’s picture

I too have a site on hsphere/../.. with the same error, I replaced the line and its seems to work here.
I figure it has something to do with the flash node module as these are the only page I encountered these errors

Thanks,
Derek

gpk’s picture

>I figure it has something to do with the flash node module
Interesting. Perhaps the flash applet generates HTTP requests that don't specify the HTTP_HOST (in contravention of some RFC...).

So I reckon there could be a 2nd bug here - Drupal shouldn't fall over in this way if HTTP_HOST is not defined. There are other clients that could cause this to happen.

gpk
----
www.alexoria.co.uk

alan d.’s picture


Alan Davison
gpk’s picture

Yes I thought I'd seen an issue about this ... is the $base_url problem a separate issue though?

gpk
----
www.alexoria.co.uk

alan d.’s picture

As far as I known you can not generate the $base_url without the host variable using PHP. I haven't read through the HTTP specs, but found this on the web earlier:

1. Do HTTP/1.0 clients send an HTTP_HOST?
No
2. If they don't, is there a way I can get the URL they are requesting using PHP?
No, the information doesn't exist in HTTP/1.0.

This was a major reason for HTTP/1.1.
HTTP/1.0 does not allow for the use of shared IP addresses among several domains.
HTTP/1.1 added the Hostname header to HTTP requests to support shared virtual hosting.

The server may be running as a cgi, and there may be some environment variables set that will have this info, but I generally follow the KISS principle, so best just to set the base url in settings.php


Alan Davison
www.caignwebs.com.au

Alan Davison
gpk’s picture

Fair enough, I think what I was groping towards was that while #346285: Drupal 5.14 & Drupal 6.8 will not load on clients that do not transmit HTTP_HOST fixes part of the problem with requests from HTTP/1.0 clients, the problem at comment-1133684 may still arise if $base_url is not hard-coded (it seems to occur in http://api.drupal.org/api/function/drupal_http_request/6). If so then I guess it will rear its ugly head soon enough.

I think you may be saying much the same thing.!

gpk
----
www.alexoria.co.uk

alan d.’s picture

After tracing through the code, I think I found where this error is happening:

Firstly, since $base_url is not being set, Drupal calculates it as:

<?php
    $base_url = $base_root .= '://'. preg_replace('/[^a-z0-9-:._]/i', '', $_SERVER['HTTP_HOST']);
?>

Then latter when Drupal tries to clear 'drupal_http_request_fails' variable, it triggers the URL given above, with the absolute flag set, which uses the falsely defined $base_url.

OK, long story short, is $_SERVER['HTTP_HOST'] being set correctly?


Alan Davison
www.caignwebs.com.au

Alan Davison