Are you willing to create (at a later stage) a PR for that?
No
iTop version
3.2.2-1
Module/extension version
1.4.6
PHP version
8.3.6
Reproduction procedure
Bug: clone_attachments assignes an attachment to a wrong object
Summary
We are using the Object Copier to convert a UserRequest into an Incident.
There is a bug when the source UserRequest contains both:
- related_request_list
- attachments
In this case, the attachments are not attached to the newly created Incident. Instead, they are incorrectly attached to the first of the related requests.
If the same conversion is performed with a UserRequest that has attachments but no related requests, the attachments are copied correctly to the new Incident.
Steps to reproduce
- Add object-copier rule to config
'incident_from_userrequest' =>
array (
'source_scope' => 'SELECT UserRequest WHERE status NOT IN (\'closed\',\'resolved\')',
'allowed_profiles' => 'Administrator',
'menu_label' => 'Transfrom UserRequest into Incident...',
'menu_tooltip' => 'This UserRequest will be closed and a new Incident created.',
'form_label' => 'Create an incident from UserRequest: %1$s',
'report_label' => 'Incident created from UserRequest: %1$s',
'dest_class' => 'Incident',
'preset' =>
array (
1 => 'clone(org_id,caller_id,origin,description,impact,urgency)',
2 => 'set(private_log,Incident was transformed from "$this->hyperlink()$")',
3 => 'copy(related_request_list, related_request_list)',
4 => 'clone_attachments()',
),
'retrofit' =>
array (
),
),
- Create a new UserRequest. Add at least one related request and at least one attachment to the same UserRequest.
- Start the conversion from the menu using the Object Copier action.
- Fill in the required fields and create the new Incident.
- Check the related Request tab of the new incident.
Result: The related requests are shown correctly.
- Check the Attachments tab of the new Incident.
Result: The Attachments tab is empty.
- Open the related request.
Result: The attachment was incorrectly attached to the related request.
- Check the database entry for the attachment.
Result: The attachment is linked to the related request instead of the new Incident.
Additional information (if needed)
No response
Are you willing to create (at a later stage) a PR for that?
No
iTop version
3.2.2-1
Module/extension version
1.4.6
PHP version
8.3.6
Reproduction procedure
Bug: clone_attachments assignes an attachment to a wrong object
Summary
We are using the Object Copier to convert a UserRequest into an Incident.
There is a bug when the source UserRequest contains both:
In this case, the attachments are not attached to the newly created Incident. Instead, they are incorrectly attached to the first of the related requests.
If the same conversion is performed with a UserRequest that has attachments but no related requests, the attachments are copied correctly to the new Incident.
Steps to reproduce
Result: The related requests are shown correctly.
Result: The Attachments tab is empty.
Result: The attachment was incorrectly attached to the related request.
Result: The attachment is linked to the related request instead of the new Incident.
Additional information (if needed)
No response