Skip to content

Commit 2ccae7e

Browse files
committed
#11885 Simplify stage casting logic and ensure consistent case-folding in template search
1 parent 059d50c commit 2ccae7e

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

api/v1/editTaskTemplates/formRequests/TaskTemplateRequestTrait.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@ protected function getContextId(): int
2727

2828
protected function getStageIds(): array
2929
{
30-
$stages = Application::getApplicationStages();
31-
32-
return array_values(
33-
array_unique(
34-
array_map('intval', array_values((array) $stages))
35-
)
36-
);
30+
return Application::getApplicationStages();
3731
}
3832

3933
protected function userGroupIdsItemRules(int $contextId): array

classes/editorialTask/Template.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,17 @@ public function scopeFilterBySearch(Builder $query, string $phrase): Builder
245245

246246
$query->where(function (Builder $outer) use ($keywords, $settingsTable, $pk, $selfTable) {
247247
foreach ($keywords as $tok) {
248-
$like = '%' . str_replace(['%', '_'], ['\\%', '\\_'], mb_strtolower($tok, 'UTF-8')) . '%';
248+
$like = '%' . addcslashes($tok, '%_') . '%';
249249

250250
$outer->where(function (Builder $q) use ($like, $settingsTable, $pk, $selfTable) {
251-
$q->whereRaw('LOWER(title) LIKE ?', [$like])
252-
->orWhereRaw('LOWER(description) LIKE ?', [$like])
251+
$q->whereRaw('LOWER(title) LIKE LOWER(?)', [$like])
252+
->orWhereRaw('LOWER(description) LIKE LOWER(?)', [$like])
253253
->orWhereExists(function ($sub) use ($like, $settingsTable, $pk, $selfTable) {
254254
$sub->select(DB::raw(1))
255255
->from($settingsTable . ' as ets')
256256
->whereColumn("ets.$pk", "$selfTable.$pk")
257257
->whereIn('ets.setting_name', ['name', 'description'])
258-
->whereRaw('LOWER(ets.setting_value) LIKE ?', [$like]);
258+
->whereRaw('LOWER(ets.setting_value) LIKE LOWER(?)', [$like]);
259259
});
260260
});
261261
}

0 commit comments

Comments
 (0)