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

Using Memberof with conditionals generates 500 error #13167

Closed
wandering213 opened this issue Nov 2, 2016 · 8 comments
Closed

Using Memberof with conditionals generates 500 error #13167

wandering213 opened this issue Nov 2, 2016 · 8 comments
Milestone

Comments

@wandering213
Copy link

wandering213 commented Nov 2, 2016

Summary

When I try to use conditionals to output if a user is a member of a group I get a 500 error. If I don't include 'then/else the error is gone.

Step to reproduce

[[!+modx.user.id:mo=`GroupName`:eq=`1`:then=`True`:else=`False`]]

Observed behavior

Generates a 500 server error

Expected behavior

I would expect it to output True or False

Environment

MODX version 2.5.1, nginx 1.11.5, mysql 5.7.16, Ubuntu 16.04

@pixelchutes
Copy link
Contributor

pixelchutes commented Nov 2, 2016

What happens if you remove the

:eq=`1`

?

@wandering213
Copy link
Author

That resolves the error.

@OptimusCrime
Copy link
Contributor

Without the eq statement, is the behavior still correct?

@wandering213
Copy link
Author

wandering213 commented Nov 2, 2016

Yes

@Jako
Copy link
Collaborator

Jako commented Nov 2, 2016

A conditional could not combined directly with the next conditional as far as I know. There has to be a some conjunction between like and: or or:. But the Internal Server Error is somehow a bug and should be removed.

@OptimusCrime
Copy link
Contributor

My thoughts exactly.

@OptimusCrime
Copy link
Contributor

Traced the bug down to lines like these: https://github.com/modxcms/revolution/blob/2.x/core/model/modx/filters/modoutputfilter.class.php#L145

Conditional arrays should be [1, '||', 1], [0, '&&', 1], and similar. Problem happens when they do not follow the format [value, operand, value, operand, value] and so on. In this case the array is [1, 1] (two true after each other), which fails the eval function.

I am going to submit a PR once I get a chance, but I think the approach would be to loop the array and make sure we have a int first and last, and alternating operands and ints between those.

@Mark-H
Copy link
Collaborator

Mark-H commented Jun 15, 2017

Fixed in 2.6, where by "fixed" I mean it now logs the error "Encountered incorrect use of output conditions" when you have an invalid tag, instead of failing with a fatal error.

@Mark-H Mark-H closed this as completed Jun 15, 2017
@Mark-H Mark-H added this to the v2.6.0 milestone Jun 15, 2017
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

No branches or pull requests

5 participants