Priority: Normal
Current State: Closed
Released In: 2.1.8
Target Release: patch
Applies To: Engine
Component:
Branches: Release02x01 master
A topic is copied using this code:
my $meta = Foswiki::Meta->load($session, $sourceWeb, $sourceTopic);
$meta->save(
web => $targetWeb,
topic => $targetTopic
);
When saving the new object is created at the target location. However, this is done in Foswiki::Meta::saveAs().
This is too late as any
beforeSaveHandler
will still be using the
$sourceWeb.$sourceTopic
. What happens is:
- Foswiki::Meta::load(): new meta is created based on the source
- Foswiki::Meta::save(): is called with target parameters (see above code)
- any
beforeSaveHandler
is dispatched using the source object
- afterwards Foswiki::Meta::saveAs() is called
- the meta object's new target location is set
- the meta object is delegated to the store layer
- any
afterSaveHandler
is displatched using the new target object
The error happens in (3): the new target location should already be set there: the object about to be saved is
not the source but the target one.
--
MichaelDaum - 24 May 2022