Skip to content

Commit

Permalink
Reduces code duplication by using Db::quote() in Db::query()
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
  • Loading branch information
Sesquipedalian committed Feb 2, 2025
1 parent 4960f80 commit 8ba051d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
9 changes: 2 additions & 7 deletions Sources/Db/APIs/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,9 @@ public function query(string $identifier, string $db_string, array $db_values =
}
}

// Inject the values passed to this function.
if (empty($db_values['security_override']) && (!empty($db_values) || str_contains($db_string, '{db_prefix}'))) {
$this->temp_values = $db_values;
$this->temp_connection = $connection;

// Inject the values passed to this function.
$db_string = preg_replace_callback('~{([a-z_]+)(?::([a-zA-Z0-9_-]+))?}~', [$this, 'replacement__callback'], $db_string);

unset($this->temp_values, $this->temp_connection);
$db_string = $this->quote($db_string, $db_values, $connection);
}

// First, we clean strings out of the query, reduce whitespace, lowercase, and trim - so we can check it over.
Expand Down
9 changes: 2 additions & 7 deletions Sources/Db/APIs/PostgreSQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,9 @@ public function query(string $identifier, string $db_string, array $db_values =
}
}

// Inject the values passed to this function.
if (empty($db_values['security_override']) && (!empty($db_values) || str_contains($db_string, '{db_prefix}'))) {
$this->temp_values = $db_values;
$this->temp_connection = $connection;

// Inject the values passed to this function.
$db_string = preg_replace_callback('~{([a-z_]+)(?::([a-zA-Z0-9_-]+))?}~', [$this, 'replacement__callback'], $db_string);

unset($this->temp_values, $this->temp_connection);
$db_string = $this->quote($db_string, $db_values, $connection);
}

// First, we clean strings out of the query, reduce whitespace, lowercase, and trim - so we can check it over.
Expand Down

0 comments on commit 8ba051d

Please sign in to comment.