Bug #2484
markers don't get replaced correctly
| Status: | Resolved | Start date: | 2009-01-20 | |
|---|---|---|---|---|
| Priority: | Should have | Due date: | ||
| Assignee: | Reinhard Führicht | % Done: | 0% |
|
| Category: | Misc | |||
| Target version: | - | |||
| Votes: | 0 |
Description
"USER"/"USER_INT" plugins are called through t3lib_div::callUserFunction() instead of $this->cObj->cObjGetSingle() which results in wrong parameters in the main function of the plugin.
This happens because the if clause for callUserFunction always evaluates to true. See patch
History
Updated by Reinhard Führicht over 4 years ago
- Category set to Misc
- Status changed from New to Needs Feedback
- Assignee set to Reinhard Führicht
I really don't understand what the if clause has to do with calling the user function using callUserFunction or cObjGetSingle.
I'm sorry, but could you explain this problem more detailed, please?
Updated by Joh. Feustel over 4 years ago
The code is part of the fillTypoScriptMarkers() method.
The if clause evaluates if the TS Object is NOT an "USER" or "USER_INT" object. In this case it calls callUserFunction otherwise cObjGetSingle.
The Problem is that the clause is always true. abstract: a!=b || a!=c
Could be false only if (b==c) which means: "USER" === "USER_INT" :-)
patch: !(a==b || a==c)
Since the TS marker is a plugin which is called through callUserFunction instead of cObjGetSingle some problems appear, particular concerning the parameters.
Updated by Reinhard Führicht about 4 years ago
The code looks like this:
if(!strcmp($options,"USER") || !strcmp($options,"USER_INT")) {
$this->settings['markers.'][$name.'.']['gp'] = $this->gp;
$markers['###'.$name.'###'] = t3lib_div::callUserFunction($this->settings['markers.'][$name.'.']['userFunc'],$this->settings['markers.'][$name.'.'],$this,"");
} else {
$markers['###'.$name.'###'] = $this->cObj->cObjGetSingle($this->settings['markers.'][$name],$this->settings['markers.'][$name.'.']);
}
The PHP function strcmp returns 0 if the two string are equal!
So it could be read like: if(a=='USER' || a=='USER_INT').
Thus, if the marker is a USER or a USER_INT object, callUserFunction() is called.
If the marker is a TEXT,HTML, ... object, cObjGetSingle() is called.
I think, this is the correct way to do this. Also passing he parameters to the user function should work, at least the documentation of t3lib_div states that a user function should be called this way.
Did you experience problems calling a user function?
Updated by Joh. Feustel about 4 years ago
ah, ok. Sorry, did't look at the return of strcmp. Allways was looking to get the USER object called via cObjGetSingle.
But: why do you make this differntiation? I use a USER object which throws a fatal error when called via callUserFunction. I think this is because of different parameter position of the conf in callUserFunction() and tslib_cObj.USER. btw in mailformplus all TS markers are called via cObjGetSingle.
Updated by Reinhard Führicht about 4 years ago
I have to admit, that I do not remember why this distinction is made. I think we changed to callUserFunction() in th_mailformplus too.
Anyway, since callUserFunction() seems to make troubles, I will replace it with cObjGetSingle() again and the problem is solved.
Updated by Reinhard Führicht about 4 years ago
- Status changed from Needs Feedback to Resolved
Tested and committed. Issue resolved.