]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1301383 - Memoize does not work under threaded perl in windows: "Anonymous functi...
authorDylan William Hardison <dylan@hardison.net>
Fri, 23 Dec 2016 01:35:20 +0000 (20:35 -0500)
committerDylan William Hardison <dylan@hardison.net>
Mon, 20 Feb 2017 22:22:01 +0000 (17:22 -0500)
Bugzilla/Constants.pm

index 2e3f339a75ed32fe8ca8456221769ab7993cfc18..7a48995da170aa568bc1f61603b84fa12a6b5a0b 100644 (file)
@@ -15,7 +15,6 @@ use parent qw(Exporter);
 
 # For bz_locations
 use File::Basename;
-use Memoize;
 
 @Bugzilla::Constants::EXPORT = qw(
     BUGZILLA_VERSION
@@ -641,9 +640,13 @@ use constant EMAIL_LIMIT_EXCEPTION  => "email_limit_exceeded\n";
 use constant JOB_QUEUE_VIEW_MAX_JOBS => 500;
 
 sub bz_locations {
-    # Force memoize() to re-compute data per project, to avoid
+    # Force $memoize to re-compute data per project, to avoid
     # sharing the same data across different installations.
-    return _bz_locations($ENV{'PROJECT'});
+    state $memoize = {};
+    my $project = $ENV{PROJECT};
+    my $key = $project // '__DEFAULT';
+
+    return $memoize->{$key} //= _bz_locations($project);
 }
 
 sub _bz_locations {
@@ -704,10 +707,6 @@ sub _bz_locations {
     };
 }
 
-# This makes us not re-compute all the bz_locations data every time it's
-# called.
-BEGIN { memoize('_bz_locations') };
-
 1;
 
 =head1 B<Methods in need of POD>