I'm quite interested in seeing a version of bakery for Drupal 7, especially as I believe it wouldn't matter whether the master and slave sites were running on the same version of Drupal core(?).

Its something i'm hoping to work on and post some patches, but if anyone from the infrastructure team knows where the sticky patches are going to be, it'd be really helpful to have a few eyes and pointers.

Comments

catorghans’s picture

Yes, I really would be interested in this and also be able to help. If bakery for drupal 7 would be able to handle drupal 6 slaves (or vice versa) that would help us greatly in a careful upgrade of our sites.

juliangb’s picture

StatusFileSize
new3.72 KB

This is my work so far. Warning - this code currently does not work.

It seems mainly to be DBTNG changes that are required.

I will post another patch once i've done a bit more.

coltrane’s picture

Status: Active » Needs review
StatusFileSize
new17.79 KB

Updated patch from the one in #2 by juliangb.

Applying patch to D7 CVS HEAD site and 6.x of Bakery on a Atrium site and I'm getting SSO to work. Need to test synchronizing fields next, email works though. Update: no syncing works yet.

One issue: the list of slaves isn't populated after saving, but it's set in the variable. Not sure why it's not filling in the text area correctly.

coltrane’s picture

StatusFileSize
new18.05 KB

Working sync! only tested with email so far though

Edit: After spending so much time in bakery_user_presave() I realize the $_SESSION storage there isn't necessary ... Will update soon

juliangb’s picture

Excellent - sounds like you've got a lot further than I got.

Have you tested with the D7 version being the master and the slave (not necessarily at the same time)?

I will test this more fully later on today hopefully.

It would be really great if one of the maintainers could branch the D6 version off in CVS and commit this to HEAD for a 7.x-1.x-dev. That will really help testing from now.

juliangb’s picture

Tested with the D7 site being the bakery slave,

Got 500 Internal Server Error at page /bakery?destination=node, having clicked 'login'.

juliangb’s picture

StatusFileSize
new19.3 KB

The attached patch gets rid of the 500 error, successfully redirects to the master (running on D6), which redirects back. Here we hit:
Fatal error: Call to undefined function db_result() in /sites/all/modules/bakery-HEAD/bakery.module on line 486

juliangb’s picture

StatusFileSize
new19.55 KB

This patch now works for me - I have been testing using a D6 master, and D7 slave.

greggles’s picture

I've created 6.x branch and 6.x-1.0-alpha1 release. That lets HEAD become the D7 compatible version.

http://drupal.org/node/528018 is the 7.0 release, though it needs 12 more hours to get re-generated to get a real tarball.

coltrane’s picture

StatusFileSize
new20.33 KB

Thanks juliangb!

Updated patch:

* There was a leftover watchdog() for debugging, removed.
* Have to store updated fields in the session because we need to implement hook_user_presave() and hook_user_update() so updated fields are pushed on update, but not insert (like user register).
* Translated menu item was using old drupal_get_destination() style
* Form alter on user forms wasn't accessing user object correctly
* Updated bakery_uncrumble_validate() user search -- but, not sure if user_load_multiple() hashes 'pass' in the condition array. Haven't tested bakery repair.

Of considerable note:
In bakery_user_authenticate_finalize() I'm calling drupal_session_regenerate(). The D6 code has a similar line commented out but in my testing of a slave d7 site running drupal_session_regenerate() the user gets logged in correctly, and stays logged in to the master site. So it seems like it should be in to protect against unlikely session fixation attacks. juliangb, let me know if anything odd happens with your tests.

I think this could be set to RTBC pending some more tests. The remaining issues could be discussed and handled in followups.

coltrane’s picture

Status: Needs review » Reviewed & tested by the community

I think it's good for dev branch.

juliangb’s picture

I haven't had a chance to do further tests (at somepoint soon I hope), but I'd agree that this is ready to put into the -dev branch, and we can sort any further bugs out there.

Not sure about the session regeneration issue - but I guess it is better to be safe than sorry. It is odd that it is in the D6 version but commented out.

greggles’s picture

Title: Bakery for Drupal 7 » Bakery for Drupal 7: testing and synch-repair system
Status: Reviewed & tested by the community » Needs work

Cool - committed - http://drupal.org/cvs?commit=355086

Thanks coltrane and juliangb!

Back to needs work and an updated title to better reflect the status. I'll update the project page to point to this.

juliangb’s picture

D7 slave site - user account page:
- Doesn't show link to profile on master site
- Allows changing of password / email address on slave site

juliangb’s picture

Also, D7 slave site, when the user logs out - the site gets quite messed up. The entire page is rendered again within the content region.

Error in logs: Recoverable fatal error: Argument 1 passed to drupal_http_build_query() must be an array, string given, called in /home/drupalde/public_html/d7-core/includes/common.inc on line 2049 and defined in drupal_http_build_query() (line 466 of /home/drupalde/public_html/d7-core/includes/common.inc).

Although the error doesn't mention bakery, it goes away when bakery is disabled.

juliangb’s picture

Would it be possible to check the recommended box for the D7 version please? Currently we can't do a drush dl bakery for d7.

EDIT - you can use drush dl bakery-7.x-1.x still, so this isn't critical - it'd just make testing thing out a little quicker!

juliangb’s picture

When saving the admin settings form, all listed slave sites disappear.

coltrane’s picture

StatusFileSize
new977 bytes

This patch fixes the bakery slaves not being displayed after submitting the form. Problem was the default_value was being cleared by http://api.drupal.org/api/function/_system_settings_form_automatic_defau...

coltrane’s picture

StatusFileSize
new719 bytes

This patch corrects the error on d7 slave site. The translated menu link was use the destination string instead of the array.

greggles’s picture

Now committed - #18: http://drupal.org/cvs?commit=360148 and #19: http://drupal.org/cvs?commit=360150.

Thanks for finding them and fixing them, juliangb and coltrane!

coltrane’s picture

Status: Needs work » Needs review
StatusFileSize
new3.67 KB

Here's working account repair for D7. On my D7 slave site I get an error about the stroopwafel key not being present in POST, but no code during bakery/repair should be calling bakery_taste_stroopwafel_cookie() that I can tell.

juliangb’s picture

I'm now getting a 403 on slave/user/login, rather than redirecting to master/user/login.

greggles’s picture

@juliangb - you mean as an anonymous user?

coltrane’s picture

yeah, @juliangb can you describe how you get a 403?

greggles’s picture

The first hunk seems wrong to me:


-        $result = db_query("SELECT COUNT(*) FROM {users} WHERE init = :init", array(':init' => $cookie['init']));
-        $record = $result->fetchObject();
-        if ($record['count(*)'] == 0) {
+        $count = db_select('users', 'u')->fields('u', array('uid'))->condition('init', $cookie['init'], '=')
+          ->countQuery()->execute()->fetchField();
+        if ($count == 0) {

Do we need to count or just say "is there at least one record?" If we need to count, we should use a sql count(1) style query. If it's a test for "at least one record" we should do a range query to limit the number of rows it will scan.

greggles’s picture

NEVERMIND! I didn't notice the little ->countQuery() in the chain. Brilliant work.

coltrane’s picture

StatusFileSize
new3.96 KB

I think we should move the 403 when anonymous hits user/login on slave to a new a issue.

Here's an updated patch for account repair. I'm still not certain why bakery_taste_stroopwafel_cookie() is called on bakery/repair, but this patch does an isset() to avoid the message.

greggles’s picture

Status: Needs review » Fixed

Fixed - thanks coltrane!

http://drupal.org/cvs?commit=361266

I agree about the 403 vs. redirect. I suggest we revisit that flow as a whole.

coltrane’s picture

Status: Fixed » Needs review
StatusFileSize
new730 bytes

Minor update, the INSTALL.txt :)

greggles’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.