? Success

User tests: Successful: Unsuccessful:

avatar alikon
alikon
6 Feb 2018

Pull Request for Issue #19547.

Summary of Changes

fix undefined offset when batch copy parent menu

Testing Instructions

see #19547
all batch copy work as before

Expected result

no notice in error.log

Actual result

PHP Notice: Undefined offset: 290 in \libraries\src\MVC\Model\AdminModel.php on line 284

avatar alikon alikon - open - 6 Feb 2018
avatar alikon alikon - change - 6 Feb 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 6 Feb 2018
Category Libraries
avatar alikon alikon - change - 6 Feb 2018
The description was changed
avatar alikon alikon - edited - 6 Feb 2018
avatar Quy
Quy - comment - 6 Feb 2018

I have tested this item successfully on 9bb1332


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

avatar Quy Quy - test_item - 6 Feb 2018 - Tested successfully
avatar sandewt
sandewt - comment - 7 Feb 2018

I have tested this item successfully on 9bb1332

PHP Version 7.1.9
Web Server Apache/2.4.27 (Win32) OpenSSL/1.0.2l PHP/7.1.9
WebServer to PHP Interface apache2handler
Joomla! Version Joomla! 3.8.5 Stable [ Amani ] 6-February-2018 15:00 GMT


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

avatar sandewt sandewt - test_item - 7 Feb 2018 - Tested successfully
avatar franz-wohlkoenig franz-wohlkoenig - change - 7 Feb 2018
Status Pending Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 7 Feb 2018

Ready to Commit after two successful tests.

avatar joomdonation
joomdonation - comment - 9 Feb 2018

This doesn't look like a right fix. The code which set the mapping between $old and $new is for $contexts variable (which is used later in the method) is remove in this PR.

Guess we need a better fix.

avatar sandewt
sandewt - comment - 9 Feb 2018

Well that you've found out.


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

avatar alikon
alikon - comment - 9 Feb 2018

@joomdonation Not sure to understand your concern
the $contexts should be the same input for batchTag, batchLanguage, batchAccess and batchCopy methods

avatar joomdonation
joomdonation - comment - 10 Feb 2018

@alikon If you look at this line https://github.com/joomla/joomla-cms/blob/staging/libraries/src/MVC/Model/AdminModel.php#L306 , you will see that $context parameter is used as parameter of a method call $this->$command

As your PR changes the existing value of $context variable (don't store the mapping between $new and $old in $context array anymore), I am worry that it might break something

avatar mbabker
mbabker - comment - 26 Feb 2018

Yeah I kind of agree, something seems off about this change (not sure what yet but just reading it it doesn't seem right).

avatar Quy
Quy - comment - 27 Feb 2018

The issue arises when copying the parent and not its children. The for loop accounts for the children even though they were not selected. So the following should fix the issue.

					foreach ($result as $old => $new)
					{
                                                if (isset($contexts[$old]))
                                                {
                                                    $contexts[$new] = $contexts[$old];
                                                }
					}

$pks:

array(1) {
  [0]=>
  int(238)
}

$contexts

array(1) {
  [238]=>
  string(18) "com_menus.item.238"
}

$result

array(3) {
  [238]=>
  int(506)
  [445]=>
  int(507)
  [446]=>
  int(508)
}
avatar alikon
alikon - comment - 27 Feb 2018

i'm still not convinced that we need that $old

avatar infograf768
infograf768 - comment - 1 Mar 2018

As all here do not agree on the code, better take off the RTC?

avatar Quy Quy - change - 31 Mar 2018
Status Ready to Commit Pending
avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Apr 2019
Title
[AdminModel] - fix undefined offset when batch copy parent menu
fix undefined offset when batch copy parent menu
avatar franz-wohlkoenig franz-wohlkoenig - edited - 19 Apr 2019
avatar alikon alikon - change - 3 Aug 2019
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2019-08-03 10:10:09
Closed_By alikon
Labels Removed: J3 Issue
avatar alikon alikon - close - 3 Aug 2019

Add a Comment

Login with GitHub to post a comment