Closed (outdated)
Project:
Domain
Version:
7.x-3.x-dev
Component:
Documentation
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
24 Jan 2011 at 16:56 UTC
Updated:
21 Oct 2017 at 16:27 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
agentrickardThis is a job for Domain CTools. That's what the module is for.
Comment #2
agentrickardOk, to really do this, we have a problem. {node_access} must have numeric keys in the gid column, so we can't get rid of those.
That means that the option is making {domain}.domain_id a foreign key to an exportable-sensitive table (or export value).
That's a pretty big architectural change in the core module.
On save / load of an exportable, the domain_id would be checked against this table and updated in {domain} as appropriate.
It would also encourage a wholesale switch from using $domain as an array to making it a real object.
Comment #3
agentrickardCould also convert domain_id to a UUID with an algorithm based on the subdomain string.
Comment #4
nonsieSure but why? What would be a possible use case?
Comment #5
damienmckenna@nonsie: exportable configurations?
Comment #6
jhedstromHaving recently completed a massive Domain Access project, I would say making these configurations exportable (even pieces at a time, starting with domain_conf), would ease future projects significantly.
Comment #7
quade commentedSolving the {node_access} gid issue seems easy enough, just by using the existing serial domain_id. However, when you import a collection of domains, how will we trigger a node_access rebuild (or is that even necessary, assuming no content belongs to the newly imported domains)?
I would suggest adding a new column for machine name. Perhaps base it off of subdomain (maybe use machine-name.js to autogenerate it and allow overrides), and make that the primary key. Then you can leave domain_id as an auto-incrementing integer used in node_access guid.
Aside from the {node_access} table and admin UI screens (like admin/structure/domain/edit/DOMAIN_ID), where is the domain_id used to uniquely identify or access the domain data?
Comment #8
agentrickardLots to unpack here.
1) Exportables are generally a Good Thing. Among other things, they can allow for scripted updates across servers (or different domains on different servers). They can also reduce some database calls if we bypass some of the current loading procedures.
2) domain_id is the foreign key for all joins to {domain}, plus the key for {node_access}.gid. In the core module suite, that includes 7 tables right now. And integers make better indexes than varchars, so I'd prefer to keep them that way. (Though I could be argued out of that position by a DBA.)
3) We actually don't need a {domain}.machine_name column, since {domain}.subdomain works just fine for that. (I've already tested it. {domain}.subdomain is a unique string containing legal characters.)
4) The problem, as I understand it, is the auto_increment on the serial {domain}.domain_id keys. We have to prevent those from incrementing (i.e. changing uncontrollably) when we do an import. I think there may be several ways around that issue, including a {domain_export} mapping table that stores subdomain and generates a domain_id that can be used to update the foreign keys in other tables. Or we could come up with a reliable UUID and use that for domain_id.
5) It hadn't occurred to me to start with Domain Conf, but that makes sense. Problem is, we have to solve the domain_id issue first or none of this will work.
Comment #9
agentrickardVery productive IRC chat with pounard, hejrocker, EclipseGC.
Given that UUID INTs are unreliable, the "best" solution may be an id mapping table "owned" by exportables that can update the domain_id key in other tables.
This solution is outlined in #2.
In essence, domain_id is always treated as a foreign key. The primary key is owned by the export.
Comment #10
nonsieMakes sense now that I have read through this thread again. However I'd try to split it into smaller manageable chunks. Every submodule should be able to define what its exportables are.
IMHO switching $domain to a real object should be discussed separately from exportables. Ideally we'd make this change for D7 version only keeping D6 sites and custom mods functional. Thoughts?
Comment #11
agentrickardThis is only going in to 7.x.3. The object discussion is separate, yes.
Right now I have sample loader code that takes hook_default_domain() data and injects it into hook_domain_bootstrap_lookup(), effectively letting domains in code overwrite domains in the db.
For the main module suite, I would want to make most things exportable. Right now, I'm just focused on domains and then aliases.
Comment #12
bforchhammer commentedAny progress on this topic? CTools exportables (and the resulting integration with the features module) would be awesome to have for a current project of mine...
Let me know if there's something I can do to help.
Comment #13
agentrickardWe should possibly start a new Git branch for this. I haven't had time to look at it recently.
Comment #14
bforchhammer commentedI'd like to work on this, but I have no experience with ctools and at the moment I'm still rather lost as of how to approach it. Any recommendations? Can anyone decompose this thing into smaller steps of what needs to be done?
I've played around a bit with this tutorial trying to create basic support for exportables (main "domain" records, not "domain conf"); the "export" part of it I kindof got working, but everything else not so much. ;-)
As for the discussion of converting $_domain into objects: could #1142558: domains as entities help to solve that issue?
Comment #15
agentrickardIt could, but I don't think domains need to be entities. Too much overhead and not enough reward.
The trick here (for CTools) is that we have to make a new table to store the numeric ID / machine name of the domains, since so many things (including {node_access} require numeric keys.
The other problem is that CTools really wants you to use it's own admin tools, and I just finished overhauling the admin UI for 7.x.3. So I don't really want to change that.
Comment #16
bforchhammer commentedOkay, here's a few issues I'm still wondering about...
1) Ctools exportables allow loading records from file/code; the domain module does some manual db-domain lookup stuff in a very early bootstrap phase (if I remember correctly from working on the domain aliases); is this compatible; i.e. does it work if there's domain information stored in code somewhere and we would need to load it that early during drupal bootstrap?
2) Which points in the domain module can I hook in to overload domain loading (and others); from the ctools perspective the easiest thing would be (I think), if I could more or less completely override the "load from db" part with the appropriate ctools api call. I don't think that's possible at the moment, is it?
Yeah, I was wondering about that as well. We basically have two options here I think:
a) separate export stuff completely into its own UI & use domain forms where possible; or
b) integrate "export status" (Default/Overriden) and additional controls (revert, export, ...) into the default domain list; can we still use parts of the ctools UI in this case?
Comment #17
agentrickard1) We'd have to alter that behavior to look for default domains first.
2) I don't quite understand.
3) I think we may end up with a separate 'export' interface.
Comment #18
stovak commentedKen:
I don't have anything to add to the Entities VS not entities debate, but, if i'm not mistaken, turning domains into entities automatically gives you features support in D7, right? And as the community seems to be coalescing around this Entity business, wouldn't that mean greater compatibility going forward?
Again, completely ignorant of the technical challenges one vs the other.
-tom
Comment #19
agentrickardSee #1142558: domains as entities for the discussion of domains as entities. Nutshell: I'm against it.
Comment #20
agentrickardThis will need to go in the main module, I think.
Here's a start of a patch. Needs lots of work. This could use some eyeballs, too.
All this first patch does is update the db schema to allow for exports from a 'machine_name' while still using numeric ids for the keys (which are required by {node_access}.
TODO
* Change the CRUD hooks and forms to the new schema.
* Integrate with CTools.
* Unknown.
Comment #21
agentrickardAnd a patch that keeps current tests passing! Hooray tests.
Comment #22
agentrickardMinor spin-off patch: #1207278: Allow default setting from domain form
Comment #23
agentrickardCurrent patch against head.
Comment #24
agentrickardOK, here's a patch that (at least) starts the capacity by allowing Bulk Export to export domain records.
There's still much to be done:
-- How to integrate into the existing CRUD UI?
-- How to load exported domain information?
-- How to load extra data (like aliases)?
My temptation is simply to use exported data to overwrite what's in the current database, but leave the rest of the functionality intact.
Input welcome.
Comment #25
agentrickardSo it occurred to me that we have to store 'machine_name' in both tables, since 'subdomain' is volatile (that is, subject to edits).
This version allows that. It also gets the Export UI partially working. We may end up with some custom handler code.
Comment #26
agentrickardSummary: I'm not crazy about CTools trying to take over the module CRUD interface. It's more than I want or need, especially since it makes numerous assumptions about data structure.
I am not inclined to rewrite everything to support CTools, so I wonder if we can implement a simple Import/Export routine that can be supported by Features directly?
And a quick poll, which behaviors are most important?
1) Exporting domain configuration from one site to another?
2) Bypassing the database by loading settings from code?
3) Knowing if individual domain records have been altered (overridden) from the exported version?
4) Other.
Comment #27
bforchhammer commentedThanks for the patch, agentrickard. I'm sorry I haven't been able to actively contribute to this issue... I am still very interested in finding a solution to the problem!
My primary use case is about managing the development-lifecycle; so the ideal solution from my point of view would be able to handle the following use case:
newdomain.dev.example.com,newdomain.staging.example.com,newdomain.example.com), set any related settings; possibly I also change settings for a different domain.example-domainsfeature, adding the new domain and updating any changes on existing domains.example-domainsfeature to my vc repository, and update respective feature on staging.This use-case is fairly high-level but I think the possibility to store and load domains and domain related settings from code is the central issue, i.e. your second point; in the end all three are important though...
Hope this helps!
Regards
Ben
Comment #28
agentrickardI think that is the exact use-case that people want. The question is, do we try to use CTools are go straight for Features exportables.
I tried CTools and am now interested in trying Features.
Comment #29
cweagansI'd say try to go with CTools. Reinventing the wheel is not really a good use of time, IMO. IIRC, Features will utilize CTools exportables where ever they are available, so making domains exportable with ctools kills two birds with one stone.
Comment #30
agentrickardMy problem is with the UI and data model that CTools wants to force on its exportables (overridden, disabled, etc.), It doesn't really fit what we need.
I also have 7.x.3 admin working exactly as I want and have NO desire to rewire the UI or move it all to a massive class handler because Ctools expects it.
Comment #31
agentrickardThat said, if _someone else_ submitted a patch for that behavior, I'd be thrilled.
But my initial review says that CTools doesn't quite fit if it's entirely up to me to do the work.
Comment #32
cweagansTh problem is, the overridden, disabled, etc. UI is what people are expecting with regards to exportables. There's already a precedent for that. Don't you think that consistency across all modules is a good idea?
As for implementation, I don't think that I'm in a position to do _all_ of it, but I'd certainly be interested in /helping/ with it.
Comment #33
agentrickardWell, the current patch is in position to implement the default CTools handling of states, so maybe take a swing at that integration.
Comment #34
agentrickardUpdated patch against 7.x-3.x.
I'll be honest, I have no clue what CTools is trying to do here. Someone else is going to have to either write this patch or pay for my time.
Comment #35
agentrickardIn regards to #32, no, actually. Exports of Fields and settings, for instance, don't follow that pattern. The problem we're facing is not the same as Panels / Views, but more akin to exporting configuration.
Given that a) domains are not object or entities (and likely won't be), and b) there is a TON of ancillary data (aliases, settings) that we may want to export as part of a domain definition, it looks like direct Features export support might be more fruitful.
The big problems to solve are:
-- How to export the data (in what format).
-- How to load the data (which is very tricky, given the bootstrap process).
-- How to tell if the data has been altered.
Comment #36
agentrickardYeah, I made more progress in one day using Features natively.
Some new decisions to make:
-- How to track domain status?
-- How to handle additional feature elements (like aliases)?
-- To export all domains or allow selection?
To test. Apply the patch and drop the file into the domain directory as
domain.features.incComment #37
agentrickardSlept on it for a night. I see a very basic battle plan that gets most people the ability to export / update from code using Features.
Instead of per-domain exports, I think we really want to export the entire data set, and offer the option to also export ancillary data:
-- Domains (export all domain records)
-- Domain configurations (export all Domain Conf values)
-- Domain aliases (export all Domain aliases)
-- Domain theme settings (export all Domain themes)
On activation of a Domain feature, the target database will be updated with the values from the feature. During normal operations, settings will _not_ be loaded from code, which makes bootstrap easier, since we don't have to change it.
This will, at least, allow the export / import / reset of domain configurations from site to site. It will also allow the creation of install profiles / feature packages.
As a side note, Domain Views will need to start using machine_name keys.
Comment #38
agentrickardI've been making steady progress on this, and the Features approach is "better" here because it gives more direct control over the output with less code refactoring.
Hope to have this wrapped up this week.
Comment #39
agentrickardHere's the current state. This is looking very good.
Features:
-- Export all or selected Domains to a Feature.
-- Export all or selected Aliases to a Feature.
-- Reload / reset Domains and Aliases from a Feature.
TODO:
-- Domain Conf
-- Domain Theme
-- Tests
To test, apply the patch and rename the new files properly (and put them in the right folders).
Note that the patch includes a database update.
Comment #40
stovak commentedis this in the DEV branch yet?
Comment #41
agentrickardNo. But I'm very tempted to commit so people can test. Let me take a last look.
Comment #42
agentrickardTests still pass. I'm going to commit what I have so people can poke at it.
Still needs tests for this functionality. Also needs eyeballs on:
-- What happens when exporting / importing to a new site that hasn't been configured.
-- How differences between source site and target site are reconciled (if they are).
-- Is the UI confusing?
Work-to-date committed.
Note that a database update is included.
Comment #43
agentrickardTagging.
Comment #44
StephenBrown commentedThis looks pretty awesome. Any chance you'll port it back to the 6.x branch? There is a project at work to separate out some of our Domain Access sites and this looks like it may be exactly what we're looking for, except we're still on Drupal 6.
Is there anything in particular that might break in 6? from what I can see, it looks fairly innocuous/universal, but I'd be happy to test it, poke and prod at it and give feedback for you.
Comment #45
StephenBrown commentedSorry, accidentally changed the Status back to "needs work". Fixing.
Comment #46
agentrickardThe big problem in D6 is the whole {domain_export} table. But the approach should still work.
I'd look at committing a patch, but don't intend to work on the D6 version at all. That branch is closed to new features.
Comment #47
StephenBrown commentedOk, I understand maintenance issues. I'm not sure why the {domain_export} table causes a problem, though, as you create it with the DB update. Could it be the requirement of changing the primary key on the {domain} table, and using machine_name?
In the meantime, I suppose I'll have to go about migrating the theme, configuration, and other content manually. Would your suggestion here: https://drupal.org/node/714540#comment-2601534 be applicable? It looks like that simply applies to nodes and users. Where else is the configuration for Domain Access domains held/how would I query that easily?
(It appears that my use case mainly involves point 1 of #26, as I really just need the configuration and theme, and associated nodes, users, roles, and permissions would probably be pulled out separately.)
The solution so far seems to be to use a either some combination of raw SQL dumping/filtering, Features and Node Export/Import, or a more complete solution such as YAMM, which of course I'll need to learn how to use effectively first. Luckily the first of our several Domain Access sites is not terribly complex, but there are a few others that have grown to be fairly large and important, so I want to find a way to do all of it right and without much error.
Apologies if this is sidetracking you, I can continue by posting on the other issue to keep topics separate, if this requires more detail than another post or two.
Comment #48
agentrickardSwitching the primary key could be problematic, but that's really just a "watch out for this" warning and not a barrier. I simply don't have time to backport the code to D6. But it should work.
Comment #49
agentrickardIt looks like the checks for "Overridden" are not coded correctly, since they don't check against the entries in the database.
Needs to be updated...
Comment #50
agentrickardBetter patch that fixes some errors and checks overridden status better.
Also makes the Rebuild functions destructive.
Likely to be committed unless someone objects.
Comment #51
agentrickardCommitted.
Still needs documentation.
Comment #52
simon georges commentedDoes this mean that, when using a feature to create the first domain on a platform, I try to revert that feature after people have used the website (and created several domains), every other domain will be destroyed, keeping only domains created by the feature (as it seems to be the case after trying on my setup) ?
It seems to me the behavior is different for other features component, as you can have content types living in features coexisting with content types living in the database, same for Views, Styles, Permissions or Variables.
Am I missing something ?
(Just to be clear, I disagree with the destructive rebuild, not the exportability of domains, which is just great ;-))
Comment #53
agentrickardYes, it does. That is (currently) the intended behavior.
I am, frankly, unclear on the concept of rebuild. Features documentation gives little or no guidance on the issue.
Here's my logic, which is still flexible at this point.
Attached is a screen shot (annotated) of a Feature that is "overridden".
Comment #54
agentrickardSo I think your scenario is looking at the situation backwards. Here's what I would expect:
I think this is more of a Features management problem than anything else.
Now, if there are automated processes that continually reset the Features on a site, that would be a problem. The solution (currently) would be to add step 3a) Disable the Feature to prevent rebuild.
But I'm not seeing anything in normal site operations that force-reverts domain features.
Comment #55
agentrickardOne last note of clarification:
A Domain feature is more like a Content Type export than anything else. If the Content Type changes, you either have to revert it or re-export it.
So it's not a case of "Content types in Features living side-by-side with native content types." It's more like "The Foo content type is defined in a Feature and has been altered. What would you like to do about it?"
Comment #56
simon georges commentedI understand your point of view.
The main reason is we indeed have automated upgrade procedures that perform "drush updb -y && drush fra -y", so the problem is raised there ;-)
As there is a workaround (not reverting this peculiar feature), it's indeed manageable... as long as we clearly isolate the domains in a dedicated feature (which is the case on our current setup, I'm just wondering if it is a desired behavior).
Thanks (as always) for your feedback on this anyway!
Comment #57
agentrickardWell, I'm open to debate here.
If people expect non-destructive Features, we should support that. But then how would you ever Revert the Feature to its base version?
We could, presumably, make it an option in the Feature export.
How do you handle Content Types in such a scenario? Are they locked down and never edited on live?
What I think you really need is better domain workflow tools, like those suggested in these two posts:
I'm to the point now that I load up all the domains on the dev side, and use some aliasing tricks to ensure that the domains work on all environments.
Comment #58
simon georges commentedYour last remark is probably one other option we should use, I don't think we're using aliases enough. I suppose every module as powerful as Domain Access should really be studied deeply to ensure using it properly and to the full extent of its power.
Actually, now that I think of it, the problem lies in the fact that we didn't define the default domain in a feature, but only the one we wanted to create after installation. Reverting the feature did destroy the default domain, so there were a lot of things that we weren't expecting. Putting the default domain in the feature too should make everything fine again.
Anyway, I think I can stop complaining, I have enough workarounds to have my setup working again. Thanks again for all the work you put into the module.
Comment #59
David Stosik commentedWell, there still is a problem, in my point of view. I work with Simon on the same project, and here is our use case :
- we produce for our client a Features based website, and have to produce only the default domain, and one other domain (we are producing a "website factory", and the first created website)
- so, our delivery process would consist in exporting both domains (defaut, and site 1) in a Feature, included in the whole package (this is OK)
- now, the website factory starts to live, and the client creates its own domains (or websites, in his words)
- but the product we delivered is still warrantied and maintained (by us !)
- now think of this : the client spots a bug on Domain Access configuration, or "site one" domain configuration and asks for a fix
Our process consists then in fixing the bug, exporting the feature again, send it to the client, and ask him to follow the update process which is reverting the delivered feature.
I am in no way able to provide a patch making Domain Access work the way I'd like to, but I wanted to share our use case, so that you can have a glance at it (and maybe suggest a better process ?).
Regards,
David
Comment #60
agentrickardThe trick in that case would be to enable the Domain feature, and then disable it.
From what you describe, though, I don't know that exporting domains to Features is feasible in your use-case.
You might be better off creating a small "feature" module that auto-creates the secondary domain on install -- assuming you are using install profiles or similar. Domain Access will create the primary domain on installation, and your small module could just create the second one.
But the way I would fix the client bug ATM is how we have to handle features for things like content types and changes to Views:
Personally, I think Features forces this workflow unless you lock down the live site -- which you can also do by not giving anyone the 'administer domains' permission.
Comment #61
joachim commentedI'm a bit late to the party, but I thought I should point out that using CTools for exportables is possible while still retaining your own admin UI: I did it over at http://drupal.org/project/clients.
Comment #62
agentrickard@joachim It was such a PITA that I gave up.
Comment #63
agentrickardDocumentation stub needs work here: http://drupal.org/node/1331868
Comment #64
agentrickardComment #65
agentrickard