[ECP-9653] Fix for Making Adyen Payments compatible with Magento 2.4.8 version and PHP 8.1+#2978
[ECP-9653] Fix for Making Adyen Payments compatible with Magento 2.4.8 version and PHP 8.1+#2978parekhreena wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Hello @parekhreena, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
Gemini here, providing a summary of this pull request. The primary goal of this PR, as indicated by the title, is to ensure compatibility of the Adyen Payments module with Magento 2.4.8 and PHP 8.1+. The changes primarily involve updating the codebase to leverage modern PHP features, specifically focusing on improved type hinting and updating the logging implementation to align with newer standards.
Highlights
- PHP 8.1+ Type Hinting: Extensive use of nullable type hints (
?) and union type hints (int|string|null) has been added to method and constructor parameters across various files (Helpers, Models, Controllers, Tests). This improves code clarity, enables better static analysis, and ensures compatibility with stricter type checking in PHP 8.1+. - Monolog Logging Update: The custom log levels (
ADYEN_DEBUG,ADYEN_NOTIFICATION,ADYEN_RESULT) within theAdyenLoggerhave been removed and replaced with standardMonolog\Levelenums. The corresponding logger handlers have also been updated to use these standard levels. - Constructor Parameter Nullability: Nullable type hints have been added to optional constructor parameters in several Model and Backend Config classes, particularly for dependencies like resource models, collections, and factories, aligning with common Magento dependency injection patterns.
Changelog
Click here to see the changelog
- Controller/Return/Index.php
- Added nullable type hint
?stringto the$incrementIdparameter in thegetOrdermethod (line 176).
- Added nullable type hint
- Helper/Config.php
- Added union type hint
int|string|nullto the$storeIdparameter in numerous methods (getApiKey,getClientKey,getIsPaymentMethodsActive,getMerchantAccount,getMotoMerchantAccounts,isMotoPaymentMethodEnabled,getMotoMerchantAccountProperties,getNotificationsUsername,getNotificationsPassword,getWebhookUrl,getWebhookId,getNotificationsCanCancel,getNotificationsHmacKey,getNotificationsIpCheck,isDemoMode,isAlternativePaymentMethodsEnabled,getChargedCurrency,getHasHolderName,getHouseNumberStreetLine,getHolderNameRequired,getAdyenPosCloudConfigData,useQueueProcessor,getAdyenAbstractConfigData,getLiveEndpointPrefix,getAdyenAbstractConfigDataFlag,getAdyenCcConfigData,getAdyenHppConfigData,getAdyenHppVaultConfigDataFlag,isHppVaultEnabled,getAdyenOneclickConfigData,getAdyenOneclickConfigDataFlag,getAdyenBoletoConfigData,getCheckoutFrontendRegion,getRatePayId,getAllowMultistoreTokens,getThreeDSFlow,getIsCvcRequiredForRecurringCardPayments,getConfigData). - Added
stringtype hint to the$modeparameter ingetApiKeyandgetClientKey(lines 85, 97). - Added nullable type hint
?intto the$storeIdparameter ingetNotificationsIpCheck(line 269). - Added union type hint
int|string|nullto the$storeIdparameter ingetConfigData(line 642).
- Added union type hint
- Helper/ConnectedTerminals.php
- Added nullable type hint
?intto the$storeIdparameter in thegetConnectedTerminalsmethod (line 34).
- Added nullable type hint
- Helper/Data.php
- Added nullable type hint
?Clientto the$clientparameter in thecreateAdyenCheckoutServicemethod (line 1445).
- Added nullable type hint
- Logger/AdyenLogger.php
- Removed custom log level constants
ADYEN_DEBUG,ADYEN_NOTIFICATION, andADYEN_RESULT(lines 25-27). - Removed custom levels from the static
$levelsarray (lines 36, 38-39). - Updated
addAdyenNotificationto useLevel::Noticeinstead ofstatic::ADYEN_NOTIFICATION(line 68). - Updated
addAdyenDebugto useLevel::Debuginstead ofstatic::ADYEN_DEBUG(line 75). - Updated
addAdyenResultto useLevel::Debuginstead ofstatic::ADYEN_RESULT(line 86).
- Removed custom log level constants
- Logger/Handler/AdyenBase.php
- Imported
Monolog\LogRecord(line 17). - Updated the
isHandlingmethod signature to useLogRecordtype hint for the$recordparameter (line 47).
- Imported
- Logger/Handler/AdyenDebug.php
- Imported
Monolog\Level(line 16). - Updated
$loggerTypeproperty to useLevel::Debug(line 28). - Updated
$levelproperty to useLevel::Debugand addedLeveltype hint (line 30).
- Imported
- Logger/Handler/AdyenError.php
- Imported
Monolog\Level(line 16). - Updated
$levelproperty to useLevel::Errorand addedLeveltype hint (line 33).
- Imported
- Logger/Handler/AdyenInfo.php
- Imported
Monolog\Level(line 16). - Updated
$levelproperty to useLevel::Infoand addedLeveltype hint (line 30).
- Imported
- Logger/Handler/AdyenNotification.php
- Imported
Monolog\Level(line 16). - Updated
$loggerTypeproperty to useLevel::Notice(line 28). - Updated
$levelproperty to useLevel::Noticeand addedLeveltype hint (line 30).
- Imported
- Logger/Handler/AdyenResult.php
- Imported
Monolog\Level(line 16). - Updated
$loggerTypeproperty to useLevel::Debug(line 28). - Updated
$levelproperty to useLevel::Debugand addedLeveltype hint (line 30).
- Imported
- Logger/Handler/AdyenWarning.php
- Imported
Monolog\Level(line 15). - Updated
$levelproperty to useLevel::Warningand addedLeveltype hint (line 29).
- Imported
- Model/Config/Backend/AutoConfiguration.php
- Added nullable type hints
?AbstractResourceand?AbstractDbto the$resourceand$resourceCollectionconstructor parameters (lines 64-65).
- Added nullable type hints
- Model/Config/Backend/DonationAmounts.php
- Added nullable type hints
?AbstractResourceand?AbstractDbto the$resourceand$resourceCollectionconstructor parameters (lines 47-48).
- Added nullable type hints
- Model/Config/Backend/Installments.php
- Added nullable type hints
?MagentoFrameworkModelResourceModelAbstractResourceand?MagentoFrameworkDataCollectionAbstractDbto the$resourceand$resourceCollectionconstructor parameters (lines 43-44).
- Added nullable type hints
- Model/Config/Backend/InstallmentsPosCloud.php
- Added nullable type hints
?MagentoFrameworkModelResourceModelAbstractResourceand?MagentoFrameworkDataCollectionAbstractDbto the$resourceand$resourceCollectionconstructor parameters (lines 44-45).
- Added nullable type hints
- Model/Config/Backend/Moto.php
- Added nullable type hints
?MagentoFrameworkModelResourceModelAbstractResourceand?MagentoFrameworkDataCollectionAbstractDbto the$resourceand$resourceCollectionconstructor parameters (lines 57-58).
- Added nullable type hints
- Model/Config/Backend/OrderStatus.php
- Added nullable type hints
?MagentoFrameworkModelResourceModelAbstractResourceand?MagentoFrameworkDataCollectionAbstractDbto the$resourceand$resourceCollectionconstructor parameters (lines 46-47). - Reordered constructor parameters and PHPDoc block to match the new nullable type hints.
- Added nullable type hints
- Model/Config/Backend/PaymentMethodsStatus.php
- Added nullable type hints
?AbstractResourceand?AbstractDbto the$resourceand$resourceCollectionconstructor parameters (lines 33-34).
- Added nullable type hints
- Model/Config/Backend/ProcessedWebhookRemoval.php
- Added nullable type hints
?AbstractResourceand?AbstractDbto the$resourceand$resourceCollectionconstructor parameters (lines 35-36).
- Added nullable type hints
- Model/Config/Backend/Tokenization.php
- Added nullable type hints
?AbstractResourceand?AbstractDbto the$resourceand$resourceCollectionconstructor parameters (lines 50-51).
- Added nullable type hints
- Model/Config/Backend/WebhookCredentials.php
- Added nullable type hints
?AbstractResourceand?AbstractDbto the$resourceand$resourceCollectionconstructor parameters (lines 64-65).
- Added nullable type hints
- Model/Creditmemo.php
- Added nullable type hints
?AbstractResourceand?AbstractDbto the$resourceand$resourceCollectionconstructor parameters (lines 28-29).
- Added nullable type hints
- Model/Invoice.php
- Added nullable type hints
?AbstractResourceand?AbstractDbto the$resourceand$resourceCollectionconstructor parameters (lines 28-29).
- Added nullable type hints
- Model/Method/PaymentMethodVault.php
- Added nullable type hint
?Jsonto the$jsonSerializerconstructor parameter (line 40).
- Added nullable type hint
- Model/Notification.php
- Added nullable type hints
?AbstractResourceand?AbstractDbto the$resourceand$resourceCollectionconstructor parameters (lines 57-58).
- Added nullable type hints
- Model/Order/Payment.php
- Added nullable type hints
?AbstractResourceand?AbstractDbto the$resourceand$resourceCollectionconstructor parameters (lines 37-38).
- Added nullable type hints
- Model/Sales/OrderRepository.php
- Added nullable type hints to several constructor parameters:
?CollectionProcessorInterface,?OrderExtensionFactory,?OrderTaxManagementInterface,?PaymentAdditionalInfoInterfaceFactory,?JsonSerializer, and?JoinProcessorInterface(lines 43-48).
- Added nullable type hints to several constructor parameters:
- Model/TransportBuilder.php
- Added nullable type hints to several constructor parameters:
?TransportInterfaceFactory,?EmailMessageInterfaceFactory,?MimeMessageInterfaceFactory,?MimePartInterfaceFactory, and?AddressConverter(lines 150-154).
- Added nullable type hints to several constructor parameters:
- Test/Unit/Gateway/Http/Client/TransactionCaptureTest.php
- Added nullable type hints
?arrayand?Exceptionto the$responseand$exceptionparameters in theconfigureAdyenMocksmethod (line 56).
- Added nullable type hints
- Test/Unit/Helper/ManagementHelperTest.php
- Added nullable type hints to several parameters in the
createManagementHelpermethod:?StoreManager,?EncryptorInterface,?Data,?Config,?AdyenLogger, and?ManagerInterface(lines 567-572).
- Added nullable type hints to several parameters in the
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Types now guide the way,
Nulls and unions hold their sway,
PHP, clear and bright.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
The changes in this pull request primarily focus on updating type hints in various PHP files to improve compatibility with PHP 8.1+ and Magento 2.4.8. Additionally, the logging classes have been refactored to utilize the standard Monolog Level enum, which is a good practice. The changes appear to be well-implemented and directly address the stated objective of the pull request.
Summary of Findings
- PHP 8.1+ Type Hinting: The pull request correctly introduces nullable type hints (
?) and union types (int|string|null) to function parameters and properties where appropriate, aligning the code with stricter type checking requirements in PHP 8.1+. - Monolog Level Enum Usage: The custom log levels in
AdyenLoggerhave been replaced with the standardMonolog\Levelenum, and the corresponding handlers have been updated. This improves consistency and adherence to the Monolog library's practices. - Severity Assessment: Based on the review criteria and the requested severity levels (
medium,high,critical), no issues falling within these categories were identified in the code changes.
Merge Readiness
The code changes are focused on compatibility and minor refactoring, and no critical or high-severity issues were found during the review. The changes appear safe and ready to be merged. As a code reviewer, I am unable to directly approve the pull request, but based on this review, it seems ready for approval by another maintainer.
|
Hello @parekhreena, Thank you for your contribution and we really appreciate your effort to make the plugin compatible with Magento 2.4.8. However, the changes in the logger are backward incompatible. The incompatibility arises from the input argument type change in Monolog library here. Due to this fact, this PR can not be merged to I am closing this PR as there is no further action will be taken. Best Regards, |
|
Hi @candemiralp Based on your response, it seems there's a misunderstanding of how PRs are intended to function on GitHub. The purpose of PRs on Github is for them to be reviewed, propose any new changes rather than have them merged as-is. If 1 file needed change, you can comment on proposing changes to that file instead of closing the whole PR with 30 other files which were correct. I hope you reconsider your approach to an open source extension and it's contributions. This is Especially needed on your part, as your current approach has kept your payment method upgrade incompatible since months for hundreds of merchants, thereby leaving them vulnerable to important security update. |
|
Hello @parekhreena, Thank you for your response and I really understand your frustration as it's currently not possible to upgrade to the latest version of Magento with our payment plugin. I ensure you that our internal team is working hard to enable our merchants again to use the latest version of the platform. Asides from this note, we encourage our contributors to create issues and propose pull-requests on our repository. We already use Github as a platform to discuss technical approaches via comments and improve the proposed solutions by collaborating closely. We have reviewed your PR already. However, there are some fundamental issues on your PR which can not be solved by discussing line-by-line. One of them is related to Monolog as I mentioned above and another one is related to mixed type declarations. Earlier versions of Magento (~2.4.4) does not support mixed argument type declarations (even though PHP supports it). It ends-up with a failure during DI compilation. After extracting these two changes, we observed some changes to make input types Based on the maintainability of the software that we offer to our merchants, we consider the supported versions of the platform, libraries and external dependencies at the same time. This approach ensures us to deliver what we have already committed and keep the quality always on top of everything while keeping the long-term support cycle in our mind always. Due to these facts, we can't introduce any breaking changes to a stable version even if they are for supporting the latest version of Magento. I accept and appreciate your feedback about the timeline of the delivery of the next major version and have already posted it internally. We will keep this in mind while preparing the next year's roadmap. Best Regards, |
|
@parekhreena I noticed Model/Sales/OrderRepository.php also needed a fix, could you merge |
|
hi @pbrouwers Thank you for contributing. I have now merged your PR in to my branch. |
This PR fixes compatibility issues with Magento 2.4.8 as discussed in #2914.
Fixes
The changes in this pull request primarily focus on updating type hints in various PHP files to improve compatibility with PHP 8.1+ and Magento 2.4.8. Additionally, the logging classes have been refactored to utilize the standard Monolog Level enum, which is a good practice. The changes appear to be well-implemented and directly address the stated objective of the pull request.
Summary of Findings
-Monolog Level Enum Usage: The custom log levels in AdyenLogger have been replaced with the standard Monolog\Level enum, and the corresponding handlers have been updated. This improves consistency and adherence to the Monolog library's practices.