-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Summary
ON magento 2.4.8-p3 I noticed that \Magento\Csp\Helper\CspNonceProvider is misleadingly named
it lives under the Helper namespace but does not extend \Magento\Framework\App\Helper\AbstractHelper.
It behaves however as a standalone service used for generating CSP nonces, not as a traditional Magento helper.
This inconsistency can confuse developers and tools expecting helper behavior.
Examples
-
Misleading:
use Magento\Csp\Helper\CspNonceProvider; $nonce = $this->cspNonceProvider->generateNonce(); // not a real Helper
-
What it should have been:
use Magento\Csp\Service\CspNonceProvider; // or use Magento\Csp\Model\CspNonceProvider;
-
Expected Helper (if it really were one):
class CspNonceProvider extends \Magento\Framework\App\Helper\AbstractHelper { // typical helper access to store config, context, etc. }
In short: the class name implies framework helper semantics, but it’s just a regular service.
Morever if it's not extending AbstractHelper then it's not possible to use it directly in PHTML files but you have to inject the viewModel instead.
In any case either the namespace should be corrected or it should extend the AbstractHelper, leaving it like this is misleading as to it's purpose.
Proposed solution
Either move it under another namespace or extend AbstractHelper
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status