Call to a member function getUrl() on a non-object (1)

Hello Everyone,

We are trying to work with a client right now and update their website a little bit. The site runs version 5.7.2 of Concrete5 and while trying to update something on the page we ran into this error.


Exception Occurred: html/packages/ct_red_five_seven/blocks/extended_caption/view.php:5 Call to a member function getUrl() on a non-object (1)

On Line 5 is this code

$c = Page::getCurrentPage();
$f = File::getByID($fID);
$fullPath = $f->getUrl();  <-- Line 5
$relPath = $f->getRelativePath();

Does anyone have any ideas?

View Replies:
hutman replied on at Permalink Reply
Whichever file you're trying to access with $fID doesn't exist. So the $f is null.
TheRealSean replied on at Permalink Reply
Chuck in a check to make sure $f is set

if($f) {
clagrange replied on at Permalink Reply

Thanks for the suggestion, so this is what happens when I do that.

The error on the page edit screen turns into "File not found"

And the error in the logs is

"Exception Occurred: html/updates/concrete5.7.4.2_remote_updater/concrete/vendor/imagine/imagine/lib/Imagine/Image/AbstractImagine.php:67 File does not exist. (0)"

I understand that it's missing something, I just don't know what it is missing.

protected function checkPath($path)
        // provide compatibility with objects such as \SplFileInfo
        if (is_object($path) && method_exists($path, '__toString')) {
            $path = (string) $path;
        $handle = @fopen($path, 'r');
        if (false === $handle) {
            throw new InvalidArgumentException(sprintf('File %s does not exist.', $path)); <-- line 67
        return $path;