Needs work
Project:
Chaos Tool Suite (ctools)
Version:
7.x-1.x-dev
Component:
Page Manager
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
24 Apr 2015 at 21:48 UTC
Updated:
1 Feb 2023 at 06:43 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #1
andypostComment #2
ndf commentedBranch on github: https://github.com/ndf4/ctools/tree/issue/2477637-MachineNameWhenCloning...
Note that I had to setup
$form_state['task_name']explicitly, because the default had an-instead of an underscore in task_name.Comment #3
ndf commentedAlso needed when "importing variants".
Comment #4
ndf commentedAdded functionality for machine-name in both Cloning and Importing handlers/variants.
Comment #5
ndf commentedComment #6
joelpittetThanks @ndf gave it a whirl and it works like a charm!
Comment #7
joelpittetWhoops, try this:
Clone a variant, change the machine name to anything else and the title to the same as another variant.
The new machine name is not saved and we get an integrity constraint error page:
Integrity constraint violation: 1062 Duplicate entry 'pm_existing_pages_user_login__test' for key 'name': INSERT INTO {page_manager_handlers} (name, task, subtask, handler, weight, conf) VALUESComment #8
ndf commentedHi Joel,
This is an updates patch that should resolve your issues.
The patch acts on:
- Variant Clone
- Variant Import
Behaviour Variant Clone:
- When using an existing machine_name, you get a validation error before saving. Message is something like "The machine-readable name is already in use. It must be unique."
Behaviour Variant Import:
- When using an existing machine_name + option 'Overwrite=FALSE', you get a validation error before saving. Message is something like "The machine-readable name is already in use. It must be unique."
- When using an existing machine_name + option 'Overwrite=TRUE', the existing variant will be deleted before saving the new variant. No errors.
- When using an non-existing machine_name + option 'Overwrite=FALSE', the new variant will be saved.
- When using an non-existing machine_name + option 'Overwrite=TRUE', the new variant will be saved.
Comment #9
ndf commentedAlso added solution for "The UUIDs of imported variant and relative panes are the same of original ones".
I added it here, because this functionality (create unique uuids) depends on having a machine-name.
Comment #10
ndf commentedComment #11
ndf commentedComment #12
ndf commentedComment #13
joelpittetStill getting this nice doozie:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'page_user_wishlist__panel' for key 'name': INSERT INTO {page_manager_handlers} (name, task, subtask, handler, weight, conf) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => page_user_wishlist__panel [:db_insert_placeholder_1] => page [:db_insert_placeholder_2] => user_wishlist [:db_insert_placeholder_3] => panel_context [:db_insert_placeholder_4] => 2 [:db_insert_placeholder_5] => a:11:{s:5:"title";s:5:"Panel";s:9:"no_blocks";i:0;s:8:"pipeline";s:8:"standard";s:22:"body_classes_to_remove";s:0:"";s:19:"body_classes_to_add";s:0:"";s:6:"css_id";s:0:"";s:3:"css";s:0:"";s:8:"contexts";a:0:{}s:13:"relationships";a:0:{}s:4:"name";s:5:"panel";s:3:"did";s:2:"98";} ) in drupal_write_record() (line 7316 of html/includes/common.inc).Maybe need some validation?
All I'm doing is cloning the variant and giving the title the same as the previous, and boom!
Thanks for covering off the UUID bit that should be nice for imports:)
Comment #14
ndf commentedThinks this needs tests and updates for panes without readable machine-name based on title.
This patch kinda depends on a panels-patch https://www.drupal.org/node/2253919#comment-9702919
And this part should take care the "save" operation
And without deleting it breaks.
Comment #15
ndf commentedHi Joel, validation was definitely necessary.
Multiple things have changed:
page_manager_handler_add_to_pagenow does not regenerate the$handler->namefrom the title. It is required now, and only _import_submit() and _clone_submit() are calling it. The main reason is that regeneration regex was different than formapi's machinename one. And I think it is redundant now.I have tested importing and cloning with new and existing machine-names and it looks quite good to me. The interface/UI is clear and consistent, the exported variants (in features) looks even better.
Note that the 're-generate' UUID's depends on patches:
- ctools: https://www.drupal.org/node/2449245
- panels: https://www.drupal.org/node/2253919
But the machine-name part does work without it.
Comment #16
ndf commentedOne task to go, if you create a new variant
Add variant, the machine-name set must be used.Currently a uuid is used.
Comment #17
ndf commentedNow also machine-names including validation for "Add new variant" operation.
Comment #18
ndf commentedhttps://www.drupal.org/node/2445203#comment-9948477 is just committed and touches same code for generating machine-name for a handler.
Comment #19
joelpittetTrim was wrapped around this in the security release.
Removed extra line break.
Comment #20
michelleThe patch applies but with a little "fuzz" so I re-diff'd it against the current 7.x-1.x code. I didn't make any other changes.
Before applying this patch, I cloned a variant and gave it the same name as the original. When I exported them to look at the code, the machine name of the clone was blank. After applying the patch, I can set the machine name both when cloning and importing to avoid that problem. Seems to be working good but leaving at "needs review" since I technically changed the patch, even if it's just updating it.
Comment #21
rivimeyThanks Michelle!
A quick review:
DCS:
- there are multiple cases of very long lines which should be wrapped or modified.
- the docblock comments have insufficient and occasionally confusing information, notably no @param or @return args.
Other
- the 'does-name-exist' code should be refactored into its own function. Before adding own function please check there isn't a suitable one elsewhere (see #18)
This docblock needs additional information. Are we validating a clone of something, validating that it might be possible to clone something, or something else.
Also needs @param, @return elements, and preferably an extended description.
Not keen on this key name: 'shoveoff'... wouldn't 'message' or similar be adequate?
Line too long.
What happens if $form_state['values'] is empty or unset? It would seem sensible to include:
if ('name' not empty) {
rest of function
}
I think we need to keep 'administrative' in the description.
Have we actually lost the 'auto assign' functionality now? If not, please don't remove that from the description either. If so, please ensure it is called-out in the upgrade documentation somewhere.
DCS: Suggest break line before "&&" and just before ") {" a the end of line.
DCS:
- Import "a" hander : any old handler? please be more specific.
- Needs @param, @return parts, extended description.
This code is (near) duplicate of code earlier (L1317..L1324) and later. Please refactor into a sub-function.
As earlier...
Language:
'if machine-name is different that import-code'
--> 'if the machine name is not "import-code".'
or perhaps:
--> 'if the machine name has changed since the code was imported.' ?
DCS: Line too long. Suggest two nested if's.
@param, @return, etc.
See earlier comments about 'validate'... what is this doing, and why have we got two functions with the same Summary-description and different function names?
Line too long
Use newly refactored 'name exists' code once more...
Sorry if this is a stupid Q but why is this code no longer needed?
Comment #22
joelpittetComment #23
joelpittetComment #24
joelpittet