fix: address QA P1 + P2 findings from 9aa5309 review
P1 fix: Add class_exists() guard in PRC_Preset_Provider before instantiating PR Core repository classes. If PR Core constant is defined but classes fail to autoload, fall back to defaults instead of crashing. P2 fixes: - Remove unused nonce from wp_localize_script (all endpoints public) - Add cross-reference comments pinning SYRINGE_UNITS_PER_ML across PRC_Math, calculator.js, and prcConfig.syringeUnits QA verdict: qa-reviews/peptide-reconstitution-calculator/2026-04-17-9aa5309.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
7
includes/class-prc-preset-provider.php
Normal file → Executable file
7
includes/class-prc-preset-provider.php
Normal file → Executable file
@@ -85,6 +85,13 @@ class PRC_Preset_Provider {
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
private function build_presets_from_pr_core(): array {
|
||||
// Why class_exists: PR_CORE_VERSION constant may be defined but classes
|
||||
// could fail to autoload (e.g. fatal error in PR Core bootstrap).
|
||||
// Fall back to empty array so the caller merges in defaults gracefully.
|
||||
if ( ! class_exists( 'PR_Core_Peptide_Repository' ) || ! class_exists( 'PR_Core_Dosing_Repository' ) ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$peptide_repo = new PR_Core_Peptide_Repository();
|
||||
$dosing_repo = new PR_Core_Dosing_Repository();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user