? Success

User tests: Successful: Unsuccessful:

avatar manchumahara
manchumahara
5 Jul 2016

Pull Request for Issue # .

Summary of Changes

Testing Instructions

situation: when you need use the site part com_content article model outside of com_content or calling model using 'ignore_request' => true

  1. include the model require_once JPATH_SITE . '/components/com_content/models/article.php';
  2. take instance of the model $articlemodel = JModelLegacy::getInstance('Article', 'ContentModel', array('ignore_request' => true));
    //see I used 'ignore_request' => true and in such case the param object stored in state in null or not an object.
  3. $articlemodel->setState('article.id', 1); //suppose I need info for article of id 1 (i hard coded it for testing)
  4. $article = $articlemodel->getItem(); //get the information

Error: php error " __clone method called on non-object in ...." for line $data->params = clone $this->getState('params'); as the param object is empty and can not be clone.

So the quick fix can be

//$data->params = clone $this->getState('params');
$tempparams = $this->getState('params');
if(is_object($tempparams)){
$data->params = clone $tempparams;
}
else{
$data->params = new Registry;
}

avatar manchumahara manchumahara - open - 5 Jul 2016
avatar manchumahara manchumahara - change - 5 Jul 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 5 Jul 2016
Labels Added: ?
avatar wojsmol
wojsmol - comment - 5 Jul 2016

@manchumahara Please see CS PR manchumahara#1

avatar manchumahara
manchumahara - comment - 6 Jul 2016

I have a query to experts. The issue I noted in this pull request same issue exists in another core model like site part single contact model, banner etc or if we look again. This is because extension developer like me try to use the core models without writing the sql query once again and can face same issue. I can send more pull request for same type issue in other core model,

avatar chrisdavenport
chrisdavenport - comment - 6 Jul 2016

I think it's reasonable to harden the code to cope with the possibility that params might be empty.

However, I think your code can be simplified to remove the else clause.

Also, please bear in mind that the core extension classes are NOT subject to our backwards-compatibility promise, so extending from them is something you should undertake only on the understanding that your code might break on a minor version upgrade, although the probability is very low for the remainder of the 3.x series.

avatar brianteeman brianteeman - change - 28 Jul 2016
Category Components
avatar mbabker
mbabker - comment - 21 May 2017

This PR needs to be synchronized to the current development branch to be tested/reviewed. Also, the commented out code should be removed.

avatar mbabker mbabker - change - 21 May 2017
Title
Update article.php
Ensure params is a Registry before cloning it
avatar mbabker mbabker - edited - 21 May 2017
avatar mbabker mbabker - change - 21 May 2017
Title
Update article.php
Ensure params is a Registry before cloning it
avatar joomla-cms-bot joomla-cms-bot - change - 21 May 2017
Category Components Front End com_content Components
avatar franz-wohlkoenig franz-wohlkoenig - change - 22 May 2017
The description was changed
Status Pending Information Required
avatar joomla-cms-bot joomla-cms-bot - edited - 22 May 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 27 May 2017

If this PR get no Response, it will be closed at 22th June 2017.

avatar manchumahara
manchumahara - comment - 27 May 2017

This PR is waiting from july 6, 2016 !
I don't know how can I resolve the conflict as the main branch code already changed after my PR. Either someone help on this or close this PR.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 27 May 2017

How to help @manchumahara to synchronize his PR?

avatar manchumahara
manchumahara - comment - 28 May 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 21 Jun 2017

ping @rdeutz as Release Leader 3.7 if he knows one who can help @manchumahara to synchronize.


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

avatar rdeutz
rdeutz - comment - 21 Jun 2017

This need a bit more, you are only checking is it is an object but the title says your check is if it is a registry. Closing because recreate a PR is easier

avatar rdeutz rdeutz - change - 21 Jun 2017
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2017-06-21 12:15:22
Closed_By rdeutz
avatar rdeutz rdeutz - close - 21 Jun 2017

Add a Comment

Login with GitHub to post a comment