Closed turf212 closed 2 years ago
This error is still in the latest version of the code although the code has been updated and is now different from the above.
In line 338 of lib.php it is fixed by changing the code to
if($where === '') { $where = 0; } else { $where = "( $where )"; }
Thanks @turf212 , I'm looking into this and testing. This seems to not have any negative impact and should make it in the next release. Thanks for sharing.
The SQL which is being generated looks like :
which is pulling but all of the matching u.ids which are the currently logging in user (id = 2) OR where the set of dN.data = or like matches. So when a user logs in and there is a large number of possible matches across a large number of courses the login time is increased significantly due to the observer re-enrolling everyone into the courses again.
Changing the SQL to encapsulate all of the OR requirements within brackets like :
where the dN.data checks are within the one AND () statement fixes this issue.
I've updated the attrsyntax_tosql() function locally to include a check at the end :
works for logging in events. I've not tested any of the other sync methods (which I suspect may be broken with this anyway as there isn't any extra u.id = X constrictions although a quick test direct on MariaDB appeared to be OK).