Problem

  • Drupal data is too abstracted today, it is impossible to share tables across multiple-sites.

Goal

  • Remove the database table prefix sharing feature.

Details

  • default.settings.php suggests:
     * To provide prefixes for specific tables, set 'prefix' as an array.
     * The array's keys are the table names and the values are the prefixes.
     * The 'default' element is mandatory and holds the prefix for any tables
     * not specified elsewhere in the array. Example:
     * @code
     *   'prefix' => array(
     *     'default'   => 'main_',
     *     'users'     => 'shared_',
     *     'sessions'  => 'shared_',
     *     'role'      => 'shared_',
     *     'authmap'   => 'shared_',
     *   ),
     * @endcode
    
  • Now, try to share those tables across multiple sites...:
    1. users.picture contains a file ID. You either have to share the file_managed and file_usage tables, too, or you have to disable user pictures.
    2. Oh, let's resolve that via #1292470: Convert user pictures to Image Field...? Then you'll have to share the field_user_picture and the field_revision_user_picture tables. In addition to the file_managed and file_usage tables.
    3. Speaking of, did you add any other fields to users? Did you re-use an existing field that's also used on a different entity type/bundle...?
    4. users.signature_format, check. Also share the filter_format and filter table.
    5. users.langcode, check. users.preferred_langcode, check. Also share the language table.
    6. Some of that stuff becomes configuration in D8? Check. No way to share/separate configuration between multi-sites.
  • Next to the fundamental issues that always existed with this feature...:
    1. role_permission references role IDs stored in role. role is shared, role_permission is not. ID mismatch, security, anyone? Better share both.
    2. Permissions in role_permission are declared by modules. Enabled modules are defined in system, but that's not shared. Either share it, or better don't change the configured permissions.
    3. ...repeat and recurse for other tables and references...
CommentFileSizeAuthor
#6 drupal8.settings-prefixes.6.patch2.13 KBsun

Comments

damienmckenna’s picture

You want to remove the *EXTREMELY* *USEFUL* shared tables functionality when the real problem you danced around is that the user profile image should be a field and not something hardcoded in the users table? Really? Can I mark this "Closed (won't fix)"?

damienmckenna’s picture

Status: Active » Closed (duplicate)
sun’s picture

Status: Closed (duplicate) » Active

It looks like you did not understand the problem space. Happy to clarify what's unclear, but not sure what is being unclear.

damienmckenna’s picture

You want to remove a core feature because of complications implementing with specific use cases? Seems kinda cutting your foot off because you can't find a shoe that fits. I've been building sites with table sharing since 2009 on both D6 and D7, I know how it works and the problems involved with it.

  • Table prefixing is a somewhat advanced feature that you shouldn't be using if you don't understand the implications. Buyer beware.
  • Moving the user images into fields (#1292470: Convert user pictures to Image Field) would finally get rid of that core limitation that multisite systems run into, and then leave room for a contrib module for syncing the user profile images across multiple sites.
  • Other shared configuration data? If you're doing a multisite setup with shared users then you should also ensure the same architecture is implemented, e.g. text formats, fields, etc - exportables helps with this. Again, buyer beware.
  • The roles gets complicated, but workable. Again, sharing the roles table can work, but as role_permissions is dependent upon the specific modules in use and sharing the system table (a prerequisite for sharing role_permissions to avoid running into #1063204: Adding a new permission causes integrity constraint violation) opens up a huge can of worms.
  • Perhaps the documentation should be updated with more detail for specific use cases, or at least a disclaimer of "This has many implications, tread carefully"?

Again, removing this feature from Drupal the wrong way of approaching this problem.

damien tournoud’s picture

Title: Remove multi-site database table prefix sharing feature, it is a relict of the past » Stop promoting multi-site database table prefix sharing feature

I would agree that we should just remove all of this help text. Sharing tables between installations is an advanced (and mostly unsupported) use-case. It should not be documented in defaults.settings.php.

sun’s picture

Status: Active » Needs review
StatusFileSize
new2.13 KB

Hm. While not exactly the original goal, I can perfectly live with merely "deprecating" the feature by not exposing it to everyone anymore.

AFAICS, the only code lives in Connection::setPrefix() and surrounding functions, and has no real performance and complexity impact on sites using a single prefix only (see #561422: Replace strtr() with str_replace() for db prefixing).

quicksketch’s picture

I agree with both sides here. I've used shared tables on multiple projects (including my own latest site for Webform: http://webform.com), so I would definitely prefer it stay intact. That said, settings.php is a disaster of end-user documentation. Removing the database sharing information gets my full support. Another related issue to cleaning up settings.php is #1055862: Require sites.php to opt-in for multi-site support/functionality, which would nix the first 45 lines of irrelevant documentation (multi-site support) for 95% of sites.

cweagans’s picture

IMO, there's cleaner ways to share user accounts across sites. For instance, http://drupal.org/project/services_sso_client - it will even handle user profile pictures with media_internet.

Sharing a database table between installations seems like you're asking for trouble, because you're essentially joining the sites at the hip. If something happens, then *both* of your sites are completely hosed, whereas with a more decoupled approach, that might not be the case. I would much rather see the shared table functionality totally removed, but I can live with deprecating it. I guess.

sun’s picture

So, any objections to the patch in #6, or is it ready?

damienmckenna’s picture

How about rewording the example to focus on loading additional data from other sources, e.g. for use with entity API? So, rather than focusing on shared user data it could say:

 * @code
 *   'prefix' => array(
 *     // Load all Drupal tables from the normal database.
 *     'default'   => '',
 *     // Load this data from the legacy database.
 *     'hammers'   => 'legacy.',
 *     'spanners'  => 'legacy.',
 *   ),
 * @endcode
damienmckenna’s picture

Status: Needs review » Needs work
andypost’s picture

Stop promoting is ok. But not removing is no way. I know too much sites with shared tables so loosing this functionality will cause a this sites to move another CMS

sun’s picture

Status: Needs work » Needs review

re #10: Like @quicksketch, I don't think default.settings.php should contain docs for such advanced features. It's too confusing for users, and at the same time, too sparse to document possible pitfalls.

damienmckenna’s picture

@sun: How about providing a link to a docs page on d.o for full documentation on how to configure it?

marcingy’s picture

I agree this shouldn't be removed it is a very very useful tool in a dev environment where the size of the db makes it impossible for each dev to have there own copy of it - but not making it common knowledge works in my book. (and Drupal has lots of those undocumented settings!)

sukr_s’s picture

I won't vote for removing the shared tables. this is a killer feature and removing this will kill many usage scenarions. User's picture can easily be shared by overriding the user_picture theme. see http://www.drupalfx.com/content/sharing-user-picture-across-multiple-dru...

lpalgarvio’s picture

i agree with #10 and #14.
either reword it, or place a link to docs

"For advanced mult-site functionality, please read the article at http:/xxxxxxxxxx"

moshe weitzman’s picture

Proposed patch looks fine to me. I don't think we need to discuss table loading from an external DB either. Thats what the array of database connections is for (usually).

sun’s picture

#6: drupal8.settings-prefixes.6.patch queued for re-testing.

chx’s picture

Title: Stop promoting multi-site database table prefix sharing feature » Clean up default.settings.php

Despite #1055862: Require sites.php to opt-in for multi-site support/functionality is in, we still carry the multisite baggage in defaults.settings.php

jibran’s picture

Status: Needs review » Needs work

The last submitted patch, 6: drupal8.settings-prefixes.6.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#2551549: Deprecate per-table prefixing

It looks like that was overtaken by [#551549], and further work is being done in #3106531: Notify in Status Report that per-table database prefixes are no longer supported, and will throw errors in Drupal 10.0. Closing this a duplicate.

If that is incorrect, set the status to Active and explain what needs to be done here. Thx