471 Commits

Author SHA1 Message Date
Brendan Heywood
7f63314383 MDL-75375 cache: Fix file store path cleaning 2022-08-09 23:50:51 +08:00
Andrew Nicols
547cae0a02 MDL-74697 libraries: Update all third-party libraries with more metadata 2022-07-22 07:28:47 +02:00
Sujith Haridasan
73d604369d MDL-71062 core: Step 1 deprecation of print_error function 2022-07-13 08:20:54 +05:30
Eloy Lafuente (stronk7)
9f53b0e965 MDL-73971 phpunit: Move more tests to use correct names and namespaces
Applied the following changes to various testcase classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- Remove file phpdoc block
- Remove MOODLE_INTERNAL if not needed.
- Changed code to point to global scope when needed.
- Fix some relative paths and comments here and there.
- All them passing individually.
- Complete runs passing too.

Special mention to:

- Some fixtures, initially defined in the test files have been
  moved to new files in fixtures subdirectory, leaving the unit
  test files clearer:
  - moodle2_course_format_test.php
- Rename wrong named test:
  - baseoptiogroup_test = baseoptigroup_test
2022-05-06 18:29:11 +02:00
Jun Pataleta
70f6b1605b MDL-74471 versions: bump all versions and requires near release 2022-04-13 10:37:36 +08:00
Andrew Nicols
0098da8239 Merge branch 'MDL-74438-master' of https://github.com/cameron1729/moodle 2022-04-08 11:03:43 +08:00
Cameron Ball
8937de6f40 MDL-74438 cache: Check if cached value is boolean false 2022-04-06 17:14:52 +08:00
sam marshall
896d0c225a MDL-74285 cachestore_redis: Unable to delete a Redis cache instance
When deleting a cache instance, it tried to purge it, even though
purge only makes sense for an individual definition (not the whole
instance). As a result, it errored.
2022-04-01 17:40:41 +01:00
Sujith Haridasan
1bb972ae0a MDL-73848 administration: Add tests for breadcrumbs and nav highlights
This change includes addition of tests for verifying the secondary
and tertiary nav highlights.
It also includes the tests to verify the breadcrumbs for the pages.
2022-03-25 17:44:58 +08:00
Sujith Haridasan
aa1c2e2382 MDL-73848 administration: Fix the breadcrumbs and nav highlights
Create or update the breadcrumbs in the site administration
pages where it is required.
Highlight the corresponding site adminstration tab.
Highlight the primary nav to Site administration when user
is navigating to any of the site administration pages.

Also changed the boostnavbar so that the nodes in the secondary
navigation are not shown in the breadcrumbs when user is in site
administration page.
2022-03-25 17:44:47 +08:00
Andrew Nicols
459c37755b Merge branch 'MDL-74072_master' of https://github.com/TomoTsuyuki/moodle 2022-03-21 22:30:32 +08:00
Ilya Tregubov
cb0278a91f Merge branch 'MDL-74032-master' of https://github.com/sammarshallou/moodle 2022-03-11 09:23:17 +06:00
sam marshall
3776b5542f MDL-74032 core_cache: Coding error before upgrade with versioned cache
In certain cases where it doesn't already redirect to run the upgrade,
users could see an exception 'Unexpectedly found non-versioned cache
entry'. This change ensures the upgrade happens instead.
2022-03-09 12:11:14 +00:00
Eloy Lafuente (stronk7)
4003e31983 MDL-73785 phpunit: Move more tests to use correct names and namespaces
Applied the following changes to various testcase classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- Remove file phpdoc block
- Remove MOODLE_INTERNAL if not needed.
- Changed code to point to global scope when needed.
- Fix some relative paths and comments here and there.
- All them passing individually.
- Complete runs passing too.

Special mention to:

- When belonging to other components and being valid api:
  - analytics related tests have been moved to tests/analytics subdir.
  - backup & restore related tests have been moved to tests/backup subdir.
  - events related tests have been moved to tests/event subdir.
  - privacy related tests have been moved to tests/privacy.
  - task related tests have been moved to tests/task subdir.
- Some simple renames, not including the component part anymore (not
  needed now that they are namespaced):
  - some xxxlib_test.php have been renamed lib_test.php
    (when they where testing the corresponding lib.php).
  - cache stores tests have been all renamed store_test, originally
    each one had its own name (file_test, apcu_test, redis_test...)
  - assign feedback tests have been all renamed feedback_test, originally
    each one had its own name (file_test, editpdf_test...)
2022-03-03 12:19:30 +01:00
Tomo Tsuyuki
25a6a42477 MDL-74072 cachestore_redis: Add error check for envoy proxy 2022-03-03 17:16:52 +11:00
sam marshall
8a0f706033 MDL-72837 core_cache: Add versioned cache support
Adds new set_versioned and get_versioned APIs to cache, which means you can
request a specific version from cache and it will not return an outdated
version.

This is important when using multi-layer-caches where a local cache might have
an outdated version of the cache, but the shared cache has a current version.
With this feature, the content of the cache does not have to be rebuilt, as
it will automatically retrieve it from the shared cache if necessary.
2022-02-23 16:58:38 +00:00
sam marshall
97778526cc MDL-72837 core_cache: Remove duplicated code in cache_session
I checked using a diff tool and the difference between 'get' in cache
and cache_session is only:

a) cache_session: call to check_tracked_user at the start
b) cache: Includes code to use static acceleration (but this would
   not run anyway in cache_session because use_static_acceleration
   returns false)
c) cache: $setaftervalidation logic is used so that it sets it slightly
   later (I can't see how this would make any difference)
d) cache_session: uses functions eg get_store() instead of variables
   $store; those functions aren't overridden.

This seems like a ridiculous duplication of very complicated code, so
I'm going to remove the duplication before I change it.
2022-02-23 16:40:35 +00:00
sam marshall
691c5b8326 MDL-72837 core_cache: Rename unit test classes to new standard
For the three unit tests that are going to be modified in future
commit, I first changed them to use a namespace and class name
matching filename, as per current standard.
2022-02-23 16:36:40 +00:00
Helen Foster
7ff6b2daef MDL-73812 lang: Import fixed English strings (en_fix) 2022-02-18 15:50:26 +00:00
Jackson D'souza
18de3388f8 MDL-69088 cache: Make file cache store purge async 2022-02-03 10:30:09 +00:00
Eloy Lafuente (stronk7)
c11096576a Merge branch 'MDL-72619-master' of https://github.com/sammarshallou/moodle 2021-11-03 18:15:28 +01:00
sam marshall
9c29979b8b MDL-72596 core_cache: Track cache I/O size in perfdebug
For cache types which mean this information can be obtained without a
significant performance cost (i.e. just by calling strlen and not
having to serialize something that wasn't serialized already),
this change calculates the size of data read from or written to cache
in each request and includes it in the perfdebug table at bottom of
output (when that is turned on).

This supports the following cache types:

* File store
* Redis (only if caching is enabled)
2021-10-19 17:00:48 +01:00
sam marshall
1b94bb8c20 MDL-72619 core_cache: Provide admin page to view cache size estimates 2021-10-11 16:49:21 +01:00
sam marshall
b8291d04f4 MDL-72619 core_cache: Move renderer to namespace 2021-10-05 09:56:59 +01:00
sam marshall
8ddfa20121 MDL-72328 cachestore_redis: Add TTL support for Redis cache
A list of times for each cache key in a TTL cache is kept in a Redis
sorted list, which can be queried efficiently to delete expired
cache items later in a scheduled task.

This change makes set and delete 2x slower (only for caches which use
TTL) but there is no impact on get performance.
2021-09-21 13:43:11 +01:00
Andrew Nicols
4c6f22b4e5 Merge branch 'MDL-70233-alternative-disabled-cache' of https://github.com/Peterburnett/moodle 2021-06-22 15:46:48 +08:00
Eloy Lafuente (stronk7)
9d6aa39985 MDL-71583 versions: Add all the missing full-stops to version/requires
It seems that the new phpcs3 checker is now controlling those
line comments that previously were ignored.

This commit just looks for all the cases and bulk-add
them when needed. The bash script (mac) used to add all them is:

while read -r line; do
    arr=(${line//:/ })
    if [[ -n ${arr[0]} ]] && [[ -n ${arr[1]} ]]; then
        echo "  file ${arr[0]}, line ${arr[1]}"
        sed -i "${arr[1]}s/\$/\./" ${arr[0]}
    fi
done < <(find . -name version.php | xargs ag --nomultiline '>(version|requires) *=.*//.*[^;\.]$')
2021-05-11 20:11:07 +02:00
Peter Burnett
93c0dc8ec4 MDL-70233 cache: Disabled factory now gets writer from parent 2021-04-07 15:33:31 +10:00
Eloy Lafuente (stronk7)
e3a46964dc Merge branch 'MDL-70901-master' of git://github.com/marinaglancy/moodle 2021-03-18 00:40:46 +01:00
Eloy Lafuente (stronk7)
309a65a6f7 MDL-71036 phpunit: Renamed various file-related assertions
In PHPUnit 9.1, the following file-related assertions
have been deprecated and there are new alternatives for
all them:
- assertNotIsReadable()         -> assertIsNotReadable()
- assertNotIsWritable()         -> assertIsNotWritable()
- assertDirectoryNotExists()    -> assertDirectoryDoesNotExist()
- assertDirectoryNotIsReadable()-> assertDirectoryIsNotReadable()
- assertDirectoryNotIsWritable()-> assertDirectoryIsNotWritable()
- assertFileNotExists()         -> assertFileDoesNotExist()
- assertFileNotIsReadable()     -> assertFileIsNotReadable()
- assertFileNotIsWritable()     -> assertFileIsNotWritable()

This is about to, simply, move all cases to the new alternatives.

Source: https://github.com/sebastianbergmann/phpunit/blob/9.1.0/ChangeLog-9.1.md

Regexp to find all them:

ag 'assertNotIsReadable|assertNotIsWritable|assertDirectoryNotExists|\
assertDirectoryNotIsReadable|assertDirectoryNotIsWritable|\
assertFileNotExists|assertFileNotIsReadable|assertFileNotIsWritable'
2021-03-11 19:22:23 +01:00
Marina Glancy
2d059d1657 MDL-70901 cache: @ no longer masks errors in unlink in php 8 2021-02-22 16:17:49 +01:00
Brendan Heywood
05f138600b MDL-51111 cache: Don't lock and write the config file if unchanged 2021-02-11 11:04:50 +11:00
Ferran Recio
e161edc97a MDL-70309 libraries: upgrade mongodb integration files 2021-01-22 14:41:12 +01:00
Ferran Recio
4b948f8a50 MDL-70309 libraries: upgrade mongodb to version 1.8.0 2021-01-22 14:41:12 +01:00
Michael Aherne
2385ae7ee2 MDL-65941 cache: Prevent cache config failure on redis problems. 2020-11-11 14:33:22 +08:00
Andrew Nicols
b8bf6f9c42 MDL-70137 cache: Write config to temp file and move into place 2020-11-06 19:15:43 +00:00
Andrew Nicols
db8377b53e MDL-70137 cache: Use sensible default when reading MUC config
When we read the MUC configuration, a file which exists but is empty
will not error, but will cause all configuration to be empty.

We already perform an {{is_array()}} check on the {{$configuration}}
variable, but the default value for {{$configuration}} is an empty
array. In the case where the file exists, but is empty, no errors occur
when the file is loaded, and the initial {{$configuration}} value is
not overwritten, leading to the file being replaced with an empty copy.
2020-11-06 19:15:34 +00:00
Eloy Lafuente (stronk7)
3a5641cb74 MDL-67673 phpunit: Remove deprecated assertEquals() params
The optional parameters of assertEquals() and assertNotEquals()
are deprecated in PHPUnit 8 (to be removed in PHPUnit 9):

- delta => use assertEqualsWithDelta()
- canonicalize => use assertEqualsCanonicalizing()
- ignoreCase => use assertEqualsIgnoringCase
- maxDepth => removed without replacement.

More info @ https://github.com/sebastianbergmann/phpunit/issues/3341

Initial search done with:

ag 'assert(Not)?Equals\(.*,.*,' --php

Then, running tests and fixing remaining cases.
2020-10-21 12:46:00 +02:00
Eloy Lafuente (stronk7)
40de097e65 MDL-67673 phpunit: Remove deprecated assertContains() uses on strings
Both assertContains() and assertNotContains() are deprecated in PHPUnit 8
for operations on strings. Also the optional case parameter is. All uses
must be changed to one of:

- assertStringContainsString()
- assertStringContainsStringIgnoringCase()
- assertStringNotContainsString()
- assertStringNotContainsStringIgnoringCase()

More info: https://github.com/sebastianbergmann/phpunit/issues/3422

Regexp to find all uses:

ag 'assert(Not)?Contains\('
2020-10-21 12:46:00 +02:00
Eloy Lafuente (stronk7)
f94195c320 MDL-67673 phpunit: Remove deprecated assertInternalType()
While this is not strictly required, because removal will
happen in PHPUnit 9.0, we are already getting rid of all
uses in core.

From release notes:https://phpunit.de/announcements/phpunit-8.html

assertInternalType() is deprecated and will be removed in
PHPUnit 9. Refactor your test to use assertIsArray(), assertIsBool(),
assertIsFloat(), assertIsInt(), assertIsNumeric(), assertIsObject(),
assertIsResource(), assertIsString(), assertIsScalar(),
assertIsCallable(), or assertIsIterable() instead.
2020-10-21 12:45:59 +02:00
Eloy Lafuente (stronk7)
f6711bb394 MDL-67673 phpunit: Fix the return type of template methods
All the setup/teardown/pre/post/conditions template methods
now are required to return void. This was warned with phpunit 7
and now is enforced.

At the same time, fix a few wrong function names,
provider data and param types, return statements...
2020-10-21 12:45:59 +02:00
Peter Burnett
3d49421a21 MDL-68440 cache: Added counting of default mappings 2020-10-12 11:41:00 +10:00
Peter Burnett
ba9fc5ed57 MDL-41492 cache: Added ability for alternate cache config 2020-09-28 15:12:33 +10:00
Andrew Nicols
1c4b3ee262 MDL-42012 cache: Fix missing return value 2020-09-15 11:46:31 +08:00
Andrew Nicols
7f7df727c2 MDL-42012 cache: Valid definitions are required even when disabled 2020-09-09 14:04:17 +08:00
Andrew Nicols
d98bbcbbe6 MDL-42012 cache: Fully disable cache for disabled cache factory 2020-09-09 14:04:05 +08:00
Andrew Nicols
063c9ee94f MDL-42012 cache: Allow data sources to work when caching is disabled 2020-09-09 13:59:41 +08:00
Eloy Lafuente (stronk7)
9a79c34eb6 MDL-69479 upgrade: Change all 4.0 occurrences to 3.10
Under parallel development, when something is worth being commented
in upgrade.txt notes, it will be applied to all the development branches
using the "earliest" one to be released. So, if something changes
in 3.10 (and also is applied to master), the upgrade.txt notes will
show 3.10 in both branches.

Of course, if something only goes to one dev branch (say master), then the
master version will be used in the notes (4.0 in this case).
2020-08-21 23:57:17 +02:00
Eloy Lafuente (stronk7)
fbb0767536 MDL-69475 versions: bump all versions and requires in master
version = 2021052500 release version
requires= 2021052500 same than version

Why 20210525? (25th May 2021) ?

Because master is going to be Moodle 4.0, to be released
on November 2021. And, until then, we are going to have
a couple of "intermediate" releases:

- Moodle 3.10 to be released 9th November 2020. (2020110900)

  This version will be using versions from today to 2020110900
  (once it's released the YYYYMMDD part stops advancing).

- Moodle 3.11 to be released 10th May 2021. (2021051000)

  This version will be using versions from 3.10 release to 2021051000
  (once it's released the YYYYMMDD part stops advancing).

That means that all versions from today to 2021051000 are going
to be used by those 2 "intermediate" releases (3.10 and 3.11).

And we cannot use them in master, because it's forbidden to have
any overlapping of versions between branches (or different upgrade
paths will fail).

So, get that 2021051000, let's add it a couple of weeks to cover
the on-sync period (or a 2 weeks delay max!) and, the first version
that master can "own" in exclusive (without any overlap) is, exactly,
25th May 2021, hence our 20210525.
2020-08-18 00:47:15 +02:00
Mihail Geshoski
566b73fbfc MDL-67594 core_lock: Deprecate extend() 2020-07-06 13:04:33 +08:00