Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Ensure that CMS is booted prior to processing legacy PayPal IPN #29521

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

seamuslee001
Copy link
Contributor

Overview

Recently the Australian Greens found that they had a recurring contribution that had been running for so long that it still relied on the extern/ipn.php route. When they switched from D7 to D9 this broke (many reasons but for the purpose of this PR) one problem was that in D9 you need to have booted the Drupal Container which is done as part of the bootstrap call here first before trying to record in the System Log table the IPN request

Before

Really old legacy IPNs cannot be processed on D9

After

Possibly can be without container errors

ping @eileenmcnaughton @MegaphoneJon @andrew-cormick-dockery @johntwyman

Copy link

civibot bot commented Feb 27, 2024

🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷

Introduction for new contributors...
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
Quick links for reviewers...

➡️ Online demo of this PR 🔗

@civibot civibot bot added the master label Feb 27, 2024
@seamuslee001
Copy link
Contributor Author

Note that as per the documentation in the ipn.php file

Whilst you can change the IPN url for future recurring contributions in the PayPal system once there is one using a particular url then it is stuck with that url.

@andrew-cormick-dockery
Copy link
Contributor

Just adding my comments here about verification.

I tested this on my local development machine using Postman to simulate a Paypal IPN, and a payment was recorded successfully with this patch (among other patches which are unrelated to CiviCRM).

Further, I have just looked in production with regard to a number of transactions which were failing prior to this PR being applied, and they are now being processed correctly.

@andrew-cormick-dockery
Copy link
Contributor

andrew-cormick-dockery commented Feb 27, 2024

Note that this was the recorded error message prior to the patch being applied:

PHP Fatal error:  Uncaught Drupal\Core\DependencyInjection\ContainerNotInitializedException: \Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container. in /var/www/html/web/core/lib/Drupal.php:179
Stack trace:
#0 /var/www/html/web/core/lib/Drupal.php(277): Drupal::getContainer()
#1 /var/www/html/vendor/civicrm/civicrm-core/CRM/Utils/System/Drupal8.php(946): Drupal::request()
#2 /var/www/html/vendor/civicrm/civicrm-core/CRM/Utils/System.php(1292): CRM_Utils_System_Drupal8->ipAddress()
#3 /var/www/html/vendor/civicrm/civicrm-core/CRM/Utils/SystemLogger.php(28): CRM_Utils_System::ipAddress()
#4 /var/www/html/vendor/psr/log/Psr/Log/AbstractLogger.php(40): CRM_Utils_SystemLogger->log()
#5 /var/www/html/vendor/civicrm/civicrm-core/extern/ipn.php(55): Psr\Log\AbstractLogger->alert()
#6 {main}

@eileenmcnaughton eileenmcnaughton merged commit 883c523 into civicrm:master Feb 27, 2024
3 checks passed
@eileenmcnaughton eileenmcnaughton deleted the extern_legacy_drupal9 branch February 27, 2024 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants