? Success

User tests: Successful: Unsuccessful:

avatar itbra
itbra
13 May 2016

Pull Request for Issue # .

Summary of Changes

When inheriting the model from within a custom component the inherited model FinderModelSearch when populating its state requires its components parameters. To fetch them it utilises JApplication::getParams(). However, if that model is inherited by a custom components model, which overrides populateState like so

protected function populateState($ordering = null, $direction = null)
{
   // Call parent for initial setup.
   parent::populateState($ordering, $direction);

   ...
}

then the context used by JApplication::getParams() is that of the custom component and the parameters returned are not those of com_finder. For that reason JApplication::getParams() must be passed the component name and correctly be JApplication::getParams('com_finder').

Testing Instructions

  1. From within any other component that is not com_finder create a model class that extends FinderModelSearch.
  2. In the inheriting model override populateState as described above.
  3. In your custom component create a view that inherits FinderViewSearch and override its display method the same way we override the model's populateState - just call parent::display($tpl) in there. This will call the parent view's display method where the model is called to return some data. That call will trigger the populateState method using the context of the custom component thus returning the wrong parameters.
  4. Create two menu items - one using com_finder's search view and another one using your component's search view, which inherits com_finder's view. Then open every view in the browser.
  5. In FinderModelSearch::populateState just var_dump() the parameters to see what is returned.
    Do it one time using the original code $params = $app->getParams().
    Then change the code to $params = $app->getParams('com_finder') and reload.
avatar itbra itbra - open - 13 May 2016
avatar itbra itbra - change - 13 May 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 13 May 2016
Labels Added: ?
avatar itbra itbra - change - 13 May 2016
The description was changed
avatar itbra itbra - change - 13 May 2016
The description was changed
avatar itbra itbra - change - 13 May 2016
The description was changed
avatar itbra itbra - change - 13 May 2016
The description was changed
avatar itbra itbra - change - 13 May 2016
The description was changed
avatar itbra itbra - change - 14 May 2016
The description was changed
avatar itbra itbra - change - 14 May 2016
The description was changed
avatar brianteeman brianteeman - change - 14 May 2016
Category Components
avatar mbabker
mbabker - comment - 21 May 2017

This could really use some tests...

avatar N6REJ
N6REJ - comment - 16 Aug 2017

could you provide sample test code please.. like perhaps a 'hello world' component?


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

avatar durubayram durubayram - test_item - 23 Jul 2018 - Tested successfully
avatar durubayram
durubayram - comment - 23 Jul 2018

I have tested this item successfully on 58ad25c


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

avatar priiish priiish - test_item - 24 Jul 2018 - Tested unsuccessfully
avatar priiish
priiish - comment - 24 Jul 2018

I have tested this item ? unsuccessfully on 58ad25c

# Testing steps

  • followed testing instructions (model in custom component, overridden both methods) => parameters from com_finder and custom component are not similar
  • it makes sense though, that your custom component's parameters are not the ones of the com_finder => if you wish them to be, passing them in JApplication::getParams('com_finder') is the right way
  • but please keep in mind, that this is not a bug

@icampus


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

avatar bembelimen
bembelimen - comment - 24 Jul 2018

I agree with @priiish I don't think, that's expected behavior, that you get com_finder params, when you're in your own extension. I expect "my" params.

If I want exactly the com_finder params, I could add the call in my extended populateState method.

Another side effect of this change would be, that we have to change all other models, too. Because if you extend from any core model class, you'll have the current behavior.

avatar Hackwar
Hackwar - comment - 26 Jul 2018

I have to side with @priiish and @bembelimen here.

avatar infograf768
infograf768 - comment - 26 Jul 2018

Closing as expected behavior.

avatar infograf768 infograf768 - change - 26 Jul 2018
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2018-07-26 09:00:00
Closed_By infograf768
avatar infograf768 infograf768 - close - 26 Jul 2018
avatar joomla-cms-bot joomla-cms-bot - change - 26 Jul 2018
Category Components Front End com_finder Components

Add a Comment

Login with GitHub to post a comment