User tests: Successful: Unsuccessful:
See #4702
When trying to Save and Copy a module, the new module does not get (copy) appended to the title (regression vs 2.5)
The issue comes from the change from var to input.
Here is a tentative patch, restoring the former behaviour.
Labels |
Added:
?
|
Sorry @infograf768. The code doesn't look right to me. The original code is supposed to work as below:
If you don't change the title before press "Save & Copy" button, the new module will be unpublished and title as " Copy" text appended.
If you change the title before press, the system will save the title of the module as how it is and leave it as published
To me, that's logical. However, with your propose code, actually $data['title'] == $orig_data['title'] is always return true, so title of the module is always changed and the module is always unpublished. To me, that's an unexpected behavior.
@joomdonation
Agree, this is wrong
The original error is in getting the id
PHP Notice: Undefined index: id in ROOT
/administrator/components/com_modules/models/module.php on line 935
Could you update that block of code with the following code:
if ($input->get('task') == 'save2copy')
{
$orig_table = clone $this->getTable();
$orig_table->load((int) $input->getInt('id'));
if ($data['title'] == $orig_table->title)
{
$data['title'] .= ' ' . JText::_('JGLOBAL_COPY');
$data['published'] = 0;
}
}
Testing
Although this now behaves as it does in 2.5, I don't think it is right.
What I expect when using save and copy is to save the original module with any modifications done and then copy it to a new instance with a (copy) in the title and unpublished if the new instance is not modified before save.
What we get —with both patches— is saving the original module as it was before modifications.
@infograf768 : The label of the button is "Save as Copy", not "Save & Copy" so I think it is working as it should. Maybe others have different ideas ?
LOL. you are right
I still think we should unpublish the copied module by default, what you think?
LOL. Then maybe you can update your PR with new code, then lets other tests it and get it merged :).
agree with @infograf768 - copied module should always be unpublished.
New tests needed
I am test save and copy module. module is copy config but save multiple times title not change. format "title module (copy)"
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4731.
I think if users change title before pressing Save & Copy, maybe they are ready to have the module published. If he doesn't want to publish, he can change published from Yes to No.
So I think just leave the state of the copied module as how users setup it. Otherwise, it might causes users an extra step.
Not sure how other users think about it.
Save as Copy unpublishes the item in all core
@infograf768 Yes, checked and confirmed. However, checking Save as Copy in Joomla core Articles component also showing that the title doesn't have ' Copy' appended. They also use title (2), title (3)...
if i need to save© a module, i first change the title and save it (save©) and then go on and make more changes.
i think the extra step is ok as you have another chance to check if all is correct.
also, if this is default core behaviour, it should be consistent.
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4731.
OK. So do we need to change the title of the copied module from Title (Copy) to Title (2), Title (3) ....to make the behavior consistent all in core ? Of use Title (Copy) is enough ?
Of just use Title (Copy), then you have a good test from me.
test works. if click 'save as copy' without renaming the title, the '(copy)' label is added to the end of the title of the dupplicated module.
if i change the title just before click on 'save as copy', the module title becomes the new title without the '(copy)' label.
great.
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4731.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-10-17 08:53:38 |
Thanks folks. Let's keep it as it was in 2.5.
OK. Then we are good. Thanks All :).
Test done with different types of modules. All will get appended 'copy' when saved as copy.
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4731.