Skip to content

Commit

Permalink
Merge pull request #38606 from fsamapoor/replace_strpos_calls_in_sett…
Browse files Browse the repository at this point in the history
…ings_app

Refactors "strpos" calls in /apps/settings
  • Loading branch information
kesselb authored Jul 24, 2023
2 parents bef4053 + 8778f29 commit 0411cc6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions apps/settings/lib/Controller/CheckSetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ private function isUsedTlsLibOutdated() {
}

// Check if NSS and perform heuristic check
if (strpos($versionString, 'NSS/') === 0) {
if (str_starts_with($versionString, 'NSS/')) {
try {
$firstClient = $this->clientService->newClient();
$firstClient->get('https://nextcloud.com/');
Expand Down Expand Up @@ -391,7 +391,7 @@ private function isCorrectMemcachedPHPModuleInstalled() {
*/
private function isSettimelimitAvailable() {
if (function_exists('set_time_limit')
&& strpos(ini_get('disable_functions'), 'set_time_limit') === false) {
&& !str_contains(ini_get('disable_functions'), 'set_time_limit')) {
return true;
}

Expand Down Expand Up @@ -592,7 +592,7 @@ protected function hasMissingColumns(): array {
}

protected function isSqliteUsed() {
return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false;
return str_contains($this->config->getSystemValue('dbtype'), 'sqlite');
}

protected function isReadOnlyConfig(): bool {
Expand Down
2 changes: 1 addition & 1 deletion apps/settings/lib/Search/AppSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function search(IUser $user, ISearchQuery $query): SearchResult {
continue;
}

if (strpos($query->getRoute(), $entry['id'] . '.') === 0) {
if (str_starts_with($query->getRoute(), $entry['id'] . '.')) {
// Skip the current app, unlikely this is intended
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/settings/lib/Settings/Personal/PersonalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ private function getLocaleMap(IUser $user): array {
$userLocale = reset($userLocale);
}

$localesForLanguage = array_values(array_filter($localeCodes, fn ($localeCode) => strpos($localeCode['code'], $userLang) === 0));
$otherLocales = array_values(array_filter($localeCodes, fn ($localeCode) => strpos($localeCode['code'], $userLang) !== 0));
$localesForLanguage = array_values(array_filter($localeCodes, fn ($localeCode) => str_starts_with($localeCode['code'], $userLang)));
$otherLocales = array_values(array_filter($localeCodes, fn ($localeCode) => !str_starts_with($localeCode['code'], $userLang)));

if (!$userLocale) {
$userLocale = [
Expand Down
2 changes: 1 addition & 1 deletion apps/settings/lib/SetupChecks/SupportedDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function check() {
$row = $result->fetch();
$version = strtolower($row['Value']);

if (strpos($version, 'mariadb') !== false) {
if (str_contains($version, 'mariadb')) {
if (version_compare($version, '10.2', '<')) {
$this->description = $this->l10n->t('MariaDB version "%s" is used. Nextcloud 21 and higher do not support this version and require MariaDB 10.2 or higher.', $row['Value']);
return;
Expand Down

0 comments on commit 0411cc6

Please sign in to comment.