Merge pull request #38606 from fsamapoor/replace_strpos_calls_in_settings_app

Refactors "strpos" calls in /apps/settings
This commit is contained in:
Daniel 2023-07-24 12:52:21 +02:00 committed by GitHub
commit 0411cc64aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View File

@ -300,7 +300,7 @@ class CheckSetupController extends Controller {
}
// 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/');
@ -391,7 +391,7 @@ class CheckSetupController extends Controller {
*/
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;
}
@ -592,7 +592,7 @@ Raw output
}
protected function isSqliteUsed() {
return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false;
return str_contains($this->config->getSystemValue('dbtype'), 'sqlite');
}
protected function isReadOnlyConfig(): bool {

View File

@ -83,7 +83,7 @@ class AppSearch implements IProvider {
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;
}

View File

@ -333,8 +333,8 @@ class PersonalInfo implements ISettings {
$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 = [

View File

@ -68,7 +68,7 @@ class SupportedDatabase {
$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;