← All changes
|
Inc/Core/Analytics/QueryBuilders/BaseQueryStrategy.php
+14
-9
3.1.7
→
3.1.14
View file →
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.7 Free | |
| 4 | + * @version 3.1.14 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <[email protected]> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | 8 | * @copyright Copyright © 2026 FirePlugins All Rights Reserved |
| @@ -42,10 +42,10 @@ | ||
| 42 | 42 | */ |
| 43 | 43 | public function getWherePeriod(): string |
| 44 | 44 | { |
| 45 | 45 | $options = $this->metric->getOptions(); |
| 46 | - | |
| 47 | - if (!$options['start_date'] ?? null || !$options['end_date'] ?? null) | |
| 46 | + | |
| 47 | + if (empty($options['start_date']) || empty($options['end_date'])) | |
| 48 | 48 | { |
| 49 | 49 | return ''; |
| 50 | 50 | } |
| 51 | 51 | |
| @@ -51,10 +51,10 @@ | ||
| 51 | 51 | |
| 52 | 52 | $dateColumn = $this->getDateColumn(); |
| 53 | 53 | $startDate = $options['start_date']; |
| 54 | 54 | $endDate = $options['end_date']; |
| 55 | - | |
| 56 | - return " AND {$dateColumn} BETWEEN '{$startDate}' AND '{$endDate}'"; | |
| 55 | + | |
| 56 | + return $this->metric->getWpdb()->prepare(" AND {$dateColumn} BETWEEN %s AND %s", $startDate, $endDate); | |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * Get the filters clause for the query |
| @@ -72,10 +72,15 @@ | ||
| 72 | 72 | // Build filters using the FilterBuilder with correct table aliases |
| 73 | 73 | $table_aliases = $this->getTableAliases(); |
| 74 | 74 | $filter_builder = new \FireBox\Core\Analytics\Filters\FilterBuilder([], $table_aliases); |
| 75 | 75 | $result = $filter_builder->build($filters); |
| 76 | - | |
| 77 | - return $result['sql']; | |
| 76 | + | |
| 77 | + if (empty($result['sql']) || empty($result['placeholders'])) | |
| 78 | + { | |
| 79 | + return $result['sql']; | |
| 80 | + } | |
| 81 | + | |
| 82 | + return $this->metric->getWpdb()->prepare($result['sql'], $result['placeholders']); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber | |
| 78 | 83 | } |
| 79 | 84 | |
| 80 | 85 | /** |
| 81 | 86 | * Get table aliases for FilterBuilder |
| @@ -120,9 +125,9 @@ | ||
| 120 | 125 | { |
| 121 | 126 | return ''; |
| 122 | 127 | } |
| 123 | 128 | |
| 124 | - return "LIMIT {$limit}"; | |
| 129 | + return $this->metric->getWpdb()->prepare("LIMIT %d", $limit); | |
| 125 | 130 | } |
| 126 | 131 | |
| 127 | 132 | /** |
| 128 | 133 | * Get the OFFSET clause |
| @@ -135,9 +140,9 @@ | ||
| 135 | 140 | { |
| 136 | 141 | return ''; |
| 137 | 142 | } |
| 138 | 143 | |
| 139 | - return "OFFSET {$offset}"; | |
| 144 | + return $this->metric->getWpdb()->prepare("OFFSET %d", $offset); | |
| 140 | 145 | } |
| 141 | 146 | |
| 142 | 147 | /** |
| 143 | 148 | * Default HAVING implementation - can be overridden |