FormIt
FormIt copied to clipboard
Update fihooks.class.php
when I add 10-20 snippet calls in emailTpl, only 3 or 5 first calls will be processed
with this patch you can use correctly more than 5 snippets calls in emailTpl
Thanks for this @Bournwog. Are there any specific tests that come to mind to make sure this doesn't introduce any new issues? I've got this merged into a testing branch over at the new repository location modxcms/FormIt https://github.com/modxcms/FormIt/commit/42f4808d83bc9246697dbae907ceb0695a7bc110
I know the parser a bit.. It seems to be a right thing :-) saw that stuff before :+1:
@Bournwog why not use $this->modx->parser instead of calling $this->modx->getParser() twice?
What if the parser isn't loaded (theoretical it can be possible)? I also agree, the getParser() should check that and only init a new instance when not already is loaded.. changed like:
public function getParser() {
$parserClass = $this->getOption('parser_class', null, 'modParser');
if(isset($this->parser) && is_object($this->parser) && $this->parser instanceof $parserClass) {
return $this->parser;
}
return $this->getService('parser', $parserClass, $this->getOption('parser_class_path', null, ''));
}
@bertoost i'm talking about this in the PR
// parse all cacheable tags first
$this->modx->getParser()->processElementTags('', $str, true, false, '[[', ']]', array(), 10);
// parse all non-cacheable and remove unprocessed tags
$this->modx->getParser()->processElementTags('', $str, true, true, '[[', ']]', array(), 10);
is there a problem with $this->modx->parser->processElementTags as it was before?
I think I copied this from a place somewhere else :-) Don't know exactly.. it's been a while
Also; when I look logical;
$this->modx->getParser();
$this->modx->parser->processElementTags('', $str, true, false, '[[', ']]', array(), 10);
$this->modx->parser->processElementTags('', $str, true, false, '[[', ']]', array(), 10);
Should be fine too..
i guess i don't understand the need to call $this->modx->getParser(); since it wasn't doing so before. is it to ensure the parser is loaded?
Yes indeed. As said.. Theorethical it's possible that it isn't loaded. Always good to call the load method. That said; I also think the getParser() method should be improved, to avoid double loadings
+1 on getParser() only getting an instance if not already loaded or a different parser class is specified