Closed Nikschavan closed 4 years ago
Hmm I'm not sure if this is the right approach. Is the filter naturally called higher up in the call stack that wpdb::query
? Wondering if we can capture the query at a different point. As it is, something that might hookquery
would erroneously see queries that are not actually sent to mysql for querying.
Is the filter naturally called higher up in the call stack that wpdb::query
I would say the filter is run just before the query is executed, Also AFAIK this is the last filter available before the query is executed.
So I am thinking any other queries will not get added to this filter which is not supposed to be executed?
Another solution to removing the placeholders would be to pass the query from remove_placeholder_escape()
But that will miss if any query is being modified using this query
filter.
Let me know what you think would be the right approach.
It looks like we could instead replace _do_query()
in this subclass, as that gets passed the query after placeholders etc have been replaced. I think that would be a better approach.
Right, that will work.
Also looking more into this, Looks like in the current query()
method, instead of the variable $query
we can use $this->last_query
which is already filtered and will have the final version of the query being executed.
I think I will prefer $this->last_query
as this does not need overriding a new method. Do let me know what you prefer and I will change the PR accordingly.
@joehoyle Let me know if you think using $this->last_query
would be good and I will update the PR accordingly.
@Nikschavan I'm suggesting we change our overriden mathed to _do_query
rather than overwriting a new one. I think $this->last_query
is less guerenteed, as it might be possible for that value to be something other than the query passed to query()
(e.g. future changed, or select found rows()
etc.
@joehoyle I have changed the PR, Instead of overriding query()
now I am overriding _do_query()
as it seems query()
was added to this class only to send the segment to X-Ray.
I think we should also port this to https://github.com/humanmade/altis-cloud/blob/master/inc/class-db.php
I have a PR on the altis-cloud repo which I will get updated with the new changes here - https://github.com/humanmade/altis-cloud/pull/235
Can you tag a release for hm-platform as well so that I can start using this fix in the project?
@Nikschavan 1.4.9 has been tagged 👍
See #183