5

I have tested a Drupal 7 multi-site before, and it worked for me perfectly. With Drupal 8, it doesn't work as expected.

Suppose there are two sites, site1 with site1_ as table prefix and site2 with site2_ as table prefix.
The documentation says that I should add the following lines in the settings.php file.

  'prefix' => array(
     'default'   => 'site2_',
     'users'     => 'shared_',
   ),

It doesn't work because the users table in Drupal 8 doesn't have username and password information.

If I add this lines, Drupal won't work normally too.

  'prefix' => array(
     'default'   => 'site2_',
     'users'     => 'site1_',
     'users_data'     => 'site1_',
     'users_field_data'     => 'site1_',
     'user__user_picture'     => 'site1_',
   ),

For example if a user in site1 changes password, this user cannot login with the new password on site2, but the user can login with the old password once, and sign out; then the new password works!

I expected that the migration path from Drupal 6 to Drupal 8 would support migration of the shared table too, but this doesn't seem to be true. Even reading https://www.drupal.org/node/2551549 and https://www.drupal.org/node/2768219 doesn't help me much.

Are shared user tables still supported and working, on Drupal 8?

  • It could be a caching issue. Try to clear cache in site 2 after changing password in site 1 – Eyal Jan 21 '17 at 8:14
  • thanks @Eyal, it's not . i tested before. also tested with another browser to prevent caching and cookie and changed cookie_lifetime to 0 but problem exist. – user780 Jan 21 '17 at 8:28
  • Making sure we are both talking about drupal caches and not browser cache. i.e. drush cr all – Eyal Jan 21 '17 at 8:40
  • i cleared drupal cache and also checked with another browser to prevent browser cache – user780 Jan 21 '17 at 8:42
7

Don't.

Per table-sharing is a relict of the past, deprecated and will be removed in Drupal 9. With all the layers on top that dynamically create tables for fields, cache invalidation and so on, this is never going to work.

If you want to have a shared authentication system, then look into an actual single sign on projects.
These are some links to get started; I don't have a lot of experience with either yet.

  • thanks @Berdir. but login with old password for one time is strange to me and a security issue. also i excepted drupal team to notify people about this big change in release notes, update doc, migration and ... – user780 Jan 21 '17 at 19:01
0

You could use Domain Access

The Domain Access project is a suite of modules that provide tools for running a group of affiliated sites from one Drupal installation and a single shared database. The module allows you to share users, content, and configurations across a group of sites such as:

example.com
one.example.com
two.example.com
my.example.com
thisexample.com <-- can use any domain string
example.com:3000 <-- treats non-standard ports as unique

By default, these sites share all tables in your Drupal installation. The Domain Prefix module (for Drupal 6) allows for selective, dynamic table prefixing for advanced users.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.