[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /lonnet/perl lonnet.pm
raeburn
raeburn at source.lon-capa.org
Tue Oct 6 14:46:52 EDT 2020
raeburn Tue Oct 6 18:46:52 2020 EDT
Modified files: (Branch: version_2_11_X)
/loncom/lonnet/perl lonnet.pm
Log:
- For 2.11
Backport 1.1427
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1172.2.127 loncom/lonnet/perl/lonnet.pm:1.1172.2.128
--- loncom/lonnet/perl/lonnet.pm:1.1172.2.127 Thu Oct 1 10:24:06 2020
+++ loncom/lonnet/perl/lonnet.pm Tue Oct 6 18:46:51 2020
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1172.2.127 2020/10/01 10:24:06 raeburn Exp $
+# $Id: lonnet.pm,v 1.1172.2.128 2020/10/06 18:46:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -8390,32 +8390,24 @@
my $cacheduser='';
# Course for which data are being temporarily cached.
my $cachedcid='';
-# List of blocks passed to &get_commblock_resources();
-my $cachedblocks='';
# Cached blockers for this user (a hash of blocking items).
my %cachedblockers=();
# When the data were last cached.
my $cachedlast='';
sub load_all_blockers {
- my ($uname,$udom,$blocks)=@_;
+ my ($uname,$udom)=@_;
if (($uname ne '') && ($udom ne '')) {
if (($cacheduser eq $uname.':'.$udom) &&
($cachedcid eq $env{'request.course.id'}) &&
- (abs($cachedlast-time)<5) &&
- (((ref($blocks) eq 'HASH') &&
- ($cachedblocks eq join(',',sort(keys(%{$blocks}))))) ||
- (!ref($blocks) && $cachedblocks eq ''))) {
+ (abs($cachedlast-time)<5)) {
return;
}
}
$cachedlast=time;
$cacheduser=$uname.':'.$udom;
$cachedcid=$env{'request.course.id'};
- %cachedblockers = &get_commblock_resources($blocks);
- if ((ref($blocks) eq 'HASH') && (keys(%{$blocks}) > 0)) {
- $cachedblocks = join(',',sort(keys(%{$blocks})));
- }
+ %cachedblockers = &get_commblock_resources();
return;
}
@@ -8553,17 +8545,23 @@
}
sub has_comm_blocking {
- my ($priv,$symb,$uri,$nosymbcache,$noenccheck,$blocked,$blocks) = @_;
+ my ($priv,$symb,$uri,$ignoresymbdb,$noenccheck,$blocked,$blocks) = @_;
my @blockers;
return unless ($env{'request.course.id'});
return unless ($priv eq 'bre');
return if ($env{'user.priv.'.$env{'request.role'}} =~/evb\&([^\:]*)/);
return if ($env{'request.state'} eq 'construct');
- &load_all_blockers($env{'user.name'},$env{'user.domain'},$blocks);
- return unless (keys(%cachedblockers) > 0);
+ my %blockinfo;
+ if (ref($blocks) eq 'HASH') {
+ %blockinfo = &get_commblock_resources($blocks);
+ } else {
+ &load_all_blockers($env{'user.name'},$env{'user.domain'});
+ %blockinfo = %cachedblockers;
+ }
+ return unless (keys(%blockinfo) > 0);
my (%possibles, at symbs);
if (!$symb) {
- $symb = &symbread($uri,1,1,1,\%possibles,$nosymbcache,$noenccheck);
+ $symb = &symbread($uri,1,1,1,\%possibles,$ignoresymbdb,$noenccheck);
}
if ($symb) {
@symbs = ($symb);
@@ -8574,7 +8572,7 @@
foreach my $symb (@symbs) {
last if ($noblock);
my ($map,$resid,$resurl)=&decode_symb($symb);
- foreach my $block (keys(%cachedblockers)) {
+ foreach my $block (keys(%blockinfo)) {
if ($block =~ /^firstaccess____(.+)$/) {
my $item = $1;
unless ($blocked) {
@@ -8584,16 +8582,16 @@
}
}
}
- if (ref($cachedblockers{$block}) eq 'HASH') {
- if (ref($cachedblockers{$block}{'resources'}) eq 'HASH') {
- if ($cachedblockers{$block}{'resources'}{$symb}) {
+ if (ref($blockinfo{$block}) eq 'HASH') {
+ if (ref($blockinfo{$block}{'resources'}) eq 'HASH') {
+ if ($blockinfo{$block}{'resources'}{$symb}) {
unless (grep(/^\Q$block\E$/, at blockers)) {
push(@blockers,$block);
}
}
}
- if (ref($cachedblockers{$block}{'maps'}) eq 'HASH') {
- if ($cachedblockers{$block}{'maps'}{$map}) {
+ if (ref($blockinfo{$block}{'maps'}) eq 'HASH') {
+ if ($blockinfo{$block}{'maps'}{$map}) {
unless (grep(/^\Q$block\E$/, at blockers)) {
push(@blockers,$block);
}
@@ -12445,9 +12443,9 @@
sub symbread {
my ($thisfn,$donotrecurse,$ignorecachednull,$checkforblock,$possibles,
- $nocache,$noenccheck)=@_;
+ $ignoresymbdb,$noenccheck)=@_;
my $cache_str='request.symbread.cached.'.$thisfn;
- if (defined($env{$cache_str}) && !$nocache) {
+ if (defined($env{$cache_str})) {
unless (ref($possibles) eq 'HASH') {
if ($ignorecachednull) {
return $env{$cache_str} unless ($env{$cache_str} eq '');
@@ -12459,11 +12457,7 @@
# no filename provided? try from environment
unless ($thisfn) {
if ($env{'request.symb'}) {
- if ($nocache) {
- return &symbclean($env{'request.symb'});
- } else {
- return $env{$cache_str}=&symbclean($env{'request.symb'});
- }
+ return $env{$cache_str}=&symbclean($env{'request.symb'});
}
$thisfn=$env{'request.filename'};
}
@@ -12471,11 +12465,7 @@
# is that filename actually a symb? Verify, clean, and return
if ($thisfn=~/\_\_\_\d+\_\_\_(.*)$/) {
if (&symbverify($thisfn,$1)) {
- if ($nocache) {
- return &symbclean($thisfn);
- } else {
- return $env{$cache_str}=&symbclean($thisfn);
- }
+ return $env{$cache_str}=&symbclean($thisfn);
}
}
$thisfn=declutter($thisfn);
@@ -12490,14 +12480,14 @@
if ($targetfn =~ m|^adm/wrapper/(ext/.*)|) {
$targetfn=$1;
}
- unless ($nocache) {
+ unless ($ignoresymbdb) {
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
&GDBM_READER(),0640)) {
$syval=$hash{$targetfn};
untie(%hash);
}
- if ($syval) {
- my @blockers = &has_comm_blocking('bre',$syval,$thisfn,$nocache,$noenccheck);
+ if ($syval && $checkforblock) {
+ my @blockers = &has_comm_blocking('bre',$syval,$thisfn,$ignoresymbdb,$noenccheck);
if (@blockers) {
$syval='';
}
@@ -12544,7 +12534,6 @@
if (@blockers) {
$syval = '';
untie(%bighash);
- return '' if ($nocache);
return $env{$cache_str}='';
}
}
@@ -12596,15 +12585,10 @@
}
}
if ($syval) {
- if ($nocache) {
- return $syval;
- } else {
- return $env{$cache_str}=$syval;
- }
+ return $env{$cache_str}=$syval;
}
}
&appenv({'request.ambiguous' => $thisfn});
- return '' if ($nocache);
return $env{$cache_str}='';
}
More information about the LON-CAPA-cvs
mailing list