Merge pull request #38605 from fsamapoor/replace_strpos_calls_in_comments_app

Refactors "strpos" calls in /apps/comments
pull/39066/head
Côme Chilliet 2023-06-29 10:32:08 +07:00 committed by GitHub
commit fc3ac4d974
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

@ -182,7 +182,7 @@ class Provider implements IProvider {
}
$message = str_replace('@"' . $mention['id'] . '"', '{mention' . $mentionCount . '}', $message);
if (strpos($mention['id'], ' ') === false && strpos($mention['id'], 'guest/') !== 0) {
if (!str_contains($mention['id'], ' ') && !str_starts_with($mention['id'], 'guest/')) {
$message = str_replace('@' . $mention['id'], '{mention' . $mentionCount . '}', $message);
}

@ -118,7 +118,7 @@ class Notifier implements INotifier {
$node = $nodes[0];
$path = rtrim($node->getPath(), '/');
if (strpos($path, '/' . $notification->getUser() . '/files/') === 0) {
if (str_starts_with($path, '/' . $notification->getUser() . '/files/')) {
// Remove /user/files/...
$fullPath = $path;
[,,, $path] = explode('/', $fullPath, 4);
@ -182,7 +182,7 @@ class Notifier implements INotifier {
// index of the mentions of that type.
$mentionParameterId = 'mention-' . $mention['type'] . $mentionTypeCount[$mention['type']];
$message = str_replace('@"' . $mention['id'] . '"', '{' . $mentionParameterId . '}', $message);
if (strpos($mention['id'], ' ') === false && strpos($mention['id'], 'guest/') !== 0) {
if (!str_contains($mention['id'], ' ') && !str_starts_with($mention['id'], 'guest/')) {
$message = str_replace('@' . $mention['id'], '{' . $mentionParameterId . '}', $message);
}