Closed BenceSzalai closed 3 years ago
Investigation goes on:
I've realised that when I have [[ImagePlus...
in renderchunktpl
the requests to assets/components/migx/connector.php
fail with 500 Internal Server Error.
From PHP side it gives me this:
Fatal error: Uncaught Error: Call to a member function get() on null in .../core/cache/includes/elements/modsnippet/11.include.cache.php:27 Stack trace: #0 .../core/model/modx/modscript.class.php(76): include() #1 .../core/model/modx/modparser.class.php(537): modScript->process(NULL) #2 .../core/components/pdotools/model/pdotools/pdoparser.class.php(273): modParser->processTag(Array, false) #3 .../core/model/modx/modparser.class.php(251): pdoParser->processTag(Array, false) #4 .../core/components/pdotools/model/pdotools/pdoparser.class.php(65): modParser->processElementTags('[[$?MIGX_id=`1`...', '[[ImagePlus? &v...', false, false, '[[', ']]', Array, 9) #5 .../core/model/modx/modchunk.class.php(123): pdoParser->processElementTags('[[$?MIGX_id=`1`...', '[[ImagePlus? &v...', false, false, '[[', ']]', Array, 10) #6 /home/webdev/publi in .../core/cache/includes/elements/modsnippet/11.include.cache.php on line 27
Where modsnippet/11.include.cache.php is the cached PHP of the ImagePlus
snippet.
So after all the issue is with this line:
$docid = $modx->getOption('docid', $scriptProperties, $modx->resource->get('id'), true);
Well one thing is that $modx->resource
is simply not defined when the connector is being processed. I'm not that familiar with the MODX system, to be able to tell if that would be even possible to be set at this point. If so, MIGX should make sure $modx->resource
is set to the correct resource when connector.php is being processed.
But the other question is why ImagePlus is even trying to do this?
$modx->resource
is not set, we must also provide the &docid property.get
on $modx->resource
, which indeed would fail.So the solution is:
[[ImagePlus...
$modx->resource
is docid is not provided.And in fact it'd be nice to wrap the $modx->resource
in a try
block to make failures more graceful.
So the workaround solution is to make sure to call ImagePlus snippet with at least two parameters:
[[ImagePlus? &docid=`[[*id]]` &value=`[[+image]]`]]
and replace line 27 in the ImagePlus snippet with this:
$docid = $modx->getOption('docid', $scriptProperties, '', true);
if ( '' === $docid ) {
if ( ! isset( $modx->resource ) ) {
$modx->log(xPDO::LOG_LEVEL_ERROR, 'Unable to determine the ID of the current resource.', '', 'Image+');
return 'Unable to determine the ID of the current resource.';
}
$docid = $modx->resource->get('id');
}
I'll try to submit that to the ImagePlus repo as well (https://github.com/Jako/ImagePlus/pull/84), but meanwhile I'll leave this issue open for MIGX too with the following note:
$modx->resource
when processing the calls from the manager interface to assets/components/migx/connector.php
.Closing this, since it seems to be solved now
I'm trying to manually render an ImagePlus TV in the MIGX grid. I know I could just use
ImagePlus.MIGX_Renderer
, but I'd like to control what to render based on other TVs, so I need to use a custom chunk. However the problem is that as soon as I call[[ImagePlus...
inside therenderchunktpl
MIGX produces number of issues:"clickaction":"switchOption"
)If I remove the
[[ImagePlus...
snippet call from therenderchunktpl
everything works fine, so I assume my configuration is OK otherwise.In the error log I see these related entries when I have the
[[ImagePlus...
included, but these are not there when I don't use the ImagePlus snippet call:In fact if I turn off
"extrahandlers":"this.handleColumnSwitch"
(which I have enabled to allow a checkbox to be changed from the grid, without opening the row in the editor) the warnings from.../core/components/migx/processors/mgr/default/handlecolumnswitch.php
go away, but the issues remain...The
renderchunktpl
I'm trying to use is very simple for now:[[ImagePlus? &value=`[[+image]]`]]
I'd use a more complex one should I get this to working.Also: The issue is the same even if I hide the column with the custom render chunk using the ImagePlus snippet. So it doesn't matter if the column is shown or hidden. The only way to get MIGX to work is to remove any calls to ImagePlus snippet from the renderer chunk code.
More updates: I can see a sample code here: https://forums.modx.com/thread/80338/migx---new-feature-renderchunk?page=4#dis-post-485293 In this post the snippet to be used is not
[[ImagePlus...
but[[renderImagePlus...
however I don't see such snippet included with either MIGX or ImagePlus, so I've assumed it is just an old name for the same, but I' not sure.Similar case was reported here: https://forums.modx.com/thread/102772/nested-migx-with-imageplus-output-breaks-my-migx-table#dis-post-553607
AFAICS, this is a very similar experience whereas using
[[ImagePlus
inrenderchunktpl
resulted in issues.