Block::getInstance() fails with Caching (Fixed)

Permalink
Hello everybody

This is my absolute first posting here @ concrete5. I'm not a native english speaker :D so please excuse my misspellings.

I am developing a new Add-On on Concrete 5.4 (i know , there is a cool newer one :) ), which worked pretty well until i activated the caching feature.

Fatal error: Block::getInstance(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "[BLOCKCLASSNAME]" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in [CONCRETEHOME]/concrete/models/block.php on line 328

I uncommented almost all the code. But the Error still occured. I've lost about 2 Weeks (spare time) now on solving this Problem. I almost gave it up.

But now I've found the solution !!

My mistake where the misspelled block folders.

My Block Controller Class definition was :
class MyaddonFeatureBlockController extends BlockController {
...
}

But my folder where named as follow :
myaddon
I--blocks
...I--myaddonfeature
......I--add.php
......I--view.php
......I-- ...

Concrete5's autoload fails with this folder naming.

The correct way to name Folder must be : "myaddon_feature"

Make sure you changed the install routine too : BlockType::installBlockTypeFromPackage('myaddon_feature', $pkg);

And reinstall the new Addon.

I'm just so happy to have this bug fixed! I hope i can help with that someone else. I do not know if this behavior is already documented.

gicara
 
jeffreyrule replied on at Permalink Reply
Thank you! I have been pulling my hair out on why I kept getting the Fatal error message on my custom package. I would clear the site cache and it would work for a second then I would get this error again. I uninstalled my package then I updated the folder name and controller name of the block and re installed and now it works perfectly.