From 160f93186111a907a524ece12e5cfb16efdf365f Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 28 Dec 2019 11:15:57 +0000 Subject: [PATCH 1/2] Fix: Search for terms and posts is now possible again --- src/Module/Search/Index.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index 010f0a790..4327dd165 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -215,9 +215,10 @@ class Index extends BaseSearchModule */ private static function tryRedirectToProfile(BaseURL $baseURL, string $search) { - $isUrl = parse_url($search, PHP_URL_SCHEME) !== ''; - $isAddr = preg_match('/^@?([a-z0-9.-_]+@[a-z0-9.-_:]+)$/i', trim($search), $matches); + $isUrl = !empty(parse_url($search, PHP_URL_SCHEME)); + $isAddr = (bool)preg_match('/^@?([a-z0-9.-_]+@[a-z0-9.-_:]+)$/i', trim($search), $matches); + Logger::info('Search', ['url' => $isUrl, 'addr' => $isAddr]); if (!$isUrl && !$isAddr) { return; } @@ -225,7 +226,7 @@ class Index extends BaseSearchModule if ($isAddr) { $search = $matches[1]; } - + Logger::info('Search', ['term' => $search]); if (local_user()) { // User-specific contact URL/address search $contact_id = Contact::getIdForURL($search, local_user()); @@ -246,6 +247,7 @@ class Index extends BaseSearchModule } } + Logger::info('Search', ['cid' => $contact_id]); if (!empty($contact_id)) { $baseURL->redirect('contact/' . $contact_id); } From f281725a0996e099e4abca70cd4b79fac606ef34 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 28 Dec 2019 11:17:10 +0000 Subject: [PATCH 2/2] Remove test loggings --- src/Module/Search/Index.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index 4327dd165..23b134b45 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -218,7 +218,6 @@ class Index extends BaseSearchModule $isUrl = !empty(parse_url($search, PHP_URL_SCHEME)); $isAddr = (bool)preg_match('/^@?([a-z0-9.-_]+@[a-z0-9.-_:]+)$/i', trim($search), $matches); - Logger::info('Search', ['url' => $isUrl, 'addr' => $isAddr]); if (!$isUrl && !$isAddr) { return; } @@ -226,7 +225,7 @@ class Index extends BaseSearchModule if ($isAddr) { $search = $matches[1]; } - Logger::info('Search', ['term' => $search]); + if (local_user()) { // User-specific contact URL/address search $contact_id = Contact::getIdForURL($search, local_user()); @@ -247,7 +246,6 @@ class Index extends BaseSearchModule } } - Logger::info('Search', ['cid' => $contact_id]); if (!empty($contact_id)) { $baseURL->redirect('contact/' . $contact_id); }