← All changes
|
src/Subscriptions/Endpoints/ListSubscriptions.php
+2
-7
4.16.6.1
→
4.18.0
View file →
| @@ -217,8 +217,9 @@ | ||
| 217 | 217 | return $query->count(); |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | + * @since 4.18.0 Filter payment mode in WHERE instead of HAVING so the database can use indexes | |
| 221 | 222 | * @since 4.12.0 Add "status" where condition |
| 222 | 223 | * @since 4.11.0 fix search by donor name or email |
| 223 | 224 | * @since 2.24.0 Replace Query Builder with Subscriptions model |
| 224 | 225 | * @since 2.21.0 |
| @@ -235,10 +236,8 @@ | ||
| 235 | 236 | $campaignId = $this->request->get_param('campaignId'); |
| 236 | 237 | $testMode = $this->request->get_param('testMode'); |
| 237 | 238 | $status = $this->request->get_param('status'); |
| 238 | 239 | |
| 239 | - $hasWhereConditions = $search || $start || $end || $campaignId || $status; | |
| 240 | - | |
| 241 | 240 | if (!empty($status)) { |
| 242 | 241 | $query->whereIn('status', $status); |
| 243 | 242 | } else { |
| 244 | 243 | // Default behavior: exclude trashed subscriptions |
| @@ -285,13 +284,9 @@ | ||
| 285 | 284 | }); |
| 286 | 285 | }); |
| 287 | 286 | } |
| 288 | 287 | |
| 289 | - if ($hasWhereConditions) { | |
| 290 | - $query->having('payment_mode', '=', $testMode ? SubscriptionMode::TEST : SubscriptionMode::LIVE); | |
| 291 | - } else { | |
| 292 | - $query->where('payment_mode', $testMode ? SubscriptionMode::TEST : SubscriptionMode::LIVE); | |
| 293 | - } | |
| 288 | + $query->where('payment_mode', $testMode ? SubscriptionMode::TEST : SubscriptionMode::LIVE); | |
| 294 | 289 | |
| 295 | 290 | return $query; |
| 296 | 291 | } |
| 297 | 292 | } |