Modernized _real_escape() and Added safety checks to query() - #23
Open
lenasterg wants to merge 3 commits into
Open
Modernized _real_escape() and Added safety checks to query()#23lenasterg wants to merge 3 commits into
lenasterg wants to merge 3 commits into
Conversation
- Bug Fix: Added a safety check (is_object) on $this->result within the query handler to safely process non-result queries (such as BEGIN and COMMIT), preventing Fatal Error crashes on tables or environments where transactions are not supported or return boolean values. - Code Quality: Refactored the query() method to strictly comply with WordPress Coding Standards (WPCS).
### Bug Fix & Enhancements: Multi-DB Query Analysis for `SHOW CREATE TABLE` - **Fixed Database Routing for `SHOW CREATE TABLE` Queries:** Updated the `analyze_query()` method in the `m_wpdb` class to correctly parse and route queries that explicitly include database names and backticks (e.g., `SHOW CREATE TABLE \`db_name\`.\`table_name\``). - **Improved Regex Flexibility:** Enhanced pattern matching to seamlessly support table names with or without database prefixes, schema identifiers, and backticks.
- Add scalar validation using is_scalar() to handle non-scalar data safely. - Implement error handling with _doing_it_wrong() and fallback to addslashes(). - Integrate add_placeholder_escape() for modern WordPress SQL placeholders.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modernized _real_escape():
Robust query() Execution:
Code Quality & Formatting: Cleaned up code comments, spacing, and regex matching consistency across query analysis methods.