Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move BAD_DOI_ARRAY constant to global space #4729

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions constants/bad_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -13040,3 +13040,13 @@
'10.7759/cureus.',
'10.7766/',
];

const BAD_DOI_ARRAY = [
'10.1126/science' => true,
'' => true,
'10.7556/jaoa' => true,
'10.1267/science.040579197' => true,
'10.0000/Rubbish_bot_failure_test' => true,
'10.0000/Rubbish_bot_failure_test2' => true,
'10.0000/Rubbish_bot_failure_test.x' => true,
];
13 changes: 2 additions & 11 deletions expandFns.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ final class HandleCache {
// Greatly speed-up by having one array of each kind and only look for hash keys, not values
private const MAX_CACHE_SIZE = 100000;
public const MAX_HDL_SIZE = 1024;
private const BAD_DOI_ARRAY = [
'10.1126/science' => true,
'' => true,
'10.7556/jaoa' => true,
'10.1267/science.040579197' => true,
'10.0000/Rubbish_bot_failure_test' => true,
'10.0000/Rubbish_bot_failure_test2' => true,
'10.0000/Rubbish_bot_failure_test.x' => true,
];

/** @var array<bool> $cache_active */
public static array $cache_active = []; // DOI is in CrossRef and works
Expand All @@ -29,7 +20,7 @@ final class HandleCache {
/** @var array<string> $cache_hdl_loc */
public static array $cache_hdl_loc = []; // Final HDL location URL
/** @var array<bool> $cache_hdl_bad */
public static array $cache_hdl_bad = self::BAD_DOI_ARRAY; // HDL/DOI does not resolve to anything
public static array $cache_hdl_bad = BAD_DOI_ARRAY; // HDL/DOI does not resolve to anything
/** @var array<bool> $cache_hdl_null */
public static array $cache_hdl_null = []; // HDL/DOI resolves to null

Expand All @@ -49,7 +40,7 @@ public static function free_memory(): void {
self::$cache_inactive = [];
self::$cache_good = [];
self::$cache_hdl_loc = [];
self::$cache_hdl_bad = self::BAD_DOI_ARRAY;
self::$cache_hdl_bad = BAD_DOI_ARRAY;
self::$cache_hdl_null = [];
gc_collect_cycles();
}
Expand Down
Loading