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

Permalink
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.

v5.7.2

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?

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

if($f) {
   $f->getUrl();
}
clagrange replied on at Permalink Reply
Hey,

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
        }
        fclose($handle);
        return $path;
    }
}

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.