Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent error if $modx->resource is not set #84

Closed
wants to merge 1 commit into from

Conversation

BenceSzalai
Copy link

The ImagePlus snippet causes a FATAL ERROR if $modx->resource is not set, even if the &docid property is provided explicitly.

The snippet should only try to call $modx->resource->get('id') if the &docid property is NOT provided.

In normal circumstances this does not cause an issue, as $modx->resource->get('id') would succeed, but for example when the snippet is used from within a call to assets/components/migx/connector.php $modx->resource may be null, and in those cases $modx->resource->get('id') results in Fatal error: Uncaught Error: Call to a member function get() on null in line 27.

This is in fact a real issue when trying to use [[ImagePlus... in a MIGX a render chunk. For detailed analysis see here: Bruno17/MIGX#354

The ImagePlus snippet causes a FATAL ERROR if `$modx->resource` is not set, even if the &docid property is provided explicitly.

The snippet should only try to call `$modx->resource->get('id')` if the &docid property is NOT provided.

In normal circumstances this does not cause an issue, as `$modx->resource->get('id')` would succeed, but for example when the snippet is used from within a call to `assets/components/migx/connector.php` `$modx->resource` may be null, and in those cases `$modx->resource->get('id')` results in `Fatal error: Uncaught Error: Call to a member function get() on null` in line 27.

This is in fact a real issue when trying to use `[[ImagePlus...` in a MIGX a render chunk. For detailed analysis see here: Bruno17/MIGX#354
@Jako
Copy link
Owner

Jako commented Jan 4, 2020

Thanks for your bug report. I have fixed this it a bit different in fff9f0b.

@Jako Jako closed this Jan 4, 2020
@BenceSzalai
Copy link
Author

Smooth, Thanks!

@BenceSzalai BenceSzalai deleted the docid_fix branch January 4, 2020 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants