327 Commits

Author SHA1 Message Date
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
1a53cbbae4 MDL-77989 testing: Add test file isolation helper
When we deprecate the use of a file, we often include tests which ensure
that the legacy behaviour is maintained. There are also legacy uses
in the community where people would like to use the deprecated API for a
period.

The issue that we face is that, if the deprecated file is included once,
then it will be included for all other, unrelated, tests. This means
that other tests may not detect cases where the deprecated file was
included.

We can solve these cases by running the test that performs the inclusion
in a deprecated process. This means that the inclusion is only performed
in that isolated process, and other unrelated tests do not include the
file.

However, we also then need to detect which files which are including the
file and which we do not know about.

This change introduces:
- an override to the TestCase::setInIsolation method to define a
  constant when the test is running in isolation
- a new function that a file can call when it is included, to make sure
  that the test process was isolated, where there is any test.
2023-04-21 13:33:56 +08:00
Petr Skoda
f0613d1bfa MDL-75005 core: remove invalid addslashes() 2023-02-17 09:50:06 +01: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
Tim Hunt
192f993906 MDL-76649 quiz statistics task: output more useful trace info
At the moment, quiz_statistics\task\recalculate gives no useful
information about what it is doing, which makes it hard to investigate
if the task fails. This commit makes it more usefully verbose.

Also, following this change, one instance of this task will not
run for more than one hour at a time.

As part of this commit, I have added a new helper mtrace_exception.
to consistently log exceptions in scheduled tasks. It is sad to
add a new function to moodlelib.php, but that seemed the logical place.
Looking at other tasks, this method is badly needed. Many are just
logging the ->getMessage() which is normaly insufficient for proper
debugging. However, swiching all existing tasks to use the new function
will need to wait for a future MDL.
2023-01-09 13:26:41 +00:00
Sara Arjona
d5b3abde3c Merge branch 'MDL-76166-username-logging' of https://github.com/brendanheywood/moodle 2022-12-05 12:44:17 +01:00
Jun Pataleta
3947ad99c1 Merge branch 'MDL-76483-master' of https://github.com/andrewnicols/moodle 2022-12-01 08:55:34 +03:00
Brendan Heywood
825d11ec50 MDL-76166 auth: Ensure user is in server access logs 2022-11-30 13:25:20 +11:00
Marina Glancy
a800e7e62f MDL-74853 various: add second parameter to htmlentities functions
Default value of the $flag argument changed in PHP 8.1 from ENT_COMPAT to ENT_QUOTES | ENT_SUBSTITUTE
To ensure consistent behavior across different PHP version the second parameter is now required for the functions:
htmlspecialchars(), htmlentities(), htmlspecialchars_decode(), html_entity_decode() and get_html_translation_table()
2022-11-28 16:12:20 +01:00
Andrew Nicols
6eccbc7af5 MDL-76483 core: Handle default value for get_docs_url() 2022-11-25 22:19:04 +08:00
Ilya Tregubov
3f568024a1 MDL-76033 core: bump version in is_major_upgrade_required
MDL-58266 changes db structure. So upgrade must happen before
accessing any page.
2022-10-19 15:08:44 +03:00
Brendan Heywood
11efc67eb5 MDL-75614 dml: Fixed debugsqltrace with anon classes bug 2022-09-02 11:42:04 +10:00
Sujith Haridasan
73d604369d MDL-71062 core: Step 1 deprecation of print_error function 2022-07-13 08:20:54 +05:30
Brendan Heywood
9fa26ed911 MDL-72486 core: Add unsafe log and fix options to proxy settings 2022-06-20 11:18:42 +10: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
Cameron Ball
776bfb134c MDL-73427 core: Remove $SESSION->fromurl 2022-01-05 19:39:21 +08:00
Jason den Dulk
e7f51a3857 MDL-68199 setup: Fix invalid parameters to make_request_directory()
Added parameter type hint to make_request_directory()
Removed invalid parameters from calls to make_request_directory()

Removing these parameters should have no effect on behaviour.
2021-12-02 07:49:28 +11:00
Eloy Lafuente (stronk7)
4c0ae3e138 MDL-73098 install: Detect stale bootstrap.php files and disable them
It's important to say that this bug apparently (till now) only happens
when an *incorrect* instalation of a site happens, reusing the dataroot
from another existing site.

When that happens, the localcache/bootstrap.php file from the old
site is reused, setting siteidentifier and SYSCONTEXTID when it's not
time for them to be defined yet.

Their existenece leads to reusing some other structures from the old
dataroot (that, again, should have been changed or wiped!), ultimately
leading to all sort of errors about non-existent tables (course,
context...).

With this change we ensure that:

1) Whenever any change to the database configuration (prefix, user,
   type..) happens, it's detected and immediately the information
   in the localcache/bootstrap.php is discarded and the file removed.
   This should fix problems like MDL-73098 itself.

2) We only set SYSCONTEXTID if the file is not stale. Main reason
   for doing that check within the localcache/bootstrap.php file
   itself is that we cannot "undefine" it @ setup.php. This should
   prevent errros like MDL-72888 to happen.

3) Finally, little detail, we only define SYSCONTEXTID if it has
   not been defined earlier. In the past, it was recommended to
   define it in config.php (exactly to save one DB read) and, sites
   having them will face "already defined" warnings.
2021-11-17 20:56:36 +01:00
Ilya Tregubov
1025ed1c22 MDL-72851 core: Bump $lastmajordbchanges to trigger upgrade immediately.
Fixing regression of MDL-52206.
2021-10-19 16:40:42 +02:00
Brendan Heywood
7b938088b5 MDL-71014 core: Cache immutable bootstrap config locally 2021-09-02 13:22:28 +10:00
Sujith Haridasan
fbc7b28614 MDL-67412 setuplib: Final deprecation of generate_uuid
Final deprecation of generate_uuid function.
2021-08-03 08:32:01 +05:30
Matteo Scaramuccia
7910fa322a MDL-63770 core: 'port' should be an integer like in parse_url()
Plus trivial comment cleanup.
2021-07-15 11:37:13 +08:00
Dmitri Pisarev
1983718149 MDL-63770 core: Fix a false-positive in reverseproxyabused check
A `reverseproxyabused` error is wrongly triggered when external port number doesn't equal internal.
2021-07-12 11:23:49 +02:00
Jess Ansell
52bc582e77 MDL-71012 setup: Return 500 error code for setup errors. 2021-03-22 14:05:45 +00:00
Eloy Lafuente (stronk7)
08ae245926 MDL-70876 php80: 5th param removed from custom error handlers
It was deprecated in php72 and now it's gone.

Have used this regexp to find all the uses in core:

ag set_error_handler | uniq

And then checked all them manually, that parameter was not
being used in the 3 methods where we are removing it.
2021-02-26 13:08:27 +01:00
Brendan Heywood
10f33b6fdc MDL-69975 core: Fix paths longer than 260 chars on windows
Also, ensure that remove_dir() only processes directories,
because sometimes it was being called by shutdown managers
with files, leading to PHP warnings.

Co-authored-by: Eloy Lafuente (stronk7) <stronk7@moodle.org>
Co-authored-by: Jun Pataleta <jun@moodle.com>
2020-11-01 11:02:00 +01:00
Brendan Heywood
9fabe1dda5 MDL-66928 core: Move request dirs to system tmp instead of localcache 2020-10-13 14:17:39 +11:00
Brendan Heywood
6e935cc29c MDL-69718 core: Added support for TB and PT to display_size 2020-09-21 11:02:16 +10:00
Jake Dallimore
7a40781aeb Merge branch 'MDL-56041-custom-error-pages' of https://github.com/brendanheywood/moodle 2020-07-08 09:33:46 +08:00
Brendan Heywood
43999a3f2b MDL-56041 error: Enable custom 404 and 500 error pages 2020-07-08 09:36:21 +10:00
Matteo Scaramuccia
82850a0418 MDL-68588 Backup: Hide ->backuptempdir in exception info 2020-07-03 21:17:42 +02:00
Brendan Heywood
1fef1de592 MDL-58281 files: Correctly handle missing files in readfile_accel 2019-12-30 17:18:49 +11:00
Eloy Lafuente (stronk7)
df272345ba MDL-65996 exceptions: Make exception handler early-errors compliant
Some errors can happen really early in Moodle bootstrap/warmup
(basically when executing setup.php stuff, before general libraries
are loaded and available).

That's called "early errors" and there are good parts within
setuplib.php that must be able to run without any dependency
other than vanilla php code.

It seems that, along the years, some dependencies have been
added (calls to debugging(), to s()....) and they worked mostly
ok because early errors are rare.

This commit just makes all those dependencies conditional so,
if an early error is detected... the exception handler will
return real information about he error happening and not
handler own errors (like it's happening now).
2019-06-22 11:38:43 +02:00
Matteo Scaramuccia
c7321899c9 MDL-61038 setuplib: Fixed PECL UUID extension support
generate_uuid() has been refactored into \core\uuid::generate()
2019-06-09 23:24:26 +02:00
Eloy Lafuente (stronk7)
7726bec6b3 Merge branch 'MDL-63262-master' of git://github.com/damyon/moodle 2019-05-07 16:26:40 +08:00
Damyon Wiese
aae219acce MDL-63262 badges: Add badgr.io
Upgrade the support for Open Badges 2 to support a real open badges 2 backpack.
Moodle can only talk to one backpack at a time, so after switching backpacks, users
will have to manually disconnect and then reconnect their backpack to the new one.

This commit combines several changes:
* Split classes into badges namespace
* Publish expiry data with a badge
* Publish badge alignments in badges exported to the backpack.
* Export the criteria for a badge to the backpack.
2019-05-03 15:00:00 +08:00
Andrew Nicols
ea00cdc79f Merge branch 'MDL-64394-accesslog' of https://github.com/brendanheywood/moodle 2019-05-03 08:49:33 +08:00
Brendan Heywood
b940ca995a MDL-64394 core: Fixed bug when using access log with pre_loginpage_hook 2019-04-01 16:48:22 +11:00
Eloy Lafuente (stronk7)
fd652de81f Merge branch 'MDL-31355-master' of git://github.com/rezaies/moodle 2019-04-11 17:17:07 +02:00
Shamim Rezaie
1c96922da5 MDL-31355 core: Bump $lastmajordbchanges to trigger upgrade immediately 2019-04-11 18:47:35 +10:00
Damyon Wiese
e8bfd9b4a9 MDL-63876 badges: Remove invalid table from badges 2019-03-29 11:30:09 +08:00
Jun Pataleta
3c7bf4ea88 MDL-57898 core: Bump $lastmajordbchanges to trigger upgrade immediately 2019-01-22 09:36:15 +08:00
Marina Glancy
0e367a119c MDL-57898 core_customfield: Custom fields API
This commit is part of work on Custom fields API,
to minimize commit history in moodle core the work of a team of developers was split
into several commits with different authors but the authorship of individual
lines of code may be different from the commit author.
2019-01-18 14:28:18 +01:00
Andrew Nicols
cca12f68d0 MDL-49399 core: Allow creation of a new per-request basedir
Shutdown handlers are processed in order. If something in a shutdown
handler uses a file which is stored in a per-request directory, and
another, unrelated, per-request directory was created before the handler
started. then a fresh per-request directory will be required.
2019-01-16 12:14:25 +08:00
Ryan Wyllie
c912cd7324 MDL-63303 core: add debug info to exceptions 2018-11-15 14:40:11 +08:00
Eloy Lafuente (stronk7)
d27e49448f Merge branch 'MDL-53566-master' of git://github.com/andrewnicols/moodle 2018-11-13 23:55:38 +01:00
Andrew Nicols
0616f045c3 MDL-53566 core: Add support for context locking
This chagne adds support for a new feature known as Context Locking.
This allows a context to be locked, thereby removing all write
capabilities for all users (including admin) for that context, and all
child contexts.
2018-11-13 21:17:40 +08:00
Matteo Scaramuccia
ef844148a9 MDL-60923 backup: Added $CFG->backuptempdir
The new setting will allow to host the temporary backup files
into a specific target directory. Defaults to '$CFG->tempdir/backup'.

Calling make_backup_temp_directory() checks that the required sub-directory
will be properly created under the new target directory.
2018-04-16 23:50:28 +02:00
Tim Hunt
168635fb6f MDL-61366 setuplib: safely construct the ajax renderer when needed 2018-02-06 12:09:43 +00:00
John Okely
cd1eb7ce9c MDL-42834 admin: Upgrade script and warning for loginhttps sites 2017-10-23 12:25:36 +08:00