Jump to content

SQL Error when using save + next


bbeer
 Share

Recommended Posts

We have a strange problem in PW 3.0.201 dev. When using the Button save + next we get following error.

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') GROUP BY pages.id ORDER BY pages.sort' at line 4
In /wire/core/PageFinder.php line 821

and 

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') GROUP BY pages.id ORDER BY pages.sort' at line 4
In /wire/core/WireDatabasePDO.php line 937

 

Link to comment
Share on other sites

  • 5 weeks later...
  • 2 weeks later...

I'm sorry but I have to open that topic again as it is even trickier. 

This Problem is user role specific. As Superuser, all works smooth, as soon as you have another role, you get this error.

Your help is much appreciated.

Link to comment
Share on other sites

  • 1 year later...

This seems to be a bug in the core that is still present in the current release (3.0.229, main branch) and has to do with the query generation for the next page. For superusers there is no problem because of PageFinder.php:2230 (getQueryAllowedTemplates()), superuser just skips the checks for allowed templates in the query completely:

16093559_Bildschirmfoto2024-03-25um15_03_44.thumb.png.7ee6741d92f3f824110f85a62f10bd5d.png

Comparing the database queries for the superusers with the one for other (logged in) users showed the error in the query.

Query for superuser: 

1819387920_Bildschirmfoto2024-03-25um13_18_08.thumb.png.c32b805dceaaf2023207ffde0a472db9.png

Query for other (logged in) user:

611641267_Bildschirmfoto2024-03-25um12_28_36.thumb.png.e06e51073d70fc74515227e6df730224.png

It is quite obvious that there is an error in the SQL syntax. 

The problem has to do with the number of templates that a user is allowed to edit. In this case, the user (editor, no superuser) is allowed to edit all templates (inheriting page-edit permissions from the homepage). As soon as I add a template that no user is allowed to even view, the „Save + Next“ action is working as expected and—obviously—the query changes and everything is working:

 304263044_Bildschirmfoto2024-03-25um15_18_49.thumb.png.0680a04f843dd4334d42e0df305f663a.png

Query for editor after adding a template that nobody (except superusers) can access:

507653477_Bildschirmfoto2024-03-25um15_22_55.thumb.png.5acdb9191169aef8f2bb956ee64b7a47.png

Maybe @ryan can have a look and dig a little deeper? This might be an edge case that almost never happens (because in most cases template access might be restricted for every role to some extend) and adding a template without access is a workaround, but it would be cool to have it fixed nonetheless.

Cheers
Flo

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...