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

Does the redirect not stop the parsing of templates? #4189

Open
shbchk opened this issue Apr 1, 2024 · 1 comment
Open

Does the redirect not stop the parsing of templates? #4189

shbchk opened this issue Apr 1, 2024 · 1 comment

Comments

@shbchk
Copy link

shbchk commented Apr 1, 2024

Just ran into this.

{if logged_out}
	{redirect="404"}
{/if}

{if !segment_3}
	{redirect="404"}
{/if}

{if logged_in}
	{exp:query sql="SELECT thing FROM table WHERE something = {segment_3}"}
		{thing}
	{/exp:query}
{/if}

So, when there is no {segment_3} or if I am logged out, EE should redirect me to 404, but instead I'm getting SQL syntax error.

@robinsowell
Copy link
Contributor

So it comes down to the parse order, and whether the variable is parsed before the tag. Segments are very early parsed, so that conditional check will run before the tags. The logged in/out aren't as early- but oddly, logged_in_member_id is parsed earlier, so you could use that and check against 0 for non-logged in.

It's not exactly a bug, but if we can parse the logged in globals that early, we could the logged_in/out ones.

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

2 participants