484 Commits

Author SHA1 Message Date
Eloy Lafuente (stronk7)
c22b39a650 MDL-76617 store_mongodb: Update mongo-php-library to v1.15.0
This updates the library from v1.13.1. Fixes some php81 warnings
leading to failed/risky tests.

The new library version should work without problems with older
php-mongodb extension versions:
- v1.15.0 (paired version, tested).
- v1.14.1 (tested)
2022-12-22 19:36:40 +01:00
David Woloszyn
0be376fdc0 MDL-76183 lib: Update Github URLs 2022-12-01 08:59:05 +03:00
sam marshall
be11ee3383 MDL-76218 cachestore_redis: delete_many can fail with no keys
In some cases, we get an error message such as:

Wrong parameter count for Redis::zRem()

Within the delete_many function. This function requires at least one
key to be supplied, but if delete_many is called with an empty array,
we will call it with no keys.
2022-12-01 08:59:05 +03:00
Jun Pataleta
00bae8b8a4 MDL-76403 versions: bump all versions and requires near release 2022-11-23 09:45:23 +08:00
Jun Pataleta
5339a96f45 Merge branch 'MDL-75481-master' of https://github.com/kevpercy/moodle 2022-11-04 12:06:38 +03:00
Mark Johnson
67c7ed25e3 MDL-76076 cache: Add locking before write for parent caches 2022-10-31 13:55:54 +00:00
Mark Johnson
045ee091da MDL-67020 Cache: Make locking work for local file caches
* Add new requirelockingbeforewrite flag for cache definitions
* Implement native locking in cachestore_file (leveraging
file_lock_factory).
2022-10-20 11:31:33 +01:00
Mark Johnson
c06fc0648d MDL-67020 Cache: Release locks in cache_application::get_many() 2022-10-19 09:04:33 +01:00
Kevin Percy
25ad0a2cba MDL-75481 lib: Update MongoDB library references to 1.13.1 2022-10-17 11:58:05 +08:00
Kevin Percy
8ab37cea82 MDL-75481 lib: Updated MongoDB files to 1.13.1 2022-10-13 15:22:01 +08:00
Jun Pataleta
45a44ec0f0 Merge branch 'MDL-71531-master' of https://github.com/andrewnicols/moodle 2022-09-27 16:30:23 +08:00
Andrew Nicols
d51d901215 MDL-71531 cachestore_file: Stop locking cache files to read
The cache file is only ever written to in the `write_file` function,
where it does so by writing to a temp file and performing an atomic
rename of that file. When writing, the target file is never locked.

The cache file is only ever read in the `get` function, and there is no
need for an exclusive lock in that situation.

There is therefore no need to obtain any lock, shared or exclusive, to
read the cache file. Doing so only affects performance of the file sytem
as file locks must be needlessly obtained and written to disk for a read
operation which does not benefit from them.
2022-09-15 10:13:32 +08:00
sam marshall
4ab9f08ce0 MDL-75369 Redis: Remove unnecessary ping after connect
The Redis cache store and session handler both do a 'ping()' after
connecting to Redis. This is unnecessary because the connect() call
has just checked the network connection and it's hardly likely that
the server has gone down since then.

According to my profiling, both connect() and ping() take
measurable time when talking to a separate server, i.e. a few
milliseconds. So it's not the case that connect() doesn't really
talk to the server, as I initially wondered.

If using Redis on a separate (non-localhost) server for both session
and cache store, removing these ping calls can save a millisecond
or two per request.
2022-09-13 10:45:00 +01:00
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