• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

An plugin which enables either beforeAttachmentSaveHandler or afterAttachmentSaveHandler triggers a block of code in TWiki::Store::saveAttachment(). This code writes a temp file using $text as an intermediate variable. $text however stores the current topic text and is left empty after this routine, resulting in the deletion of topic text on save.


This can be reproduced using EmptyPlugin by removing DISABLE_ for either *AttachmentSaveHandler.

  1. Save a topic with text.
  2. Attach any file.
  3. Attach is added and text is deleted. (Text should not be deleted)

Known Plugins Affected:

Note: ALL attachments do this even if attachment related functionality is disabled in plugin.


Fix

lib/TWiki/Store.pm line ~863

                open( F, $tmpFile );
                binmode( F );
                # transfer 512KB blocks
                while( my $r = sysread( $opts->{stream}, $text, 0x80000 )) {
                    syswrite( F, $text, $r );
                }
                close( F );

should be

                my $atext; # attachment content block
                open( F, $tmpFile );
                binmode( F );
                # transfer 512KB blocks
                while( my $r = sysread( $opts->{stream}, $atext, 0x80000 )) {
                    syswrite( F, $atext, $r );
                }
                close( F );

lib/TWiki/Store.pm line ~890

                open( F, $tmpFile );
                binmode(F);
                while( read($opts->{stream}, $text, 1024 )) {
                    print F $text;
                }
                close(F);

should be

                my $atext; # attachment content block
                open( F, $tmpFile );
                binmode(F);
                while( read($opts->{stream}, $atext, 1024 )) {
                    print F $atext;
                }
                close(F);

Additional Considerations

Should the afterAttachmentSave portion even exist? The attachment is already saved at this point (possibly by the beforeAttachmentSave code and definately by the attachment code itself).

BatchUploadPlugin would benefit from a veto upload capability in beforeAttachmentSaveHandler as would any other attachment redirection plugin.


Would be so kind as to review this against current code in SVN? A few bugs were fixed already in this part of the code (i.e. Item2097).

Additionally I think it would be a good idea to report the new functionality request for BatchUploadPlugin as a separate item.

Setting this Low / Waiting For Feedback.

-- SP

I am bumping this to urgent Steffen because I have seen a very similar symptom and lost the form contents on quite a few topics both on my Motion TWiki and on the Motorola TWiki and I use RevCommentPlugin both places.

I have had trouble reproducing why so I feel this one could be very important.

I have seen the problems in 4.0.2 + patches.

So please ensure that either problem is solved and discard - OR - problem is there and the the priority is now low please.

KJL

Duplicate of Item2097. Discarding.

CC

ItemTemplate
Summary Plugins which enable *AttachmentSaveHandler delete page text on Attach
ReportedBy TWiki:Main.JadeCravy
Codebase 4.0.1
SVN Range

AppliesTo Engine
Component

Priority Urgent
CurrentState No Action Required
WaitingFor

Checkins

TargetRelease n/a
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2006-05-29 - CrawfordCurrie
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback