New to ConcreteCMS. Have a tiny issue...error

Installed Concrete 9 just fine. On Windows 8.1 Wampserver64 3.2.9, Apache 2.4.51, MySQL 8.0.27, PHP 7.4.26.
Everything was going GREAT! Blows Wordpress away! IMO. All due respect.
Added some files…images to Gallery folder manually. The theme is Atomik latest I guess. Concrete CMS is 9.1.1.
All a sudden I go to view the main page…first…index…whatever… I get THIS:

    // Stop outputting
<div id="ccm-block-gallery-<?=$bID?>">
    <div class="ccm-block-gallery">
        <div class="row gx-0">
            /** @var File $image */
            foreach ($images as $image) {
                $tag = (new Image($image['file']))->getTag();
                $size = $image['displayChoices']['size']['value'] ?? null;
                $caption = $image['displayChoices']['caption']['value'] ?? null;
                $hoverCaption = $image['displayChoices']['hover_caption']['value'] ?? null;
                $downloadLink = null;
                $fileVersion = $image['file']->getApprovedVersion();
                if ($includeDownloadLink && $fileVersion instanceof Version) {
                    $downloadLink = $fileVersion->getForceDownloadURL();
                <a class="col-md-<?php echo $size === 'wide' ? '8' : '4' ?> col-<?php echo $size === 'wide' ? '12' : '6' ?>"
                   href="<?php echo h($image['file']->getThumbnailUrl(null)) ?>" data-gallery-lightbox="true"
                   data-download-link="<?php echo h($downloadLink); ?>">
                    <div class="ccm-block-gallery-image"><?php echo $tag ?></div>
                    <div class="ccm-block-gallery-image-overlay">
                        <div class="ccm-block-gallery-image-overlay-color"></div>
                        <div class="ccm-block-gallery-image-overlay-text"><?=h($hoverCaption)?></div>


  1. “Call to a member function getApprovedVersion() on null”

I have tried emptying cache. Rescan files. Change theme to Elemental…nothing. Still getting that ERROR on first page. The rest of the pages work. Changed back to Atomik. Downloaded a new view.php file. Compared them…exactly the same. So it isn’t the view.php file.
One thing I did that quite possibly broke that page. I deleted the several image files that were already in Gallery folder via Dashboard. However…I downloaded atomik from github and put those files back. Still ERROR on main first page. PLEASE help and advise.
Thank you.

Looking at the Retrieving File Objects Programmatically etc… I can pretty much figure what I did was…when deleting those image files…had no idea they were versioned. My bad. I guess. So I am speculating that the code is looking for the getApprovedVersion and there just ain’t one there. NOW. Is there anyway possible to reset the approval…or something to that affect? Please help and advise. Thanks MUCH. Peace out…

There are likely a couple of things going on:

  • As you surmised, you removed some files that were being used
  • The gallery block should have code that protects against such issues (and does not), so a bug in the gallery block.

How to recover.
I am guessing the block was there with the sample content. So the usual approach of going to the sitemap and back in the page version can’t be done because there is no version without that block.

Adding the images back to the file manager will not fix it. They will now have a different ID.

If you can handle a little bit of php. you can temporarily comment out those lines of the block view.php. That will enable you to navigate to the page, get it into edit mode, and use the edit dialogue to delete the block.

Then remove the commenting and add a new gallery with the files you want.

If you want to be a bit more advanced, you could add a test before the erroring line


That will skip the missing files from the display and is also the kind of fix that could be made on GitHub for a more permanent solution.

Thanks much. Yes…I like dabbling with code. Especially if I can make it work. NOT break it. lol
Tried to comment out line 38 and put this code before it…$version = $file->getVersionToModify(true); //forces the retrieval of a new version
No go. But yes thank you again.

I should have been clearer. If adding the condition, don’t comment out or remove anything. Just insert the condition. It will make sure you have an object before trying to get its version.
(There will be other files that it loops through that still exists and need that version code.)

I am modifying the theme as it is and don’t think I even need that particular block (section). Makes complete sense now that you’ve advised on my “mess up”.
I do believe that will solve this for me. Thank you kindly once again Sir. Much appreciated.

OK. Cool…Thanks again for your time man. I have been fighting Wordpress. Used to love it. Ain’t no spring chicken and need a CMS that I can enjoy and work with. Concrete…even after I broke it…seems perfect for what I need. I understand it better. Thank you.

Oh no no… You were very clear. Thank you. I tried that before you replied. I was just gonna break it some more on my own. LOL… Thanks man.

johnthefish… It worked. Fixed it with the code you said to use. Pasted it in…refreshed the page. Done. Greatly appreciated my friend. Thank you. MUCH.
Sincerely, David