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

dev/core#973 Fix legacy IPN endpoint for Drupal #14272

Merged

Conversation

artfulrobot
Copy link
Contributor

@artfulrobot artfulrobot commented May 20, 2019

Overview

The old extern/ipn.php script was failing.

Before

Calls failed because Drupal was not bootstrapped but was assumed to have been.

After

Works as expected.

Technical Details

I added a bootstrap call.

Comments

Note that the bootstrap does not load a user (which is the default behaviour). I don't think a CMS user is required for this anyway, but pointing it out.

https://lab.civicrm.org/dev/core/issues/973

@civicrm-builder
Copy link

Can one of the admins verify this patch?

@civibot civibot bot added the master label May 20, 2019
@civibot
Copy link

civibot bot commented May 20, 2019

(Standard links)

@jaapjansma
Copy link
Contributor

I do think this is a good patch.

Copy link
Contributor

@laryn laryn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put an "or backdrop" condition in with it?

@mattwire
Copy link
Contributor

What is the reason for still using the deprecated extern/ipn.php script instead of the newer civicrm/payment/ipn/XX endpoint? A better fix might be to "encourage" people to switch to the newer endpoints as they have been available for quite a long time now..

@artfulrobot
Copy link
Contributor Author

@mattwire because you physically cannot change the IPN for PayPal. When the payment is submitted it is bound to a fixed URL(!) So if you have been running CiviCRM for years you'll always need that extern script.

@artfulrobot
Copy link
Contributor Author

@laryn re Backdrop: Probably. Would need someone with Backdrop to test. For all I know this might also be broken in WordPress as well though. I don't know.

@mattwire
Copy link
Contributor

@artfulrobot Can you add in some commenting to this file (as part of this PR) that explains why we still need the extern/ipn.php for paypal and we can't "just get rid of it". And also modify the commit message so it's a bit clearer without having to read the gitlab first? Then I would feel ok to merge.

@artfulrobot artfulrobot force-pushed the artfulrobot-gitlab-issue-973 branch from cb70683 to 79f6a52 Compare May 20, 2019 14:23
@artfulrobot artfulrobot changed the title Patch to address gitlab issue 973 Fix legacy IPN endpoint for Drupal (gitlab issue 973) May 20, 2019
@artfulrobot
Copy link
Contributor Author

How's that @mattwire ?

@mattwire
Copy link
Contributor

@artfulrobot Comment is great but now the actual patch has gone away...

@artfulrobot artfulrobot force-pushed the artfulrobot-gitlab-issue-973 branch 2 times, most recently from 82e4324 to e5e472b Compare May 20, 2019 15:08
@artfulrobot
Copy link
Contributor Author

@mattwire huh? weird. Try reloading github page? I forced an update to the branch to clean it up. (also spotted I'd accidentally joined three lines in a comment so corrected that too).

@laryn
Copy link
Contributor

laryn commented May 20, 2019

@artfulrobot I think he's referring to this: https://github.com/civicrm/civicrm-core/pull/14272/files

@mattwire
Copy link
Contributor

mattwire commented May 20, 2019

@artfulrobot Yes, this was your original patch (cb70683) - now that bit's not included in the latest PR!

@artfulrobot artfulrobot force-pushed the artfulrobot-gitlab-issue-973 branch from e5e472b to 4b54135 Compare May 20, 2019 15:25
@artfulrobot
Copy link
Contributor Author

*blush* !

Sorry! Try this now! Also I swapped out the if elseif for a switch as I figured it would be clearer/nicer to add in case 'Backdrop: if that turns out to be a good idea.

@laryn
Copy link
Contributor

laryn commented May 20, 2019

I think it would be quite safe to add case 'Backdrop': immediately after case 'Drupal': since it should be identical but I don't have a way to test such an IPN from Paypal currently.

Also, maybe it would be good to move the //CRM-18245 comment to the Joomla switch to reference the issue which seems to be Joomla specific.
https://issues.civicrm.org/jira/browse/CRM-18245

Or, perhaps you've already thought of this and discarded the idea, but might it be better to lose the switch altogether? What's the functional difference between CRM_Utils_System::loadBootStrap(); and CRM_Utils_System::loadBootStrap([], FALSE);?

@artfulrobot
Copy link
Contributor Author

artfulrobot commented May 20, 2019

Backdrop, agreed seems sensible, I'll do that.

The difference between the 2 calls is whether the bootstrap should load a CMS user or not. It doesn't make sense to load a user to me, and sure enough it doesn't work doing so in Drupal but I didn't want to change someone else's code without testing that my change works in joomla.

@mfb
Copy link
Contributor

mfb commented May 20, 2019

As a long-term solution, could CiviCRM create an endpoint named extern/ipn.php and remove the file?

@eileenmcnaughton
Copy link
Contributor

add to whitelist

@eileenmcnaughton
Copy link
Contributor

@mfb it's a full path - /sites/all/modues/civicrm/extern/ipn.php - not sure thatis do-able

@mfb
Copy link
Contributor

mfb commented May 20, 2019

You can create an endpoint @ any path, so sites/all/modues/civicrm/extern/ipn.php would work, but it looks like CiviCRM supports setups where this isn't doable: no clean URLs.

@artfulrobot artfulrobot force-pushed the artfulrobot-gitlab-issue-973 branch from 4b54135 to 48af6e7 Compare May 21, 2019 08:01
@artfulrobot
Copy link
Contributor Author

OK, included @laryn's Backdrop suggestion and put the Joomla comment by the joomla bit (thanks).

@mfb: yeah can't rely on clean paths. But still be good if CiviCRM scripts had a single way to bootstrap the whole system (CMS+Civi).

@seamuslee001
Copy link
Contributor

Jenkins doesn't seem to like your style @artfulrobot https://test.civicrm.org/job/CiviCRM-Core-PR/26258/checkstyleResult/new/

@xurizaemon
Copy link
Member

xurizaemon commented May 21, 2019

We know that PayPal respects HTTP 307 (Jon's SE answer, chat.civicrm.org with @artfulrobot).

Are these fixes really worthwhile, to keep maintaining extern/ipn.php?

🔥 🔥 🔥 rm -rf extern/ 🔥 🔥 🔥

/opinion 😁

be good if CiviCRM scripts had a single way to bootstrap the whole system (CMS+Civi)

dev/cloud-native#16

To be fair to @artfulrobot's MR, the change is probably not going to make things worse, but in your position I'd try to change your existing redirect to the modern IPN and be done.

@artfulrobot
Copy link
Contributor Author

@xurizaemon what I'm unclear on is how the 307 can help redirect from

 extern/ipn.php?contributionID=123&contributionRecurID=456&contactID=1234&reset=1&...

to

civicrm/payment/ipn/100

Where you don't know the payment processor ID on the incoming request.

@artfulrobot artfulrobot force-pushed the artfulrobot-gitlab-issue-973 branch from 48af6e7 to b9a3974 Compare May 21, 2019 10:21
@artfulrobot artfulrobot force-pushed the artfulrobot-gitlab-issue-973 branch from b9a3974 to 0ef08f3 Compare May 21, 2019 10:23
@artfulrobot
Copy link
Contributor Author

@seamuslee001 think I've calmed that perfectionist Jenkins :-)

@xurizaemon
Copy link
Member

xurizaemon commented May 22, 2019

Where you don't know the payment processor ID on the incoming request.

Uggh, fair.

Do you really not know, though? Does the site in question really have multiple PayPal processors configured? If not, I'd 307 to new-IPN URL with a fixed value; if so, I'd look at the proxy / relay approach mentioned in same chat, esp since the PP ID is derivable from the contributionID which you do have.

Anyway ... good luck with it :)

@artfulrobot
Copy link
Contributor Author

@xurizaemon Actually they do have several PayPal accounts (although probably these old IPN requests are all going to one of those two), however we're talking about core CiviCRM here so we can't make assumptions if we want it to be a stable platform. I think we just need a way to keep this extern script as minimal to maintain as poss (I appreciate that's what your linked issue was in part about).

@eileenmcnaughton
Copy link
Contributor

I guess this is safe since we were already doing it for Joomla! & you have tested for drupal - there seems to be adequate discussion ./ buy in. Merging

@eileenmcnaughton eileenmcnaughton merged commit aa03bf9 into civicrm:master May 23, 2019
@eileenmcnaughton eileenmcnaughton changed the title Fix legacy IPN endpoint for Drupal (gitlab issue 973) dev/core#973 Fix legacy IPN endpoint for Drupal May 23, 2019
@eileenmcnaughton
Copy link
Contributor

turns out this was a regression caused by #13439

@artfulrobot
Copy link
Contributor Author

Thanks @eileenmcnaughton!

@eileenmcnaughton
Copy link
Contributor

@artfulrobot do you have any thoughts about the comments here https://lab.civicrm.org/dev/drupal/issues/66#note_18471

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.

9 participants