? ? Pending

User tests: Successful: Unsuccessful:

avatar anmode
anmode
28 Mar 2022

Pull Request for Issue #37378

Summary of Changes

$pk is detected wrongly:

1.The controller sets $data['id'] explicitly to 0 if we're in a save2copy task.
2.Therefore $data['id'] is detected as empty in the model and $pk falls back to $this->getState('item.id') which is the id of the menu item to be copied.

Testing Instructions

  1. Create two menus, e.g. "menu 1" and "menu 2".
  2. Create a menu item in menu 1. Click Save.
  3. Edit the first menu item. Change the title and set the menu to the menu 2. Select "Save as Copy"

Actual result BEFORE applying this Pull Request

Both the first and its copy end up in menu 2.

Expected result AFTER applying this Pull Request

The first menu item should remain in menu 1 and the copy should be found in menu 2.

Documentation Changes Required

No Document.

avatar anmode anmode - open - 28 Mar 2022
avatar anmode anmode - change - 28 Mar 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 28 Mar 2022
Category Administration com_menus
avatar anmode anmode - change - 28 Mar 2022
Labels Added: ?
avatar chmst
chmst - comment - 29 Mar 2022

I have tested this item successfully on d27e6fe


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37395.

avatar chmst chmst - test_item - 29 Mar 2022 - Tested successfully
avatar richard67
richard67 - comment - 29 Mar 2022

@anmode I think your testing instructions are not complete. They cover only the test of the issue fixed by this PR. But the fix is made in the save method of the component's model, and this is used by any other kind of "Save", "Save & New", "Save & Close" or whatever may be available in frontend editing and in backend. It needs to test also if these are not broken with the change from this PR.

So I think you should add a final test step "Check that Save & Close, Save & New and Save as Copy in backend still work" or something like that.

avatar anmode
anmode - comment - 29 Mar 2022

@anmode I think your testing instructions are not complete. They cover only the test of the issue fixed by this PR. But the fix is made in the save method of the component's model, and this is used by any other kind of "Save", "Save & New", "Save & Close" or whatever may be available in frontend editing and in backend. It needs to test also if these are not broken with the change from this PR.

So I think you should add a final test step "Check that Save & Close, Save & New and Save as Copy in backend still work" or something like that.

Okay I got the point what you are trying to convey I will look into Save & Close, Save & New and Save as Copy too so this fix valid in those.
If any advice related to code. Please tell.

avatar richard67
richard67 - comment - 29 Mar 2022

If any advice related to code. Please tell.

@anmode See my answer in the above review comment #37395 (comment) :

I think you should do it like it is already done in the admin model: Just use isset($data['id']) instead of (!empty($data['id']) || $data['id'] === 0) like it is done here https://github.com/joomla/joomla-cms/blob/4.1-dev/libraries/src/MVC/Model/AdminModel.php#L1353 .

As said, with your current code it will fail when $data['id'] is not set.

avatar anmode
anmode - comment - 29 Mar 2022

If any advice related to code. Please tell.

@anmode See my answer in the above review comment #37395 (comment) :

I think you should do it like it is already done in the admin model: Just use isset($data['id']) instead of (!empty($data['id']) || $data['id'] === 0) like it is done here https://github.com/joomla/joomla-cms/blob/4.1-dev/libraries/src/MVC/Model/AdminModel.php#L1353 .

As said, with your current code it will fail when $data['id'] is not set.

Okay! I'll look into it.

avatar richard67
richard67 - comment - 29 Mar 2022

Okay! I'll look into it.

What does it need to look into? I've provided all necessary information already.

avatar anmode
anmode - comment - 29 Mar 2022

Okay! I'll look into it.

What does it need to look into? I've provided all necessary information already.
?just doing changes and pushing commit. Thanks :).

avatar vorayash
vorayash - comment - 30 Mar 2022

I have tested this change and working correctly on machine.

avatar richard67
richard67 - comment - 30 Mar 2022

@vorayash Could you mark your test result in the issue tracker by going to this page https://issues.joomla.org/tracker/joomla-cms/37395 , using the blue "Test this" button at the top left corner, selecting the test result ("Tested successfully" in this case) and then submit? Thanks in advance.

avatar vorayash
vorayash - comment - 30 Mar 2022

Ok sir.

avatar vorayash
vorayash - comment - 30 Mar 2022

I have tested this item successfully on e7c60bb


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37395.

avatar vorayash vorayash - test_item - 30 Mar 2022 - Tested successfully
avatar vorayash
vorayash - comment - 30 Mar 2022

I have tested this item   successfully on f7a966e


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37395.

avatar vorayash
vorayash - comment - 30 Mar 2022

I have tested this item   successfully on f7a966e


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37395.

avatar Quy
Quy - comment - 31 Mar 2022

I have tested this item successfully on e7c60bb


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37395.

avatar Quy Quy - test_item - 31 Mar 2022 - Tested successfully
avatar Quy Quy - change - 31 Mar 2022
Status Pending Ready to Commit
avatar Quy
Quy - comment - 31 Mar 2022

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37395.

avatar anmode anmode - change - 1 Apr 2022
Labels Added: ?
avatar Quy Quy - change - 2 Apr 2022
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2022-04-02 04:41:16
Closed_By Quy
avatar Quy Quy - close - 2 Apr 2022
avatar Quy Quy - merge - 2 Apr 2022
avatar Quy
Quy - comment - 2 Apr 2022

Thanks

Add a Comment

Login with GitHub to post a comment