Item10219: AUTOINC cannot be used when creating a topic programmatically
Priority: Enhancement
Current State: Needs Merge
Released In: 2.2.0
Target Release: minor
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 -
- move the AUTOINC processing to Meta,
- 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