497 Commits

Author SHA1 Message Date
sam marshall
a3b1e3b4ee MDL-76784 core_cache: versioned cache (modinfo) can fail in install
When cache is disabled but temporary in-memory caches are allowed,
these were direct instances of cachestore_static with no loader, which
meant that the get_versioned and set_versioned functions did not work.
2023-02-21 10:40:23 +00:00
Andrew Nicols
6d31626130 Merge branch 'MDL-76791-master' of https://github.com/sammarshallou/moodle 2023-02-16 10:53:25 +08:00
David Woloszyn
02418cc093 MDL-75454 cache: Reduced exposure of sesskey param 2023-02-14 11:25:49 +11:00
Andrew Nicols
7bf57d9850 MDL-77161 cachestore_memcached: Remove from core 2023-02-07 21:42:50 +08:00
sam marshall
3353aecc8b MDL-76791 core_cache: Locking breaks for multiple-identifiers store
Cache locking fails if the cache store supports multiple identifiers
(in core, the only two which do are cachestore_static and
cachestore_mongodb, so this is unlikely to cause severe problems).
2023-02-06 15:46:17 +00:00
Marina Glancy
b0a83aa7bd MDL-76362 various: Avoid passing nulls to functions that don't allow nulls
PHP 8.1 is more strict on the parameter type. Functions such as trim(), strlen(), str_replace(), etc
show notice when null is passed as an argument
2023-01-23 09:15:54 +08:00
Jun Pataleta
db2ee34986 Merge branch 'MDL-76506' of https://github.com/jrchamp/moodle 2023-01-09 19:34:07 +08:00
Sara Arjona
3dd93ffc5e Merge branch 'MDL-76617' of https://github.com/stronk7/moodle 2022-12-28 12:42:12 +01:00
Eloy Lafuente (stronk7)
47435471ee MDL-76617 store_mongodb: Adjust moodle to mongo-php-library to v1.15.0
The new library version should work without problems with older
php-mongodb extension versions:
- v1.15.0 (paired version, tested).
- v1.14.1 (tested)

But, in order to keep them paired, the requirements have been
raised to the extension v1.15.0. See:

https://www.mongodb.com/docs/drivers/php/#compatibility
2022-12-22 19:36:36 +01:00
Eloy Lafuente (stronk7)
c5efd54971 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:36 +01:00
sam marshall
0b2c2a1f95 MDL-76129 upgrade: Allow caching in specific functions
During install/upgrade, caching is disabled. This change provides a
way to temporarily enable caching (using in-memory cache storage only)
within a specific function; caches are deleted afterwards.

Adding this to two locations improves install performance quite a lot.

Caching is not enabled during the parts of plugin installation that
can vary for individual plugins (install.php/upgrade.php) as these
might be relying on its absence, for example by making direct database
changes.
2022-12-22 11:05:45 +00:00
Andrew Nicols
0646f7ea5a Merge branch 'MDL-76183-master' of https://github.com/davewoloszyn/moodle 2022-12-01 08:55:34 +03:00
Andrew Nicols
b1e77fe1f3 Merge branch 'MDL-76218-master' of https://github.com/sammarshallou/moodle 2022-12-01 08:55:34 +03:00
David Woloszyn
126028cc76 MDL-76183 lib: Update Github URLs 2022-11-30 14:01:31 +11:00
Jonathan Champ
a45c8120c9 MDL-76506 cache_application: Fix MDL_PERF and perfdebug checks 2022-11-29 13:27:31 -05:00
Jun Pataleta
00bae8b8a4 MDL-76403 versions: bump all versions and requires near release 2022-11-23 09:45:23 +08:00
sam marshall
5f5f922fd8 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-11-14 14:40:09 +00: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