cms icon indicating copy to clipboard operation
cms copied to clipboard

[3.x]: Resaving an asset with queue fails to set field data but works when run directly.

Open jamesmacwhite opened this issue 3 years ago • 1 comments

What happened?

Description

I want to resave a bunch of assets to populate a new field called alt added to several image asset volumes.

In order to do this I performed an asset element query in a content migration to obtain the required element IDs and then pass these to the ./craft resave/assets command with some additional paramaters.

When testing locally, I've tested these commands, in this case I've just used a single asset ID.

This doesn't seem to work (it runs successfully but the title is not copied to the alt field

/app $ ./craft resave/assets --element-id=602522 --queue=true --set=alt --to=title --update-search-index=true
Assets queued to be resaved.

This does work when the command is not queued

/app $ ./craft resave/assets --element-id=602522 --set=alt --to=title --update-search-index=true
Resaving 1 asset ...
    - [1/1] Resaving Graham basten (602522) ... done
Done resaving asset.

When having queue set to true the field data on alt is not set, when running directly without the queue set to true the field data is set accordingly.

The queue job successfully completes and returns no error, but the data is not set.

Steps to reproduce

  1. Run craft resave/assets using the properties set to and queue
  2. The field data specified in to is not written to the field defined on the set value but it is if you omit queue

Expected behavior

The data to be saved when run as a queue job

Actual behavior

The data does not get written to the defined field when queued.

Craft CMS version

3.7.55

PHP version

8.0

Operating system and version

Ubuntu 20.04 LTS (WSL2)

Database type and version

MySQL 8

jamesmacwhite avatar Sep 20 '22 20:09 jamesmacwhite

Just to add, I've also updated to 3.7.55 as I realised I was slightly out of date, the behaviour remains the same.

jamesmacwhite avatar Sep 21 '22 07:09 jamesmacwhite

Thanks for reporting that! This is now fixed for the next Craft 3 and 4 releases, via #11975.

brandonkelly avatar Oct 04 '22 10:10 brandonkelly

Craft 3.7.56 and 4.2.6 are out with the fix for this.

brandonkelly avatar Oct 11 '22 16:10 brandonkelly

Awesome, thank you.

jamesmacwhite avatar Oct 11 '22 18:10 jamesmacwhite

Confirmed, the queue job now supports these parameters and works, with passing set, to and touch.

jamesmacwhite avatar Oct 13 '22 16:10 jamesmacwhite