195 Commits

Author SHA1 Message Date
Eloy Lafuente (stronk7)
29a541724f
MDL-65292 style: Fix all the function declaration ordering
This has been generated running the following Sniff,
part of the Moodle's CodeSniffer standard:
- PSR2.Methods.MethodDeclaration

It just ensures all the function declarations have
the correct order for:
- abstract and final.
- visibility (public, protected, private).
- static.

So, all the lines modified by this commit are function declarations
and the only changes are in the positions of those keywords.
2024-02-28 23:47:47 +01:00
Eloy Lafuente (stronk7)
ba1f804ffa
MDL-65292 style: Fix all function declarations white space
This has been generated running the following Sniffs, all
them part of the Moodle's CodeSniffer standard:
- PSR12.Functions.ReturnTypeDeclaration
- PSR12.Functions.NullableTypeDeclaration
- moodle.Methods.MethodDeclarationSpacing
- Squiz.Whitespace.ScopeKeywordSpacing

All them are, exclusively, about correct spacing, so the changes
are, all them, only white space changes.

Only exceptions to the above are 3 changes what were setting the
return type in a new line, and, when that happens, the closing
parenthesis (bracket) has to go to the same line than the colon.
2024-02-28 23:33:26 +01:00
sam marshall
0f8577784d MDL-78467 core_cache: Improve cache locking API
* Makes it possible to safely call acquire_lock so that it throws an
  exception instead of returning false if it can't get a lock (which
  most existing uses assumed it already does).
* Fix some omissions from the requirelockingbeforewrite option (it
  now checks on delete).
* Modinfo uses a versioned cache, so it is not necessary to delete
  items, only increase the version. (Provided we keep track of
  cacherev carefully...)
2023-09-14 09:28:10 +01:00
Ilya Tregubov
4fa5a40f34
Merge branch 'MDL-76865-master' of https://github.com/daledavies/moodle 2023-09-06 14:48:15 +08:00
Ilya Tregubov
b327210cd2
Merge branch 'MDL-78615' of https://github.com/paulholden/moodle 2023-08-29 13:32:46 +08:00
Brendan Heywood
482758b1df MDL-79150 cache: Improve requirelockingwrite error 2023-08-24 10:39:12 +10:00
Paul Holden
8462e7880d
MDL-78615 cache: display failure notifications deleting lock/store. 2023-08-21 10:45:11 +01:00
Dale Davies
af91ae626a MDL-76865 core: Check lock state before attempting to acquire a lock 2023-08-14 12:34:14 +01:00
sam marshall
8df2ac4e98 MDL-78109 core_cache: Remove harmful requirelockingwrite/read options
These cache options are not used in core and would cause a performance
cost without any benefit if ever used. Also they don't work properly.
2023-07-12 15:33:15 +01:00
Petr Skoda
3c25ccdcd1 MDL-78552 core: tidy up MDL_PERF constants
* all constans usable in ABORT_AFTER_CONFIG should be always defined
* MDL_PERFDB and $PERF->logwrites not used after legacy log removal
* MDL_PERF_TEST should be documented in codebase
* deprecated warnings in shutdowb manager
2023-06-25 08:39:09 +02:00
Andrew Nicols
5138f02dd3
MDL-78466 cache: Add new result_found helper
This helper is intended to prevent recurrences of this issue by moving
the guess-work to something well tested.
2023-06-14 11:58:12 +08:00
Andrew Nicols
5c6ebcd5f5
MDL-78466 cache: Perform strict test on static cache values
If a statically accelerated cache returns an empty array then the value
was still fetched from the non-static cache store.

The check of the `$result` should be strictly checked against `false`,
which is the value used if no value was found.
2023-06-14 09:28:53 +08:00
Jonathan Champ
e32cf94b9b MDL-78383 cache: Remove unused class property configlockmappings 2023-05-30 19:46:03 -04:00
Meirza
691d80fdae MDL-77350 cache: Added class properties that are not declared
In PHP 8.2 and later, setting a value to an undeclared class property is
deprecated and emits a deprecation notice.
So we need to add missing class properties that still need to be declared.
2023-05-16 00:33:20 +07:00
Marina Glancy
8fc1486d36 MDL-77164 various: fix incorrect phpdocs 2023-04-13 11:35:06 +01: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
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
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
Jonathan Champ
a45c8120c9 MDL-76506 cache_application: Fix MDL_PERF and perfdebug checks 2022-11-29 13:27:31 -05: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
Sujith Haridasan
73d604369d MDL-71062 core: Step 1 deprecation of print_error function 2022-07-13 08:20:54 +05:30
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
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
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
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
Peter Burnett
93c0dc8ec4 MDL-70233 cache: Disabled factory now gets writer from parent 2021-04-07 15:33:31 +10: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
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
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
Paul Holden
2d70187ade MDL-69005 cache: fix private $store access in loader. 2020-06-10 10:31:47 +01:00
Brendan Heywood
9f4bb48e40 MDL-68329 cache: Improve cache performance footer info 2020-04-28 10:08:28 +10:00
Leon Stringer
36b6444420 MDL-64719 cache: Implement purge_current_user() in \cache
\cache::make() may return a cache_disabled subclass but callers, specifically
user/lib.php:user_create_user(), invoke \cache::purge_current_user() which was
only implemented by the cache_session subclass.  Added empty
\cache::purge_current_user() which subclasses can implement, i.e.
cache_session, or not, i.e. cache_disabled.
2019-04-01 15:29:39 +01:00
David Mudrák
0ea0dfde6d MDL-64452 cache: Always use the current session id in the key prefix
The current logic in the cache_session::check_tracked_user() is not
right. We must always set the current session id. A typical use case is
when the cache instance is instantiated for a not logged in user. We
can't let the sessionid property null in that case as it forms an
important part of the parsed key.

Similarly, even if we have the same user currently loaded, we must still
set the sessionid to make sure the data will be associated with the
current PHP session. Same user (including visitors or guest users) can
access the site from different browsers and each must end up with its
own key prefix.
2019-02-15 09:36:43 +01:00
Andrew Nicols
c96cd71102 MDL-63924 privacy: Add shared user providers to subsytsems 2018-11-08 21:26:18 +08:00
Andrew Nicols
0a197875df MDL-63101 cache: Improve accuracy of cache event invalidation 2018-08-27 14:43:42 +08:00
Andrew Nicols
26bb44e5f4 MDL-61898 core_cache: Implement Privacy API 2018-04-30 14:07:27 +08:00
sam marshall
4998d3a5be MDL-59427 MUC: cache_helper::purge_all should reset adhoc caches 2017-06-30 11:15:30 +01:00
Skylar Kelty
32ec2da151 MDL-58658 caching: Fix static acceleration for empty arrays 2017-04-20 09:49:09 +01:00
Eloy Lafuente (stronk7)
4d505af519 Merge branch 'MDL-55267-master-deprecation' of https://github.com/marcusgreen/moodle 2017-03-21 10:18:56 +01:00