Description
What happened?
Description
When updating an asset via GraphQL the EVENT_AFTER_REPLACE_ASSET is not triggered.
Steps to reproduce
-
Upload an asset to Craft
-
Create a module with the EVENT_AFTER_REPLACE_ASSET and just throw an Error
Event::on( Assets::class, Assets::EVENT_AFTER_REPLACE_ASSET, function (ReplaceAssetEvent $event) { throw new Error('Some Errormsg'); } );
-
Create a mutation with payload that replaces the Asset
mutation AssetMutation( $id: ID, $folderId: ID, $document: FileInput, $title: String, ) { save_images_Asset( _file: $document, title: $title, id: $id newFolderId: $folderId ) { id folderId title } }
Payload is the output of the following php fun
public function assetPayload(string $fileData, array $image): String { $payload = [ 'id' => $image['id'], 'folderId' => $image['folderId'], 'title' => $image['name']', 'document' => [ 'filename' => $image['name'], 'fileData' => "data:image/jpg;base64," . $fileData ], ]; return json_encode($payload); }
-
Replace an Asset via Crafts native backend and observe an error is thrown
-
Run the mutation for the same Asset and see no Error is thrown
Expected behavior
When updating an Asset via GraphQL the EVENT_AFTER_REPLACE_ASSET and EVENT_BEFORE_REPLACE_ASSET are triggered.
Actual behavior
Said events are not triggered.
Craft CMS version
Craft CMS 4.14.11 Pro
PHP version
PHP 8.2.22
Operating system and version
Linux 6.8.0-56-generic
Database type and version
PostgreSQL 12.14
Image driver and version
Imagick 3.7.0 (ImageMagick 6.9.11-60)
Installed plugins and versions
No response