Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors "strpos" calls in /apps/settings #38606

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/settings/lib/Controller/CheckSetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,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 @@ -382,7 +382,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 @@ -566,7 +566,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
Loading