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

Bug in Wordpress plugin Ultimate Member #278

Closed
JohnWDawson opened this issue May 18, 2018 · 9 comments
Closed

Bug in Wordpress plugin Ultimate Member #278

JohnWDawson opened this issue May 18, 2018 · 9 comments

Comments

@JohnWDawson
Copy link

JohnWDawson commented May 18, 2018

Bug found in the Ultimate Member plugin for Wordpress. Reported to Ultimate Member, but their team showed that bug not manifest in a native MySQL host, hence possibly related to use of SqlServer / ProjectNami. Bug visible in this screenshot; evidently cannot see page definitions:
um settings

@patrickebates
Copy link
Member

Do you have the PHP error log and/or the PN translation log file available?

@JohnWDawson
Copy link
Author

JohnWDawson commented May 18, 2018

Debug switched on, output here:
Debug.txt

@JohnWDawson
Copy link
Author

Sorry, what's the PN translation log?

@JohnWDawson
Copy link
Author

Can offer a little more; tried the (apparently) offending query in the debug log (above); seems to fail similarly when tried in SQL Server Management log, but is OK if double quotes are replaced by single quotes; related to SET QUOTED_IDENTIFIER { ON | OFF }? Could it be this simple?

@JohnWDawson
Copy link
Author

And finally; tested in SQL Server Management Studio
quoted_identifier on

@JohnWDawson
Copy link
Author

And with it off:
quoted_identifier off

@patrickebates
Copy link
Member

There are several things in SQL Server which break if this is left off, per
https://docs.microsoft.com/en-us/sql/t-sql/statements/set-quoted-identifier-transact-sql?view=sql-server-2017

I examined the translations, and seems that we have tightly controlled when double-quotes are replaced with single-quotes in order to prevent damaging post content. At the moment, I'm not settled on how we would catch this instance without causing more problems.

There is a simple fix for it by editing a line in the plugin itself. /includes/core/class-query.php, line 97. Simply swap all single-quotes and double-quotes on that line and it should work properly.

@patrickebates
Copy link
Member

Looking through the rest of that same file, the bigger question is why they aren't using WP_Query or get_posts like they do elsewhere. This query which is giving you trouble seems to be the exception to their coding standards.

@JohnWDawson
Copy link
Author

If single quotes are used for literals in SQL, which is the preferred practice, then it doesn't matter about QUOTED_IDENTIFIER, so this seems to be the way to go, so line 97 in class-query.php goes
from: 'SELECT * FROM '.$wpdb->posts.' WHERE post_type = "page" AND post_status = "publish" '
to: 'SELECT * FROM '.$wpdb->posts.' WHERE post_type = 'page' AND post_status = 'publish' '
so the SQL looks like: SELECT * FROM wp_posts WHERE post_type = 'page' and post_status = 'publish'
which works ...
Thanks for help; will pass onto UM

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