Environment
MODX Revolution 2.8.5
pdoTools 2.13.3 - this is relevant as the MODX parser is replaced by pdoParser
My Snippet [[get_superhero]]
uses a MIGXdb schema to query a custom database. It creates an array of output properties $arr_output_props
and calls getChunk
which contains relevant placeholder tags. Ultimately it runs phpThumbOf to create a thumbnail image and while the image is generated the the following error is logged
PHP warning: is_readable(): open_basedir restriction in effect. File(/assets/media/[[+img_src]]) is not within the allowed path(s)
[pThumb] Resource: 1 || Image: (none)
File not found: /home/server/webapps/dev/httpdocs/assets/media/[[+img_src]]
At the point of error the placeholder `[[+img_src]] has not been replaced with the actual image file path. I suspect this is caused by the parse order and my nested snippet calls.
However, as noted above, the image is generated despite the error, hence the process appears to run twice.
The relevant code from [[get_superhero]]
is
$arr_output_props['img_src'] = $obj_superhero->get('img_src');
// getChunk executes the parser (currently pdoParser) so the $tpl chunk can use output filters
$output .= $modx->getChunk($tpl, $arr_output_props);
return $output;
The relevant code from the $tpl
Chunk is
[[generate_grid_picture?
&src=`[[+img_src]]`
Here you can see the [[+img_src]]
is used by another snippet [[generate_grid_picture]]
. To debug I wrote the value of $src
to screen and it is correct.
The [[generate_grid_picture]]
Snippet is 400 lines and not well formatted so I’m not including it at the moment as I’m unsure it’s necessary.
I see @markh noted the following which seems relevant
Placeholders that are not yet available in a $modx->getChunk call will be returned as-is and rendered later. Depending on where the code runs and where [[++city]] comes from, that may or may not be available.
Stop Custom Snippet from Parsing Placeholders - #7 by markh
I can resolve the issue in two ways but neither is a proper solution
- update the
$tpl
Chunk to use the:default
output modifier
[[generate_grid_picture?
&src=`[[+img_src:default=``]]`
- or call
[[!generate_grid_picture? ...]]
uncached.
Can anyone suggest the next steps to find the proper solution or if it would help for me to post the full code please?
Thanks