JParameter::render() - bug or feature??

This forum is for reporting bugs in Joomla!. Please don't report problems with extensions in here.
Forum rules
Forum Rules
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
User avatar
webamoeba
Joomla! Explorer
Joomla! Explorer
Posts: 433
Joined: Fri Sep 16, 2005 9:13 am
Contact:

JParameter::render() - bug or feature??

Post by webamoeba » Fri Jan 30, 2009 7:40 pm

Groups do not appear to be properly handled by the render method. However, changing it now could impact exsiting ectensions, including core extensions.

OK, to explain.

The get and set methods allow us to get and set parameters in a group. This works flawlessly. Now If I have two groups _default and advanced. To render the advanced parameters I use someting like this:

Code: Select all

echo $params->render("advanved", "advanved");
The rendering works. But if I have set the values for the parameters group in the advanced group, i.e. $params->set("aparam", "avalue", "advanced"), this data is not used! This is because it uses the _default groups data instead... Surely this shouldn't be happening??

The source of this porblem is actually in the getParams() method

Code: Select all

function getParams($name = 'params', $group = '_default')
	{
		if (!isset($this->_xml[$group])) {
			return false;
		}
		$results = array();
		foreach ($this->_xml[$group]->children() as $param)  {
			$results[] = $this->getParam($param, $name);
		}
		return $results;
	}
The line $results[] = $this->getParam($param, $name); should be $results[] = $this->getParam($param, $name, $group);

The same issue exists in the renderToArray() method which for some reaosn has reinvented the wheel and doesn't use the getParams() method as I would certainly argue it should.

Any thoughts???

Koichi
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Fri Apr 18, 2008 7:58 am

Re: JParameter::render() - bug or feature??

Post by Koichi » Tue Feb 03, 2009 5:56 pm

This is surely a bug, caused by a lack of attention.
To be fixed?

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: JParameter::render() - bug or feature??

Post by mcsmom » Fri Feb 06, 2009 3:56 am

Did you try fixing the spelling of advanced?
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

User avatar
webamoeba
Joomla! Explorer
Joomla! Explorer
Posts: 433
Joined: Fri Sep 16, 2005 9:13 am
Contact:

Re: JParameter::render() - bug or feature??

Post by webamoeba » Fri Feb 06, 2009 10:10 am

ha, lol.

no that has nothing to do with it!

It is defo always retrieveing from the default group. Hell if you check out the way in which parameters for articles in content component are handled it is actually relying on using the default group for its data. Look in the DB and you'll see advanced and _default params are all stored together (no [advanced] INI style grouping).

As already stated the issue is this

Code: Select all

$results[] = $this->getParam($param, $name);
shold be

Code: Select all

$results[] = $this->getParam($param, $name, $group);

delgardo
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Mon Feb 23, 2009 9:38 am

Re: JParameter::render() - bug or feature??

Post by delgardo » Mon Feb 23, 2009 1:39 pm

Is there any solution for this bug? I've got exactly the same problem with my new component.

User avatar
webamoeba
Joomla! Explorer
Joomla! Explorer
Posts: 433
Joined: Fri Sep 16, 2005 9:13 am
Contact:

Re: JParameter::render() - bug or feature??

Post by webamoeba » Mon Feb 23, 2009 1:59 pm

Hey delgardo,

No solution as far as I am aware... A hacky way of doing this would be to create a subclass of JParameter and overide the offending methods so that they deal correctly with the groupings, the errors themselves are actually quite minor, as shown in the previous posts.

Ideally this should of course be corrected in JParameter...

delgardo
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Mon Feb 23, 2009 9:38 am

Re: JParameter::render() - bug or feature??

Post by delgardo » Mon Feb 23, 2009 2:11 pm

Thanks for the reply. Do you have written a subclass, actually?

User avatar
webamoeba
Joomla! Explorer
Joomla! Explorer
Posts: 433
Joined: Fri Sep 16, 2005 9:13 am
Contact:

Re: JParameter::render() - bug or feature??

Post by webamoeba » Mon Feb 23, 2009 2:27 pm

fraid not, am still hoping that the problem will be fixed in Joomla!

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: JParameter::render() - bug or feature??

Post by mcsmom » Mon Feb 23, 2009 4:36 pm

amoeba,

Did you put this in the tracker? If you do and especially if you attach a proper patch I'm sure it will be looked at. At this stage there is always a question about if it is really a 1.6 issue, but let's see what they say.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

User avatar
webamoeba
Joomla! Explorer
Joomla! Explorer
Posts: 433
Joined: Fri Sep 16, 2005 9:13 am
Contact:

Re: JParameter::render() - bug or feature??

Post by webamoeba » Mon Feb 23, 2009 6:12 pm

thanks mcsmom,

I didn't know I could submit tracker items! Always assumed that was for J! devs only, shows how much I know ;) lol. Am really busy this week, but I'll try and build a patch next week and submit a tracker item. As you say, perhaps it should really be a 1.6 issue - especially because of the impact it will have on anything that relies heavily on JParameter groups to define parameters.

User avatar
webamoeba
Joomla! Explorer
Joomla! Explorer
Posts: 433
Joined: Fri Sep 16, 2005 9:13 am
Contact:

Re: JParameter::render() - bug or feature??

Post by webamoeba » Thu Mar 05, 2009 2:45 pm

Finally got round to submitting this

http://joomlacode.org/gf/project/joomla ... m_id=15366


Locked

Return to “Joomla! 1.5 Bug Reporting”