calls to the ContentData function in 0.11.2

A place to discuss the testing process in beta cycles or against SVN for the CMS Made Simple CORE package.
Locked
Marek_PL

calls to the ContentData function in 0.11.2

Post by Marek_PL »

I am almost sure that what I describe below is a bug in the stable release 0.11.2.

visible effects of the bug:

If a module uses the ContentData function in a nontrivial way (making any changes to the parameter of the function) the results of the changes are visible if you press the "Preview" button in the "Edit Content" area, but they are not visible if you press the "View Site" button in the menu (or just view your site in a browser).

The bug:

The 491 line of the content.functions.php file is:

Code: Select all

$gCms->modules[$key]['object']->ContentData($content);
and should (probably) be:

Code: Select all

$gCms->modules[$key]['object']->ContentData($tpl_source);
i.e. the parameter to the ContentData function should be $tpl_source instead of $content.

Explanation:

The function ContentData (in the line 491) is called inside the definition of the function:

Code: Select all

content_get_template($tpl_name, &$tpl_source, &$smarty_obj)
Inside this definition the $content variable or parameter is not defined in any way. It is not a parameter to the content_get_template function and it is not defined or initialized inside the content_get_template function. So it is just a local variable, not used before or after the call to ContentData. Effectively the call to ContentData does nothing.

After fixing the probably-bug:

My problems with implementing a module filtering the content of a page are gone. Now everything works fine.

Marek
Marek_PL

Re: calls to the ContentData function in 0.11.2

Post by Marek_PL »

Patricia wrote:I will report that to the dev team, and see if this modification is necessary, or if a modification in the module you tried was necessary...
Thank you, Patricia. :)

I do not know the inner construction of CMSMS, I don't know all the functions, what do they do etc. But from my knowledge of PHP it seems to be obvious, that if you have a function definition like:

Code: Select all

function ChangeParameter(&$parameter)
{
SomeFunction($argument);
}
then the function ChangeParameter does not change its parameter in any way...

And this was exactly the case of the definition of the function content_get_template in lib/content.functions.php.

:)
cyberman

Re: calls to the ContentData function in 0.11.2

Post by cyberman »

Hi Marek,
Marek_PL wrote: My problems with implementing a module filtering the content of a page are gone. Now everything works fine.
Is this module available for download?
Marek_PL

Re: calls to the ContentData function in 0.11.2

Post by Marek_PL »

Patricia wrote: this has been applied in Subversion (SVN) by Wishy on January 22nd. It will be in the next release.
Thanks for your input Marek_PL :)
Thank you, Patricia, for your assistance with reporting the bug. And thanks to Wishy for applying the change.

I am happy I could be helpful.

:)
Marek_PL

Re: calls to the ContentData function in 0.11.2

Post by Marek_PL »

Marek_PL wrote: My problems with implementing a module filtering the content of a page are gone. Now everything works fine.
cyberman wrote: Is this module available for download?
Hi Cyberman,

No, the module is not ready, yet. I am still making experiments with the construction of the module.

When I said "everything works fine" I meant, there are no problems with connecting (the experimental version of) the module to the CMS.

It is relatively easy to write a module that will apply one particular filtering function to the input text. However it is not that easy to implement a configurable filtering module. But this discussion probably does not belong to this quality assurance subforum.

Marek
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: calls to the ContentData function in 0.11.2

Post by Ted »

Just as a follow up, ContentData will go away, along with a few other callbacks in 0.12-beta2.  The changes are documented here: http://forum.cmsmadesimple.org/index.ph ... 088.0.html
Locked

Return to “[locked] Quality Assurance”