CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Civicrm breaks Drupal functionality when registering
Pages: [1] 2

Author Topic: Civicrm breaks Drupal functionality when registering  (Read 2820 times)

torrance123

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 3
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0.91
  • PHP version: 5.3.3
Civicrm breaks Drupal functionality when registering
August 10, 2011, 09:53:00 pm
Hi there,

We have a use case as such:

User tries to sign up for an event, we detect that they are not logged in, and fire them off to a register/login screen in drupal with the 'destination' query string set to the original page. The expected outcome is that, on successful submission of the form and thanks to logintoboggan, the user to taken back to the original page logged in.

There are two breakages I am noticing caused by civicrm.

The first issue is that if we are at user/register, and the destination string is civicrm/page/1, then when civicrm is enabled the page attempts to redirect to /user/civicrm/page/1, as opposed to the normal civicrm/page/1. It's not properly handling the redirection.

The second issue, related to the first, is that we are using logintoboggin to automatically log in upon registering. When civicrm is enabled, we are not automatically logged in. I can see that in logintoboggan, the function handling user registration never makes it passed a call to user_save(): the remaining code in that function — including the code which causes the user to be logged in immediately — is never called.

Both these issues appear to be caused by civicrm listening for hook_user and responding to $op == update. After following a very *long* line of function calls I have discovered that if I comment out line 284 of Controller.php in civicrm3.4.4 (this->_pages[$pageName]->handle($action); , I can stop both these issues from happening.

I've given up following it any further from here, but appears to me that civicrm is responding to a hook_user event, but is never handing back control to drupal to finish up its tasks. This is bad for numerous reasons, not least of all that other modules listening to hook_user aren't being called or (in logintoboggan's case) aren't being allowed to finish their work.

What can we do to fix this?

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Civicrm breaks Drupal functionality when registering
August 11, 2011, 03:48:05 pm
These issues aren't necessarily caused by CiviCRM, but rather just an incompatibility between the LoginTobbogan drupal module and CiviCRM.    Keep in mind CiviCRM is not really a Drupal module.  Rather it is a codebase 10x the size of Drupal pretending to be a Drupal module so that people can use it with Drupal.

CiviCRM hasn't tested compatibility with every Drupal module and all their possible configurations, and conflicts like this occasionally happen.   
My suggestion is to hire a programming company to investigate the issue and make changes to either LogniTobbogan and/or CiviCRM code so they play nice together.  I suggest WebAccess
Try CiviTeacher: the online video tutorial CiviCRM learning library.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Civicrm breaks Drupal functionality when registering
August 13, 2011, 08:37:46 am
Torrance has done quite a bit of digging on this already & I think he as gotten to the point in the code where Civi doesn't behave like a 'normal' drupal module.

I would think that Civi would ideally hand back control of the user update hook. I presume it doesn't because it's redirecting the browser at some point in the form controller.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Civicrm breaks Drupal functionality when registering
August 13, 2011, 09:18:11 am

torrance:

can u  cut-n-paste the backtrace to where civicrm does the redirection (this will make it easier for me to track and figure things, rather than trying to reproduce). I think we do have conditional code in there that avoids redirection when drupal is invoked. i suspect we missed this case and hence the bug

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

torrance123

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 3
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0.91
  • PHP version: 5.3.3
Re: Civicrm breaks Drupal functionality when registering
August 15, 2011, 09:16:05 pm
I'm not sure how to produce a useful backtrace for these purposes. However, I inserted a runtime error prior to the method call mentioned previously which allowed me to get an xdebug backtrace up to that point. I'm not sure if it will prove useful.

Code: [Select]
1. {main}() /sites/egwellness/index.php:0 0.3756 61215008
2. menu_execute_active_handler(???) /sites/egwellness/index.php:17 0.3756 61215104
3. call_user_func_array(string(25), array(0)) /sites/egwellness/includes/menu.inc:349 0.3756 61215352
4. single_user_page_callback() /sites/egwellness/includes/menu.inc:349 0.4094 66110760
5. drupal_get_form(string(13)) /sites/egwellness/sites/all/modules/egwc_custom_modules/single_user_page/single_user_page.module:49 0.7329 103840560
6. drupal_process_form(string(13), array(29), array(7)) /sites/egwellness/includes/form.inc:120 0.7908 104051184
7. form_execute_handlers(string(6), array(29), array(7)) /sites/egwellness/includes/form.inc:421 0.7908 104054864
8. logintoboggan_user_register_submit(array(29), array(7)) /sites/egwellness/includes/form.inc:781 0.7909 104056352
9. user_save(string(0), array(11), ???) /sites/egwellness/sites/all/modules/logintoboggan/logintoboggan.module:354 0.8082 107375528
10. user_module_invoke(string(6), array(14), class stdClass, string(7)) /sites/egwellness/modules/user/user.module:339 0.8128 107399120
11. civicrm_user(string(6), array(14), class stdClass, string(7)) /sites/egwellness/modules/user/user.module:21 0.8128 107400816
12. civicrm_register_data(array(14), class stdClass, string(7), bool, ???) /sites/egwellness/sites/all/modules/civicrm/drupal/civicrm.module:418 0.9891 113063256
13. CRM_Core_BAO_UFGroup::getEditHTML(long, string(0), long, bool, bool, null, bool, string(10)) /sites/egwellness/sites/all/modules/civicrm/drupal/civicrm.module:563 0.9932 113084840
14. CRM_Core_Controller->run() /sites/egwellness/sites/all/modules/civicrm/CRM/Core/BAO/UFGroup.php:582

I should be clear: this ONLY happens when destination is set in the query string, eg. /user/register?destination=/node/1. So it seems very likely that civicrm is seeing the redirect and attempting the redirection itself, as opposed to handing control back to drupal to do the redirection as it should.

There are actually two bugs here: 1. civicrm is doing the redirect instead of letting drupal do it. 2. civicrm isn't redirecting to the correct page. The second issue would be fixed if the first were fixed.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Civicrm breaks Drupal functionality when registering
August 16, 2011, 09:30:14 am

argh ...

seems like there is a conflict of GET vars. Civi also uses destination to do redirections within Civi and hence we try to do the redirect :(

seems like we should rename it to civiDest to be on the safe side. I dont think we use it in too many places, so making the change might not be too hard

Can you work on a patch for this and we can add the fix to 4.1

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Civicrm breaks Drupal functionality when registering
August 17, 2011, 02:17:48 pm
Lobo - where did you spot the conflict? Can we get this patch into 3.4.6? Otherwise I think we need to come up with another solution.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Civicrm breaks Drupal functionality when registering
August 17, 2011, 02:44:21 pm

we do an explicit redirect on destination (in the configuration page mainly) and hence spotted the conflict with drupal/logintobaggon

We can apply the contributed patch for 3.4.6. I dont think it will be a big patch

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

torrance123

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 3
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0.91
  • PHP version: 5.3.3
Re: Civicrm breaks Drupal functionality when registering
August 17, 2011, 10:20:02 pm
I'm not up on the play with civi internals, but I ran a grep and changed both variables and url strings from 'destination' to 'civicrmDestination' where it looked like it made sense.

So consider the attached patch pre-alpha.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Civicrm breaks Drupal functionality when registering
August 18, 2011, 12:28:30 am
Hi T, patch looks OK in theory ... does it fix your problem?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

torrance123

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 3
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0.91
  • PHP version: 5.3.3
Re: Civicrm breaks Drupal functionality when registering
August 18, 2011, 01:35:16 am
Quote from: Eileen on August 18, 2011, 12:28:30 am
Hi T, patch looks OK in theory ... does it fix your problem?

Yep, logintoboggan works and redirections replace the entire url, not just the last section.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Civicrm breaks Drupal functionality when registering
August 18, 2011, 07:52:05 am

To keep the patch simple and in just a few files, i would prefer that we:

1. change only the name of the URL variables (when retrieving and sending) to civicrmDestination

2. The rest of the code, $destination is a local variable to the function / civi code and hence should be kept as is (IMO)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

torrance123

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 3
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0.91
  • PHP version: 5.3.3
Re: Civicrm breaks Drupal functionality when registering
August 18, 2011, 03:27:49 pm
See attached for changes as per Lobo's suggestion.

I'd changed both variables and string names because their were a few instances where I wasn't completely sure what the code was doing (eg. line 54 of ConfigTaskList.php) and wasn't sure if I was writing out to a variable or to the query string. Plus it seemed more consistent.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Civicrm breaks Drupal functionality when registering
August 21, 2011, 07:55:56 pm
Added to Jira with patch - hope that was okay - http://issues.civicrm.org/jira/browse/CRM-8698
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

torrance123

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 3
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0.91
  • PHP version: 5.3.3
Re: Civicrm breaks Drupal functionality when registering
August 31, 2011, 03:44:30 pm
That patch has been committed to 3.x. I'm not sure if this has also been done against 4.x.

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Civicrm breaks Drupal functionality when registering

This forum was archived on 2017-11-26.