Situation: I'm developing a package for Concrete 5 Version 5.6.3.1.
The problem:
Here's my controller
class PcShooterChShowSomeThingsBlockController extends Concrete5_Controller_Block_Content {
protected $btName = "Show Some Things";
protected $btTable = 'btPcShooterChShowSomeThings';
protected $btInterfaceWidth = 500;
protected $btInterfaceHeight = 400;
protected $btWrapperClass = 'ccm-ui';
//...
public $pkgHandle = 'pc_shooter_ch_show_some_things';
//...
/**
* --------------- Overrides ----------------------
*/
public function delete() {
$db = Loader::db();
//Log::addEntry('DELETE FROM ' . $this->btTable . ' WHERE bID = ' . $this->bID);
$db->Execute('DELETE FROM ' . $this->btTable . ' WHERE bID = ' . $this->bID);
parent::delete();
}
}
The block itself works well, the package too. It isn't My first package at all, also I develop block/packages as recommended by C5.
I start thinking, its a bug, but before I post something on C5, I'm interested to hear from other C5 developers...
In the forum of C5 it says, that overriding the Concrete5_Controller_Block_Content
's delete-method helps.
Also I tried to call the parent::delete();
at the beginnig instead of the end, but no difference.
UPDATE
The parents delete method from the Concrete5_Library_BlockController
:
/**
* Automatically run when a block is deleted. This removes the special data
* from the block's specific database table. If a block needs to do more
* than this this method should be overridden.
* @return $void
*/
public function delete() {
if ($this->bID > 0) {
if ($this->btTable) {
$ni = new BlockRecord($this->btTable);
$ni->bID = $this->bID;
$ni->Load('bID=' . $this->bID);
$ni->delete();
}
}
}
UPDATE 1
Cache settings print screen
And, maybe it helps, the db.xml
<?xml version="1.0"?>
<schema version="0.3">
<table name="btPcShooterChShowSomeThings">
<field name="bID" type="I">
<key />
<unsigned />
</field>
<field name="desc_true" type="I2">
</field>
<field name="block_css_style" type="C" size="255">
</field>
<field name="block_css_id" type="C" size="255">
</field>
<field name="block_css_class" type="C" size="255">
</field>
<field name="title_css_class" type="C" size="255">
</field>
<field name="desc_css_class" type="C" size="255">
</field>
</table>
</schema>
If you need any further infos or code, just tell me. I'd be glad to get some tips on this.
UPDATE 2
A uninstall/install of the package does not help neither.
UPDATE 3
So finally, I've got an answer from a developer of the C5-team:
Not a bug. Blocks still store their data so that they can be reinstated in case a previous version of a page gets approved and rolled back to. Block's will only call BlockController::delete() when they no longer need to keep their data around.
For other C5 developers:
Go to Dashboard > System & Settings > Automated Jobs (under "Optimization") and run the job:
"Remove Old Page Versions"
The child's (or parent's) delete method is firing. The block is deleted.
Thx to Andrew Embler from the C5-Team!