New Foswiki release 2.1.6 is available with important security fixes.
Sourceforge foswiki email lists being discontinued. Subscribe to the new Foswiki announce and discuss lists at MailingLists
You are here: Foswiki>Tasks Web>Item10219 (06 Mar 2018, GeorgeClark)Edit Attach

Item10219: AUTOINC cannot be used when creating a topic programmatically

Priority: Enhancement
Current State: Needs Merge
Released In: 2.2.0
Target Release: minor
Applies To: Engine
Component: FoswikiMeta
Branches: Item14563 master
Reported By: ArthurClemens
Waiting For:
Last Change By: GeorgeClark
AUTOINC is resolved in Foswiki::UI::Save, but not in Meta. So when you want to create a topic using Foswiki::Func::saveTopic, AUTOINC will not be resolved.

This code should be implemented in Meta.

-- ArthurClemens - 02 Jan 2011

This also applies to the edit script; POSTing to an edit script with a topic named with AUTOINC0 will not expand properly (it literally creates, Eg. TestTopicAUTOINC0 instead of TestTopic1234).

-- PaulAlexander - 02 Mar 2012

should implement this for 1.2.0 -
  1. move the AUTOINC processing to Meta,
  2. fix the corner case Paul found - I've seen a few instances where we have non-expanded AUTOINC's saved too

-- SvenDowideit - 08 Mar 2012

It would be great to fix this so it works for all saves.

Now for edit scripts, I see a risk in making this possible. Isn't this function deliberately left in save? IIRC the number is generated simply by globbing the topics in the directory that match the AUTOINC pattern, then find the last entry, add one to the number found and create a new topic name. This ensures at save-time a unique new topic name which is actually used.

If moved to edit (to handles Paul's case), does that not mean the generated topic name will not necessarily be saved. More importantly, an edit screen can be open for some time, other users could initiate a new topic in a similar manner and be given the same topic name to create. I suppose the globbing could include picking up leases as well as txt files to prevent this. OTOH this would potentially create gaps in the sequence if the user cancels the edit session, which may not be desirable.

-- JulianLevens - 08 Mar 2012

Good point. I thought making AUTOINC consider lease files would be enough, but perhaps we should encourage people to post to save first, then redirectto the edit screen.

On the other hand... allowing the save method to stomp on topic with an active lease could be considered a bug.

If users really care about contiguous numbering, they should be use the save + redirectto -> edit; those who don't care, could simply go straight to an AUTOINC edit. Are there any holes in that?

-- PaulHarvey - 08 Mar 2012

No that covers it, as long as the user understands the options they have available. It's their party or funeral.

-- JulianLevens - 08 Mar 2012

Defer to 2.0.

-- GeorgeClark - 02 Jun 2014

Will be fixed in Foswiki 2.2.

-- GeorgeClark - 21 Feb 2018

ItemTemplate edit

Summary AUTOINC cannot be used when creating a topic programmatically
ReportedBy ArthurClemens
Codebase 2.1.5, 2.0.0, 1.1.9, 1.1.8, 1.1.7, 1.1.6, 1.1.5, 1.1.4, 1.1.4 RC2, 1.1.4 RC1, 1.1.4 beta2, 1.1.4 beta1, 1.1.3, 1.1.3 RC1, 1.1.3 beta1, 1.1.2, trunk
SVN Range
AppliesTo Engine
Component FoswikiMeta
Priority Enhancement
CurrentState Needs Merge
Checkins distro:382a43561773
TargetRelease minor
ReleasedIn 2.2.0
CheckinsOnBranches Item14563 master
masterCheckins distro:382a43561773
ItemBranchCheckins distro:382a43561773
Topic revision: r11 - 06 Mar 2018, GeorgeClark - This page was cached on 22 Mar 2018 - 13:14.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License