| @@ -10,9 +10,24 @@ | ||
| 10 | 10 | use FluentCart\Framework\Support\Arr; |
| 11 | 11 | |
| 12 | 12 | class CheckoutFieldsSchema |
| 13 | 13 | { |
| 14 | + /** | |
| 15 | + * Per-request memo for getFieldsSettings(). In production every HTTP | |
| 16 | + * request runs in a fresh PHP process, so this lives exactly one request. | |
| 17 | + * Long-running processes that simulate multiple requests (test suites, | |
| 18 | + * CLI) must clear it between simulated requests via | |
| 19 | + * resetFieldsCache() — as a function-static it was | |
| 20 | + * unreachable and leaked the first request's field settings into every | |
| 21 | + * subsequent one. | |
| 22 | + */ | |
| 23 | + private static $fieldsCache = null; | |
| 14 | 24 | |
| 25 | + public static function resetFieldsCache(): void | |
| 26 | + { | |
| 27 | + self::$fieldsCache = null; | |
| 28 | + } | |
| 29 | + | |
| 15 | 30 | public static function titleMap(): array |
| 16 | 31 | { |
| 17 | 32 | return [ |
| 18 | 33 | 'full_name' => __('Name', 'fluent-cart'), |
| @@ -588,11 +603,10 @@ | ||
| 588 | 603 | } |
| 589 | 604 | |
| 590 | 605 | public static function getFieldsSettings() |
| 591 | 606 | { |
| 592 | - static $cached = null; | |
| 593 | - if ($cached !== null) { | |
| 594 | - return $cached; | |
| 607 | + if (self::$fieldsCache !== null) { | |
| 608 | + return self::$fieldsCache; | |
| 595 | 609 | } |
| 596 | 610 | |
| 597 | 611 | $defaults = [ |
| 598 | 612 | 'basic_info' => [ |
| @@ -735,9 +749,9 @@ | ||
| 735 | 749 | |
| 736 | 750 | $defaults[$key] = wp_parse_args($savedValues, $default); |
| 737 | 751 | } |
| 738 | 752 | |
| 739 | - return ($cached = $defaults); | |
| 753 | + return (self::$fieldsCache = $defaults); | |
| 740 | 754 | } |
| 741 | 755 | |
| 742 | 756 | public static function isTermsRequired(): bool |
| 743 | 757 | { |