Hi all,
I'd like to report a bug in ResourceSpace 10.7 related to the 'Save all with
locked values' functionality when used in “Upload first, then set metadata”
mode. I have deployed a clean installation of ResourceSpace 10.7 through
Docker.
When using 'Save all with locked values', all locked fields are copied into all
resources but license. If I use the option “save and next” it works properly.
I have been trying to solve it with the help of Claude and this is the report that Claude has emit:
The `copy_locked_data_extra` hook is not
called inside the `save_auto_next` loop in `pages/edit.php`. This means that
plugins relying on this hook to persist their own locked field data will only
save correctly for the first resource, not for the subsequent ones in the
batch.
In `pages/edit.php`, the `save_auto_next` loop calls `copy_locked_data()` and
`copy_locked_fields()` for each subsequent resource, but it does not call the
`copy_locked_data_extra` hook. This hook is only called once, outside the loop,
when the page first loads.
By contrast, at page load time the hook is called correctly:
```php
$hookresource = hook('copy_locked_data_extra', '', [$resource, $locked_fields,
$lastedited], true);
```
But inside the `save_auto_next` loop, the equivalent call is missing.
Claude Proposed fix:
In `pages/edit.php`, inside the `save_auto_next` loop, add the following lines
immediately after the call to `copy_locked_data()`:
```php
// Allow plugins to persist their own locked fields during Save all with locked
values
$hookresource = hook('copy_locked_data_extra', '', [$resource, $locked_fields,
$lastedited, true], true);
if ($hookresource !== false && is_array($hookresource)) {
$resource = $hookresource;
}
```
Note the fourth argument `true` signals to the hook that it should persist data
(i.e. `$save = true`), consistent with how the other functions in the loop are
called.
On the plugin side, `HookLicensemanagerEditCopy_locked_data_extra` in the
License Manager plugin would also need to be updated to accept and act on this
fourth `$save` parameter.
Thanks for the great
work on 10.7!
Best regards