craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.29k stars 638 forks source link

[4.3.1]: Calling unknown method: yii\base\Event::isNew() in "__string_template__c6118c31eace33961ac03c0c79f6f37f1ba1d663341db31408b776760f217fd8" at line 18 #12293

Closed DTesch-Reem closed 11 months ago

DTesch-Reem commented 2 years ago

What happened?

Description

Cannot delete entries because of this error: Calling unknown method: yii\base\Event::isNew() in "__string_template__c6118c31eace33961ac03c0c79f6f37f1ba1d663341db31408b776760f217fd8" at line 18

Changing to production environment seems to fix this.

Steps to reproduce

  1. Delete Entry

Expected behavior

Entry deleted

Actual behavior

Error Calling unknown method: yii\base\Event::isNew() in "__string_template__c6118c31eace33961ac03c0c79f6f37f1ba1d663341db31408b776760f217fd8" at line 18 is thrown.

Craft CMS version

4.3.1

PHP version

8.0.11

Operating system and version

Unix

Database type and version

mysql 8

Image driver and version

No response

Installed plugins and versions

-Embedded Assets embeddedassets spicyweb/craft-embedded-assets 3.1.0 Feed Me feed-me craftcms/feed-me 5.0.4 Incognito Field incognito-field mmikkel/incognito-field 1.3.0 Isolate isolate trendyminds/isolate dev-craft-4 Yes Yes Matrix Field Preview matrix-field-preview weareferal/matrix-field-preview dev-main MatrixMate matrixmate vaersaagod/matrixmate 2.1.1 Redactor redactor craftcms/redactor 3.0.2 Redactor Anchors redactor-anchors utakka/redactor-anchors 1.4.0 Smith smith verbb/smith 2.0.0 Super Table super-table verbb/super-table 3.0.5 Table Maker tablemaker verbb/tablemaker 4.0.3 Typed link field typedlinkfield sebastianlenz/linkfield 2.1.4 Webhooks webhooks craftcms/webhooks 3.0.4

brianjhanson commented 2 years ago

Thanks for reaching out! Is there any more of a stack trace in the logs that might point us in the right direction? Or any chance you have any event handlers registered on a delete event of some kind?

DTesch-Reem commented 2 years ago

Hey, this happens after using my fix from my pull request: https://github.com/craftcms/cms/pull/12296.

brianjhanson commented 2 years ago

I'm having issues replicating, even on my similar branch.

Is there any additional reproduction steps or details you can provide? How are you deleting the entry? Is it via the CP or with something more custom? Is there a stack trace associated? Have you tried running ./craft clear-caches/all?

DTesch-Reem commented 1 year ago

The Issue was because of the Webhook Plugin. I had this line in it: isNew: event.isNew ?? null,

For some reason it worken with the afterSave hook, but afterDelete would throw that error. Sorry for the late reply.

brandonkelly commented 11 months ago

Glad you got it sorted! Element::EVENT_AFTER_DELETE triggers a yii\base\Event, which doesn’t have an $isNew property, so that explains it.