Non-static method upload::isReadable()

See all posts Add a new post

Non-static method upload::isReadable() new!
by Steve M, 17 years, 6 months ago
Wonderful class. Got this working on my local web server with no problem. Uploaded my code to a Plesk/Fedora environment and the same bit of code is producing a problem. In the Apache log it reads:

PHP Fatal error: Non-static method upload::isReadable() cannot be called statically in class.upload.php on line 1818

Completely perplexed. Permissions look fine. Does anyone have any ideas?

Many thanks,
SteveReply
Re: Non-static method upload::isReadable() Problem new!
by colin, 17 years, 6 months ago
Hi Steve,

It is a bug, thank you for reporting it. You must have PHP5. I will fix it in the next release. Read More information about the problem here

In the meantime, if you use PHP5, you can do the following:
Replace lines 1818-1825
if ($this->processed && !isReadable($this->file_src_pathname)) {
    $this->processed = false;
    if (is_readable($this->file_src_pathname)) {
        $this->error = _("Source file is not readable. open_basedir restriction in place?");
    } else {
        $this->error = _("Source file is not readable. Can't carry on a process");
    }
}
with
if ($this->processed && !($f = @fopen($this->file_src_pathname, 'r'))) {
    $this->processed = false;
    if (is_readable($this->file_src_pathname)) {
        $this->error = _("Source file is not readable. open_basedir restriction in place?");
    } else {
        $this->error = _("Source file is not readable. Can't carry on a process");
    }
} else {
    fclose($f);
}

I can't test it right now, but I think it should work. Please let me know.Reply
Re: Non-static method upload::isReadable() Problem new!
by Steve M, 17 years, 6 months ago
Thanks for the prompt reply.

Yes I'm using 5.0.4.

I've implemented your changes but other problems occur further down is_writeable. I've attempted a similar fix but this leads to a further problemReply
Re: Non-static method upload::isReadable() Problem new!
by colin, 17 years, 6 months ago
Yes, the same fix has to be applied to isWriteable().

The strange thing is that I don't have the problem with my version of PHP5, which is 5.1.2. I was damn sure that I tested the class on PHP4 and 5!
So maybe it is a PHP behaviour prior to 5.1.2

In any case, it is not right to define a static function within a class method, so I will change it. Let alone that both functions are used only once.

Can you update your version of PHP?

Which further problems the fix led to when you tried it?Reply