You are here: Foswiki>Tasks Web>Item15136 (24 May 2022, MichaelDaum)Edit Attach

Item15136: Foswiki::Meta::save() sets topic and web too late when copying a topic

pencil
Priority: Normal
Current State: Waiting for Release
Released In: 2.1.8
Target Release: patch
Applies To: Engine
Component:
Branches: Release02x01 master
Reported By: MichaelDaum
Waiting For:
Last Change By: MichaelDaum
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:

  1. Foswiki::Meta::load(): new meta is created based on the source
  2. Foswiki::Meta::save(): is called with target parameters (see above code)
  3. any beforeSaveHandler is dispatched using the source object
  4. afterwards Foswiki::Meta::saveAs() is called
  5. the meta object's new target location is set
  6. the meta object is delegated to the store layer
  7. 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

 

ItemTemplate edit

Summary Foswiki::Meta::save() sets topic and web too late when copying a topic
ReportedBy MichaelDaum
Codebase
SVN Range
AppliesTo Engine
Component
Priority Normal
CurrentState Waiting for Release
WaitingFor
Checkins distro:5422da086417 distro:d8de32118e9e
TargetRelease patch
ReleasedIn 2.1.8
CheckinsOnBranches Release02x01 master
trunkCheckins
masterCheckins distro:d8de32118e9e
ItemBranchCheckins
Release02x01Checkins distro:5422da086417
Release02x00Checkins
Release01x01Checkins
Topic revision: r1 - 24 May 2022, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy