Skip to content

[Bug] $quote can be null. Module: module-payment-services-paypal #39116

Open
@sgeleon

Description

@sgeleon

Summary

magento/product-community-edition: v2.4.7-p1

This plugin has some issues. The $quote can be null, but this possibility isn't accounted for in the plugin's definition.

Examples

vendor/magento/module-payment-services-paypal/Plugin/Vault/Method.php:59

public function afterIsAvailable(VaultMethod $subject, bool $result, **CartInterface $quote**): bool

vendor/magento/module-vault/Model/Method/Vault.php:659

 public function isAvailable(\Magento\Quote\Api\Data\CartInterface **$quote = null**)

Proposed solution

Patch for fix this problem:

Index: vendor/magento/module-payment-services-paypal/Plugin/Vault/Method.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/vendor/magento/module-payment-services-paypal/Plugin/Vault/Method.php b/vendor/magento/module-payment-services-paypal/Plugin/Vault/Method.php
--- a/vendor/magento/module-payment-services-paypal/Plugin/Vault/Method.php	
+++ b/vendor/magento/module-payment-services-paypal/Plugin/Vault/Method.php	(date 1714131569327)
@@ -56,9 +56,9 @@
      * @param CartInterface $quote
      * @return bool
      */
-    public function afterIsAvailable(VaultMethod $subject, bool $result, CartInterface $quote): bool
+    public function afterIsAvailable(VaultMethod $subject, bool $result, CartInterface $quote = null): bool
     {
-        if ($subject->getCode() === HostedFieldsConfigProvider::CC_VAULT_CODE) {
+        if ($quote && $subject->getCode() === HostedFieldsConfigProvider::CC_VAULT_CODE) {
             if ($customerId = $quote->getCustomerId()) {
                 return !empty($this->tokenManagement->getVisibleAvailableTokens($customerId));
             }

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

Area: PaymentsComponent: VaultIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: ready for devReported on 2.4.7-p1Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions