You are here: Foswiki>Tasks Web>Item13568 (03 Aug 2015, GeorgeClark)Edit Attach

Item13568: tools/bulk_copy.pl: removes topic data prior to saving new revision; breaks attachments and history

pencil
Priority: Urgent
Current State: Closed
Released In: 2.0.1
Target Release: patch
Applies To: Engine
Component: FoswikiTools
Branches: master Item13525
Reported By: JanKrueger
Waiting For:
Last Change By: GeorgeClark
bulk_copy.pl iterates over topic revisions and performs a save for each revision. When doing that, it checks whether the topic already exists in the target instance (which it does after the first revision has been saved there) -- if so, it is deleted, including all attachments. Code in question, from saveTopicRev, included since the first committed revision of bulk_copy.pl:

[...]
    # When saving over existing revs of a topic, must make sure we
    # fully delete the existing data
    if ( $session->topicExists( $web, $topic ) ) {
        my $demo = Foswiki::Meta->new( $session, $web, $topic );
        $demo->removeFromStore();
[...]

Let's assume you have a topic with the following history:

  • Revision 1: text, uploaded an attachment
  • Revision 2: changed text, did not touch attachment

So, this saves revision 1, then deletes the topic before saving revision 2. The result is a topic with one revision (equivalent to revision 2 in the origin instance) and no attachment data (because revision 2 did not include any new revisions of an attachment).

I'm not entirely sure the delete needs to be in there at all -- after all, bulk_copy.pl skips existing topics no matter what.

-- JanKrueger - 28 Jul 2015

Yes, the situation i was trying to avoid is where Topic revs 1..3 are saved over Topic where it already has revs 1..3 from a previous copy, as the new revs would then be 4..6 instead.

Your patch looks correct to me. Go ahead.

-- Main.CrawfordCurrie - 30 Jul 2015 - 14:12

 

ItemTemplate edit

Summary tools/bulk_copy.pl: removes topic data prior to saving new revision; breaks attachments and history
ReportedBy JanKrueger
Codebase 2.0.0
SVN Range
AppliesTo Engine
Component FoswikiTools
Priority Urgent
CurrentState Closed
WaitingFor
Checkins distro:a8b56f70bbb2
TargetRelease patch
ReleasedIn 2.0.1
CheckinsOnBranches master Item13525
trunkCheckins
masterCheckins distro:a8b56f70bbb2
ItemBranchCheckins distro:a8b56f70bbb2
Release01x01Checkins
Topic revision: r5 - 03 Aug 2015, GeorgeClark
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