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
Update Subs-Db-mysql.php #4065
Update Subs-Db-mysql.php #4065
Conversation
- any modification or future SMF update that includes additions/changes for where clauses contained within the $user_info array (using the query_ prefix) will be included using this method. - Imo this should also be applied to the SMF 2.0.15 update Signed-off-by: Underdog-01 <github.underdog@gmail.com> Author: Underdog <github.underdog@gmail.com> Date: Mon May 22 21:24:25 2017 -0400 On branch patch-22 Your branch is up-to-date with 'origin/patch-22'. Changes to be committed: modified: Sources/Subs-Db-mysql.php
Any reason why not the Subs-Db-postgresql is touched? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that this is a very helpful change. At the very least, strpos() should be used rather than preg_grep(). But moreover, since we already know the only two permitted values, the current method of doing strict equality tests and returning immediately on success is the most efficient approach possible.
Sources/Subs-Db-mysql.php
Outdated
|
||
if ($matches[1] === 'query_wanna_see_board') | ||
return $user_info['query_wanna_see_board']; | ||
$user_queries = array_values(preg_grep('/^query_/', array_keys($user_info))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to use a regex here. It'd be much more efficient to use strpos() in this case.
Can you give an example, @Underdog-01, of how a mod would want to use this change? What sort of "query_*" WHERE clause placeholder do you imagine a mod would want to add? |
I can give an example from SimpleDesk, where we do use a query_see_ticket. To accomplish our needs we use a wrapper around queries that make use of it. Although I myself am not sure of this implantation being the correct method of doing so.
|
I have had to manually edit popular mods due to the change. SMF itself uses the $user_info array to pass info for db queries in this fashion for quite some time now so it makes sense to me to allow dynamic usage for mod authors. |
Signed-off-by: Underdog-01 <github.underdog@gmail.com>
I keep missing an awnser of my question, |
- any modification or future SMF update that includes additions/changes for where clauses contained within the $user_info array (using the query_ prefix) will be included using this method. Signed-off-by: Underdog-01 <github.underdog@gmail.com>
@albertlast: done. |
Okay, that explanation makes sense. Just trim off the trailing whitespace after the closing |
Signed-off-by: Underdog-01 <github.underdog@gmail.com>
done. |
Signed-off-by: Underdog-01 <github.underdog@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM approval
Author: Underdog github.underdog@gmail.com
Date: Mon May 22 23:07:25 2017 -0400
On branch patch-22
Changes to be committed:
modified: Sources/Subs-Db-mysql.php
Signed-off-by: Underdog-01 github.underdog@gmail.com