Closed mandrasch closed 2 months ago
It's a little odd this is being picked up by Zen logs, but I can't tell if that's the fault of the Timber plugin you're using, Zen, or something else!
Using Timber, can you download the zen log and paste it here? Or, you're welcome to send to support@verbb.io
if you'd rather not publicly share.
Okay, I could track it down - it happens when we use
use craft\commerce\elements\Product;
$element = Product::find()->id(123)->one();
if (!Craft::$app->elements->deleteElement($element)) {
Error | 2024-08-30 08:48:20 | verbb\zen\services\Elements::_onElementAction
Unable to record element action: “Getting unknown property: craft\commerce\elements\Product::promotable” /var/www/html/vendor/yiisoft/yii2/base/Component.php:154 {"memory":8625016}
Refers to https://github.com/verbb/zen/blob/craft-5/src/services/Elements.php#L182
Background info: We create these products programmatically beforehand, so they might not have all properties which they would have if created in the UI (educated guess).
I wasn't aware that Zen keeps track of things - and might impact performance?. Thought Zen is just a simple export/import tool which only runs when I do import/export stuff? 🤔
Aha, now that makes sense why Zen is picking up these sorts of things. So the reason Zen is picking this up is that it listens to the delete/restore event of every element it supports.
As you can see in https://github.com/verbb/zen/blob/craft-5/src/services/Elements.php#L182 we save a record of the element that's been deleted/restored (you can see this in the zen_elements
database table. The reason we do this is so we can record this as a "change" against the element. This is for exporting, where we list all elements that have been "changed" (added, edited, deleted, restored). The added/edited are easy to track through the dateUpdated
column for elements, but for deleted/restore elements - not so much. That's why we have our own tracking mechanism.
In terms of performance, this is pretty minimal, record-only handling, and only triggers when an element is deleted or restored.
Long story short though, it shouldn't be throwing this error. Fixed for the next release. To get this early, run composer require verbb/zen:"dev-craft-5 as 2.0.0"
.
Ah thanks very much for insights!
Mh... we do some heavy lifting for import/exports for test purposes and import > 10'000 entries programmatically via PHP/REST API regularly. I just wanted Zen for exporting some active entries in another channel (~ 500 entries) to another instance (STAGE > LIVE). Currently without the need of a real delete logic.
While I totally understand the technical approach (and challenge behind deletion) and like the idea very much - in our current test project I might feel better with a "Don't track deleted/restored elements" option to be sure that Zen is not interfering. (Or an option to select which elements should be tracked - I know that is adding a lot of complexity.) Had to remove Zen for now from our project unfortunately, hope I have the chance to re-use it in future.
But just as optional feedback, it's not the usual project case I guess.
Much success with Zen, I really love the idea and looked for such a tool for some years now where I can easily take some prepared entries from staging to production! 👏👏👏
That's great to know, and for sure, very happy to add some more options on control to fine-tune this sort of thing. Of course, hindsight is a wonderful thing and didn't really consider this to be too much of a problem at the time, but it's also early days for Zen, as there's plenty of room for growth into the general import/export space like Feed Me.
Appreciate the feedback!
Fixed in 2.0.1, and will be adding more options to control delete/restore element tracking.
Describe the bug
We're running CraftCMS with CraftCommerce and zen, found these error in logs:
It seems to be connected to importing entries via REST API - maybe a queue job triggering this? Couldn't pinpoint it yet and not sure why this in Zen logs after all? 🤔 Thanks!
Steps to reproduce
Not sure yet
Craft CMS version
5.3.5
Plugin version
2.0.0
Multi-site?
No
Additional context
Craft Commerce 5.0.17