gpt4 book ai didi

php - block 未从数据库中删除

转载 作者:搜寻专家 更新时间:2023-10-31 21:09:50 25 4
gpt4 key购买 nike

情况:我正在为 Concrete 5 Version 5.6.3.1 开发一个包。

问题:

  • 从前端删除一个已经发布的 block 时(像任何用户执行),数据库表中的相应行不会被删除。
  • 在不发布的情况下删除 block 时,它有效。

这是我的 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();
}
}

block 本身运行良好,包也是如此。这根本不是我的第一个包,我也是按照 C5 的推荐开发 block /包。

我开始思考,这是一个错误,但在我在 C5 上发布内容之前,我很想听听其他 C5 开发人员的意见...

在 C5 的论坛上说,重写 Concrete5_Controller_Block_Content 的删除方法会有所帮助。

我还尝试在开始而不是结束时调用 parent::delete();,但没有区别。

更新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();
}
}
}

更新 1

缓存设置打印屏幕

enter image description here

而且,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>

如果您需要任何进一步的信息或代码,请告诉我。我很乐意就此获得一些提示。

更新 2

卸载/安装软件包都无济于事。

更新 3

  • 从前端删除一个已经发布的 block 时(像任何用户执行),数据库表中的相应行不会被删除并且没有 delete() 方法被触发,无论是我的还是 parent 的

最佳答案

最后,我从 C5 团队的开发人员那里得到了答案:

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.

对于其他 C5 开发人员:

转到仪表板 > 系统和设置 > 自动化作业(在“优化”下)并运行作业:

“删除旧页面版本”

child (或 parent )的删除方法正在触发。该 block 被删除。

感谢Andrew Embler来自 C5 团队!

关于php - block 未从数据库中删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22928895/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com