This is coming in response to #1337500: Restrict user to only set path on assigned domains, which needs domain_path_node_insert() to know an existing path's dpid so that drupal_write_record() can update only that record, rather than destroying all values and writing them new each time. This would be more congruent with path.module's handling of the same in core.
Unfortunately, I think this means the structure of the return array from domain_path_paths() needs to change. Instead of the following
$paths[$key][$nid][$domain_id] = 'alias as a string';
That value has to be an associative array or object:
$paths[$key][$nid][$domain_id] = array(
'dpid' => $dpid,
'source' => $source,
'alias' => $alias,
);
This also means corresponding changes to deal with the new structure wherever domain_path_paths() is called.
Comments
Comment #1
Les LimHere's a patch altering domain_path_paths() to return the full row from {domain_path} including dpid. Not actually using the API change for anything yet here.
EDIT: Note that this requires a cache clear.
Comment #2
Les LimThis one uses the API change to act on individual records within {domain_path} in domain_path_node_insert(). Existing table records will be updated rather than destroyed and created new.
By the way, the cache must be cleared after patching with either of these. The module will need an update function if this makes it in.
Comment #3
Les LimComment #3.0
Les Limminor clarifications
Comment #4
agentrickardMakes sense.
If you have any interest in co-maintaining this module, let me know.
Comment #5
grndlvl CreditAttribution: grndlvl commentedNo longer applies to 7.x-1.x since domain_path_paths was replaced in favor of domain_path_lookup_path.
I will be looking into this probably later today. We probably need a domain_path_load similar to path_load to accomplish this.
Comment #6
Les LimI like the parallelism with naming the function domain_path_load(), but it should probably be domain_path_path_load() to avoid confusion with hook_load().
I missed that there was new development in 7.x-1.x. Are you keeping snapshot releases off intentionally?
Comment #7
agentrickardHad been, but I'll activate them now.
Comment #8
agentrickardSnapshots are active. https://drupal.org/node/1027556
Comment #9
grndlvl CreditAttribution: grndlvl commentedRe domain_path_path_load(): Went ahead and used domain_path_load() anyways since it would not interfere with nodes hook_load() as we don't implement a node, and it is just cleaner.
Some new additions:
- domain_path_load
- domain_path_save
- domain_path_save_paths
- domain_path_delete
Comment #10
grndlvl CreditAttribution: grndlvl commented- Removing the delete out of domain_path_save and place back into the node submission.
- Automatically detecting the current domain id for domain_path_load when a domain id was not sepecified
Comment #11
grndlvl CreditAttribution: grndlvl commentedBueller?
Thinking about it more I will probably go ahead and change the load function's name, but that's simple enough I can do it after we get an initial review.
Comment #12
agentrickardNot crazy about the $conditions parameter's mutability. The rest seems fine.
Comment #13
grndlvl CreditAttribution: grndlvl commentedDoesn't work against latest dev.
Comment #14
grndlvl CreditAttribution: grndlvl commentedLast wasn't an error it was an issue w/ GlobalRedirect which we are currently looking into.
Re mutability:
This is because of the various ways a domain is looked up. This happens in Drupal's http://api.drupal.org/api/drupal/includes!path.inc/function/path_load/7. So I am inclined to want to leave it.
Unless I hear a response I will assume this is ok and commit.
Patch changes:
- rename domain_path_load to domain_path_path_load
- re-roll against dev
Comment #15
grndlvl CreditAttribution: grndlvl commentedComment #16
agentrickardreturn $foo
Really? That needs a real variable name. Otherwise I have no objections.Comment #17
grndlvl CreditAttribution: grndlvl commentedlol looks like some test code made in the patch :) yes I will def. remove that
Comment #18
grndlvl CreditAttribution: grndlvl commentedCommitted http://drupalcode.org/project/domain_path.git/commit/7ae9ace8002a83b881f...
Thanks guys.
Comment #19
grndlvl CreditAttribution: grndlvl commentedActually we should add tests for this.
Comment #20
grndlvl CreditAttribution: grndlvl commentedRequires patch from #1337500: Restrict user to only set path on assigned domains at comment 11.
Comment #20.0
grndlvl CreditAttribution: grndlvl commentedSpecify which function needs the API change