[LON-CAPA-cvs] cvs: loncom /interface londocs.pm /lonnet/perl lonnet.pm
raeburn
raeburn at source.lon-capa.org
Thu Oct 23 20:20:15 EDT 2014
raeburn Fri Oct 24 00:20:15 2014 EDT
Modified files:
/loncom/interface londocs.pm
/loncom/lonnet/perl lonnet.pm
Log:
- Bug 6755.
- Additional randomization in unique numeric identifier used for each item
added to the paste buffer.
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.586 loncom/interface/londocs.pm:1.587
--- loncom/interface/londocs.pm:1.586 Wed Oct 15 07:24:43 2014
+++ loncom/interface/londocs.pm Fri Oct 24 00:20:09 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.586 2014/10/15 07:24:43 droeschl Exp $
+# $Id: londocs.pm,v 1.587 2014/10/24 00:20:09 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3826,6 +3826,7 @@
if ($type eq 'paste') {
$prefix = $type;
$namespace = 'courseeditor';
+ $idtype = 'addcode';
} elsif ($type eq 'map') {
$prefix = 'docs';
if ($area eq 'supplemental') {
@@ -3837,9 +3838,8 @@
$prefix = $type;
$namespace = 'templated';
}
- $idtype = 'concat';
my ($suffix,$freedlock,$error) =
- &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num);
+ &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype);
if (!$suffix) {
if ($type eq 'paste') {
$errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1267 loncom/lonnet/perl/lonnet.pm:1.1268
--- loncom/lonnet/perl/lonnet.pm:1.1267 Sat Oct 18 16:49:19 2014
+++ loncom/lonnet/perl/lonnet.pm Fri Oct 24 00:20:15 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1267 2014/10/18 16:49:19 raeburn Exp $
+# $Id: lonnet.pm,v 1.1268 2014/10/24 00:20:15 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -5990,10 +5990,15 @@
my %inuse = &Apache::lonnet::dump('nohist_'.$namespace,$cdom,$cnum,$prefix);
my $id = time;
$newid = $id;
+ if ($idtype eq 'addcode') {
+ $newid .= &sixnum_code();
+ }
my $idtries = 0;
while (exists($inuse{$prefix."\0".$newid}) && $idtries < $maxtries) {
if ($idtype eq 'concat') {
$newid = $id.$idtries;
+ } elsif ($idtype eq 'addcode') {
+ $newid = $newid.&sixnum_code();
} else {
$newid ++;
}
@@ -6010,6 +6015,7 @@
$error = 'error saving new item: '.$putresult;
}
} else {
+ undef($newid);
$error = ('error: no unique suffix available for the new item ');
}
# remove lock
@@ -6022,6 +6028,15 @@
return ($newid,$dellock,$error);
}
+sub sixnum_code {
+ my $code;
+ for (0..6) {
+ $code .= int( rand(9) );
+ }
+ return $code;
+}
+
+
# -------------------------------------------------- portfolio access checking
sub portfolio_access {
More information about the LON-CAPA-cvs
mailing list