diff --git a/local_moodleappbehat/tests/behat/behat_app.php b/local_moodleappbehat/tests/behat/behat_app.php index 168bfa9d5..7a815ec17 100644 --- a/local_moodleappbehat/tests/behat/behat_app.php +++ b/local_moodleappbehat/tests/behat/behat_app.php @@ -19,6 +19,7 @@ require_once(__DIR__ . '/../../../../lib/behat/behat_base.php'); require_once(__DIR__ . '/behat_app_helper.php'); +use Behat\Behat\Hook\Scope\ScenarioScope; use Behat\Gherkin\Node\TableNode; use Behat\Mink\Exception\DriverException; use Behat\Mink\Exception\ExpectationException; @@ -45,6 +46,27 @@ class behat_app extends behat_app_helper { protected $windowsize = '360x720'; + /** + * @BeforeScenario + */ + public function before_scenario(ScenarioScope $scope) { + if (!$scope->getFeature()->hasTag('app')) { + return; + } + + global $CFG; + + $performanceLogs = $CFG->behat_profiles['default']['capabilities']['extra_capabilities']['goog:loggingPrefs']['performance'] ?? null; + + if ($performanceLogs !== 'ALL') { + return; + } + + // Enable DB Logging only for app tests with performance logs activated. + $this->getSession()->visit($this->get_app_url() . '/assets/env.json'); + $this->execute_script("document.cookie = 'MoodleAppDBLoggingEnabled=true;path=/';"); + } + /** * Opens the Moodle App in the browser and optionally logs in. * diff --git a/src/addons/mod/quiz/services/quiz-sync.ts b/src/addons/mod/quiz/services/quiz-sync.ts index 68568c798..e6f799dc8 100644 --- a/src/addons/mod/quiz/services/quiz-sync.ts +++ b/src/addons/mod/quiz/services/quiz-sync.ts @@ -15,7 +15,6 @@ import { Injectable } from '@angular/core'; import { CoreError } from '@classes/errors/error'; -import { CoreSite } from '@classes/site'; import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync'; import { CoreCourse, CoreCourseModuleBasicInfo } from '@features/course/services/course'; import { CoreCourseLogHelper } from '@features/course/services/log-helper'; @@ -314,7 +313,7 @@ export class AddonModQuizSyncProvider extends CoreCourseActivitySyncBaseProvider if (!CoreNetwork.isOnline()) { // Cannot sync in offline. - throw new CoreError(Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION })); + throw new CoreError(Translate.instant('core.cannotconnect')); } const offlineAttempt = offlineAttempts.pop()!; diff --git a/src/core/classes/site.ts b/src/core/classes/site.ts index 6b7fa7538..6fffa7b91 100644 --- a/src/core/classes/site.ts +++ b/src/core/classes/site.ts @@ -106,7 +106,8 @@ export class CoreSite { '3.10': 2020110900, '3.11': 2021051700, '4.0': 2022041900, - '4.1': 2022111100, // @todo [4.1] replace with right value when released. Using a tmp value to be able to test new things. + '4.1': 2022112800, + '4.2': 2023011300, // @todo [4.2] replace with right value when released. Using a tmp value to be able to test new things. }; // Possible cache update frequencies. @@ -806,7 +807,7 @@ export class CoreSite { ): Promise { if (preSets.forceOffline) { // Don't call the WS, just fail. - throw new CoreError(Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION })); + throw new CoreError(Translate.instant('core.cannotconnect')); } try { @@ -1694,7 +1695,7 @@ export class CoreSite { .catch(async () => { if (cachePreSets.forceOffline) { // Don't call the WS, just fail. - throw new CoreError(Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION })); + throw new CoreError(Translate.instant('core.cannotconnect')); } // Call the WS. diff --git a/src/core/features/login/pages/site/site.ts b/src/core/features/login/pages/site/site.ts index 4388745aa..7673fa6fc 100644 --- a/src/core/features/login/pages/site/site.ts +++ b/src/core/features/login/pages/site/site.ts @@ -45,7 +45,6 @@ import { CoreErrorInfoComponent } from '@components/error-info/error-info'; import { CoreUserSupportConfig } from '@features/user/classes/support/support-config'; import { CoreUserGuestSupportConfig } from '@features/user/classes/support/guest-support-config'; import { CoreLoginError } from '@classes/errors/loginerror'; -import { CoreSite } from '@classes/site'; /** * Site (url) chooser when adding a new site. @@ -420,7 +419,7 @@ export class CoreLoginSitePage implements OnInit { text: Translate.instant('core.contactsupport'), handler: () => CoreUserSupport.contact({ supportConfig: alertSupportConfig, - subject: Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }), + subject: Translate.instant('core.cannotconnect'), message: `Error: ${errorCode}\n\n${errorDetails}`, }), } @@ -435,11 +434,10 @@ export class CoreLoginSitePage implements OnInit { ), ].filter(button => !!button); - // @todo Remove CoreSite.MINIMUM_MOODLE_VERSION, not used on translations since 3.9.0. const alertElement = await CoreDomUtils.showAlertWithOptions({ header: errorTitle ?? ( siteExists - ? Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }) + ? Translate.instant('core.cannotconnect') : Translate.instant('core.sitenotfound') ), message: errorMessage ?? Translate.instant('core.sitenotfoundhelp'), diff --git a/src/core/services/db.ts b/src/core/services/db.ts index 036c8718c..87eefd519 100644 --- a/src/core/services/db.ts +++ b/src/core/services/db.ts @@ -18,7 +18,6 @@ import { SQLiteDB } from '@classes/sqlitedb'; import { SQLiteDBMock } from '@features/emulator/classes/sqlitedb'; import { CoreBrowser } from '@singletons/browser'; import { makeSingleton, SQLite } from '@singletons'; -import { CoreAppProvider } from './app'; import { CorePlatform } from '@services/platform'; const tableNameRegex = new RegExp([ @@ -47,7 +46,7 @@ export class CoreDbProvider { * @returns Whether queries should be logged. */ loggingEnabled(): boolean { - return CoreBrowser.hasDevelopmentSetting('DBLoggingEnabled') || CoreAppProvider.isAutomated(); + return CoreBrowser.hasDevelopmentSetting('DBLoggingEnabled'); } /** diff --git a/src/core/services/filepool.ts b/src/core/services/filepool.ts index 34a3627b9..1751636f0 100644 --- a/src/core/services/filepool.ts +++ b/src/core/services/filepool.ts @@ -55,7 +55,6 @@ import { lazyMap, LazyMap } from '../utils/lazy-map'; import { asyncInstance, AsyncInstance } from '../utils/async-instance'; import { CorePath } from '@singletons/path'; import { CorePromisedValue } from '@classes/promised-value'; -import { CoreSite } from '@classes/site'; /* * Factory for handling downloading files and retrieve downloaded files. @@ -510,7 +509,7 @@ export class CoreFilepoolProvider { } else { if (!CoreNetwork.isOnline()) { // Cannot check size in offline, stop. - throw new CoreError(Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION })); + throw new CoreError(Translate.instant('core.cannotconnect')); } size = await CoreWS.getRemoteFileSize(fileUrl); diff --git a/src/core/services/sites.ts b/src/core/services/sites.ts index 3550b6277..5a4b7bb3e 100644 --- a/src/core/services/sites.ts +++ b/src/core/services/sites.ts @@ -363,7 +363,7 @@ export class CoreSitesProvider { if (error instanceof CoreAjaxError || !('errorcode' in error)) { // The WS didn't return data, probably cannot connect. return new CoreLoginError({ - title: Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }), + title: Translate.instant('core.cannotconnect'), message: Translate.instant('core.siteunavailablehelp', { site: siteUrl }), errorcode: 'publicconfigfailed', errorDetails: error.message || '', @@ -374,7 +374,7 @@ export class CoreSitesProvider { // Service supported but an error happened. Return error. const options: CoreLoginErrorOptions = { critical: true, - title: Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }), + title: Translate.instant('core.cannotconnect'), message: Translate.instant('core.siteunavailablehelp', { site: siteUrl }), errorcode: error.errorcode, supportConfig: error.supportConfig, diff --git a/src/core/services/utils/dom.ts b/src/core/services/utils/dom.ts index 36a155f72..bca8e0701 100644 --- a/src/core/services/utils/dom.ts +++ b/src/core/services/utils/dom.ts @@ -57,7 +57,6 @@ import { CoreNetwork } from '@services/network'; import { CoreSiteError } from '@classes/errors/siteerror'; import { CoreUserSupport } from '@features/user/services/support'; import { CoreErrorInfoComponent } from '@components/error-info/error-info'; -import { CoreSite } from '@classes/site'; /* * "Utils" service with helper functions for UI, DOM elements and HTML code. @@ -1373,7 +1372,7 @@ export class CoreDomUtilsProvider { } else if (this.isSiteUnavailableError(message)) { alertOptions.header = CoreSites.isLoggedIn() ? Translate.instant('core.connectionlost') - : Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }); + : Translate.instant('core.cannotconnect'); } else { alertOptions.header = Translate.instant('core.error'); }