Commit graph

1556 commits

Author SHA1 Message Date
Dongsheng Cai
ecae6484a4 MDL-71978 core_calendar: only allow owner to edit user subscriptions 2021-07-08 23:32:19 +02:00
Sara Arjona
cdd0a7f2ae Merge branch 'MDL-67208-311' of git://github.com/lameze/moodle into MOODLE_311_STABLE 2021-06-30 16:55:38 +02:00
Simey Lameze
35d8248b7a MDL-71789 calendar: fix subscription url validation 2021-06-30 16:29:58 +02:00
Simey Lameze
5e5421b56d MDL-67208 calendar: fix manage subscription redirection
This patch fix the subcription page only adding the course parameter
only when viewing the calendar on course context. It also passes the
url to the form instance, so we have the course parameter on the
form action attribute.
2021-06-24 17:00:04 +08:00
Andrew Nicols
c54bf071a1 Merge branch 'MDL-71837-311' of git://github.com/paulholden/moodle into MOODLE_311_STABLE 2021-06-24 10:59:57 +08:00
Andrew Nicols
613cd69cbd MDL-71113 javascript: Improve basic JS Documentation 2021-06-18 09:38:05 +08:00
Andrew Nicols
e214af5720 MDL-71113 js: Fix all jsdoc warnings 2021-06-18 09:38:05 +08:00
Paul Holden
3ed05ecf8c MDL-71837 calendar: turn off export form double submit protection. 2021-06-02 19:53:02 +01:00
Eloy Lafuente (stronk7)
71d0cfefab MDL-71583 versions: bump all versions and requires near release
version = 2021051700 release version
requires= 2021051100 current rc1 (week7roll1) version

Note that, because we are under parallel development period,
this is being done in the branch that is going to be released
(MOODLE_311_STABLE already existing) for Moodle 3.11.0 and
not in master, that is the one getting the bump under normal
(non-parallel) periods.
2021-05-11 18:50:34 +02:00
Marina Glancy
c7e3291ac8 MDL-70926 core: getuserdate() shoud show debugging if null was passed
passing null to getdate() has different results in PHP7 and PHP8
2021-05-06 20:41:16 +02:00
Marina Glancy
b597b491ec MDL-71051 core_user: create user profile field form is now modal form 2021-04-28 11:49:28 +02:00
Marina Glancy
ac494c7d91 MDL-71051 core_user: move user profile edit field form to classes 2021-04-28 11:49:27 +02:00
Simey Lameze
10018bbc39 MDL-71156 core: machinery to recover orphaned calendar events
The machinery to fix orphaned calendar events that were broken by MDL-67494.

The solution consists of:

1) Upgrade step that checks if this site has executed the problematic upgrade steps and
   if positive, it will schedule a new run for calendar_fix_orphaned_events adhoc task.

2) Adhoc task that will self-spawn calling the recovery machinery, running until
   all the orphaned calendar events are fixed. It also sets the maximum runtime of
   60 seconds. It is also possible to override that number by specifing the desired
   number setting the ->calendareventsmaxseconds in your config.php

3) CLI script that will look for all the calendar events which userids
   where broken by a wrong upgrade step, affecting to Moodle 3.9.5
   and up.

   It performs checks to both:
     a) Detect if the site was affected (ran the wrong upgrade step).
     b) Look for orphaned calendar events, categorising them as:
       - standard: site / category / course / group / user events
       - subscription: events created via subscriptions.
       - action: normal action events, created to show common important dates.
       - override: user and group override events, particular, that some activities support.
       - custom: other events, not being any of the above, common or particular.

   By specifying it (--fix) try to recover as many broken events (missing userid) as
   possible. Standard, subscription, action, override events in core are fully supported but
   override or custom events should be fixed by each plugin as far as there isn't any standard
   API (plugin-wise) to launch a rebuild of the calendar events.

4) Unit tests and helper functions to generate calendar events. We have decided to
   keep the tests simple, testing only true and false and not using data generators because
   the code is purely to recover the calendar events and won't turn into an API or something
   and also due to the urgency of this issue.
   The helpers have been created in calendar/tests/helpers.php since there are no data generators
   for calendar.
2021-04-22 10:39:46 +08:00
Simey Lameze
5efbb6402b MDL-71182 calendar: add logic for category events in get_context
This commit adds the missing logic for category events in
get_context() method. Without this fix, users will get errors
if they have category events with userid set to 0.
2021-03-24 17:33:50 +08:00
Simey Lameze
41cbdeccab MDL-71182 calendar: Revert "Merge branch 'MDL-67494-311' of git://github.com/lameze/moodle into MOODLE_311_STABLE"
This reverts commit 9f5794834e, reversing
changes made to d30b045210.
2021-03-24 09:18:16 +08:00
Adrian Greeve
b443f37f91 Merge branch 'MDL-70924-311' of git://github.com/paulholden/moodle into MOODLE_311_STABLE 2021-03-18 11:52:51 +08:00
Eloy Lafuente (stronk7)
6f2b5817d6 Merge branch 'MDL-70893-311' of git://github.com/marinaglancy/moodle into MOODLE_311_STABLE 2021-03-18 00:23:36 +01:00
Paul Holden
e2e4b15285 MDL-70924 course: ensure required fields present when getting courses. 2021-03-15 12:46:41 +00:00
Eloy Lafuente (stronk7)
0357efb1fc MDL-71036 phpunit: Coding style changes, 99% whitespace only
I've gone over a few of the mofified files (those
which were showing warnings and errors to CiBoT. Some of them
have been fixed completely, while others only have fixed
for the lines belonging to this issue (lib/tests/moodlelib_test.php)
for example.
2021-03-11 23:07:31 +01:00
Eloy Lafuente (stronk7)
2d693cda7a MDL-71036 phpunit: Mock->setMethods() silently deprecated
The current ->setMethods() has been silently (won't emit any
warning) in PHPUnit 9. And will stop working (current plans)
in PHPUnit 10.

Basically the now deprecated method has been split into:

- onlyMethods(): To point to existing methods in the mocked artifact.
- addMethods(): To point to non existing (yet) methods in the mocked
  artifact.

In practice that means that all our current setMethods() calls can be
converted to onlyMethods() (existing) and done. The addMethods() is
mostly useful on development phases, not final testing.

Finally note that <null> isn't accepted anymore as parameter to
double all the methods. Instead empty array [] must be used.

Link: https://github.com/sebastianbergmann/phpunit/issues/3770
2021-03-11 23:07:31 +01:00
Eloy Lafuente (stronk7)
3dd26fe334 MDL-71036 phpunit: assertContains() now performs strict comparison
The methods assertContains() and assertNotContains() now perform
strict (type and value) comparison, pretty much like assertSame()
does.

A couple of new assertContainsEquals() and assertNotContainsEquals()
methods have been created to provide old (non-strict) behavior, pretty
much like assertEquals() do.

Apart from replacing the calls needing a relaxed comparison to those
new methods, there are also a couple of alternative, about how to
fix this, depending of every case:

- If the test is making any array_values() conversion, then it's better
  to remove that conversion and use assertArrayHasKey(), that is not
  strict.
- Sometimes if may be also possible to, simply, cast the expectation
  to the exact type coming in the array. I've not applied this technique
  to any of the cases in core.

Link: https://github.com/sebastianbergmann/phpunit/issues/3426
2021-03-11 23:07:31 +01:00
Eloy Lafuente (stronk7)
c989d6ec61 MDL-71036 phpunit: Renamed various regexp-related assertions
In PHPUnit 9.1, the following regexp-related assertions
have been deprecated and there are new alternatives for
all them:
    - assertRegExp()     -> assertMatchesRegularExpression()
    - assertNotRegExp()  -> assertDoesNotMatchRegularExpression()

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 'assertRegExp|assertNotRegExp' -li
2021-03-11 23:07:30 +01:00
Simey Lameze
0375020308 MDL-67494 calendar: privacy provider should not delete shared events 2021-03-03 16:29:20 +08:00
Simey Lameze
6bd9922957 MDL-67494 calendar: shared subscriptions should not set userid to 0 2021-03-03 16:29:20 +08:00
Simey Lameze
25f0a459c1 MDL-67494 calendar: set userid to zero for shared events 2021-03-03 16:29:19 +08:00
Simey Lameze
dc9701aa68 MDL-67494 calendar: add logic for category events in get_context 2021-03-03 16:27:00 +08:00
Marina Glancy
d2d0cffd1d MDL-70893 various: optional function arguments must be in the end 2021-02-15 16:54:01 +01:00
Eloy Lafuente (stronk7)
80cf455e48 Merge branch 'MDL-70648-311' of git://github.com/lameze/moodle into MOODLE_311_STABLE 2021-02-01 19:17:45 +01:00
Simey Lameze
b0aa55a75a MDL-70648 calendar: add form validation for category events 2021-01-20 09:26:33 +08:00
Shamim Rezaie
120e744a43 MDL-70625 core_calendar: Fix whitespace appearance in the id attribute 2021-01-14 01:58:52 +11:00
Luca Bösch
26345a0de5 MDL-70355 calendar: Filter popuptext for calendar entries. 2020-12-17 17:45:23 +01:00
Eloy Lafuente (stronk7)
b0a1b4ce8b MDL-70089 versions: bump all versions and requires near release
version = 2020110900 release version
requires= 2020110300 current beta+ (week6roll1) version

Note that, because we are under parallel development period,
this is being done in the branch that is going to be released
(MOODLE_310_STABLE already existing) for Moodle 3.10.0 and
not in master, that is the one getting the bump under normal
(non-parallel) periods.
2020-11-03 19:34:52 +01:00
Sara Arjona
b13ec3c353 Merge branch 'MDL-67673_310' of https://github.com/stronk7/moodle into MOODLE_310_STABLE 2020-10-21 17:38:16 +02:00
Eloy Lafuente (stronk7)
46606b3ddd 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:05 +02:00
Eloy Lafuente (stronk7)
35bc26b516 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:05 +02:00
Eloy Lafuente (stronk7)
ddf72dd60d MDL-67673 phpunit: Remove expectedException annotations
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

The annotations `@expectedException`, `@expectedExceptionCode`,
`@expectedExceptionMessage`, and `@expectedExceptionMessageRegExp`
are now deprecated.
Using these annotations will trigger a deprecation warning
in PHPUnit 8 and in PHPUnit 9 these annotations will be removed.

Also, all uses of expectExceptionMessageRegExp() has been moved
to expectExceptionMessageMatches(). See https://github.com/sebastianbergmann/phpunit/issues/3957

TODO: Various weirdness found while doing the changes with these tests:
- vendor/bin/phpunit lib/tests/exporter_test.php (created MDL-69700)
- vendor/bin/phpunit competency/tests/external_test.php (same issue than prev one)
- vendor/bin/phpunit question/engine/tests/questionengine_test.php (created MDL-69624)
- vendor/bin/phpunit lib/tests/event_test.php (created MDL-69688)
2020-10-21 12:46:05 +02:00
Eloy Lafuente (stronk7)
d81a94807b 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:46:04 +02:00
Jun Pataleta
f266c852c3 Merge branch 'MDL-69945-310' of git://github.com/lucaboesch/moodle into MOODLE_310_STABLE 2020-10-21 16:03:14 +08:00
Jenkins Automation
213ea00afe MDL-69726 calendar: fix raw event fetcher under postgres
Without this, there's a code path that under the right circumstances is hit and
results in a query with `FROM (mdl_event) ev` in it - which is not valid syntax
under postgres.
2020-10-20 07:46:00 +08:00
Luca Bösch
2c98bfc4f4 MDL-69945 core_calendar: let circles appear as circles 2020-10-16 14:22:47 +02:00
Brendan Heywood
0a8371c690 MDL-69910 calendar: Fix export exception when both params are sent 2020-10-10 19:28:45 +11:00
Sara Arjona
7db1a61a72 Merge branch 'MDL-69050-310-allowlist' of git://github.com/mudrd8mz/moodle into MOODLE_310_STABLE 2020-10-01 14:51:12 +02:00
Sara Arjona
e2a73965ca Merge branch 'MDL-68098-310' of git://github.com/dpalou/moodle into MOODLE_310_STABLE 2020-10-01 12:56:23 +02:00
Juan Leyva
cc16de4ccc MDL-68845 calendar: New WS get_calendar_export_token 2020-09-29 10:56:29 +02:00
Juan Leyva
c0af823086 MDL-68845 calendar: Move duplicated code to function 2020-09-29 10:54:05 +02:00
David Mudrák
19fe7f27a8 MDL-69050 lang: Improve the wording of the comments
Stop using the terms whitelist/blacklist when used to allow/deny things.
2020-09-24 19:32:40 +02:00
Dani Palou
e16b858ff9 MDL-68098 ws: Add unit tests to test mathjax in WS 2020-09-23 12:08:52 +02:00
Dani Palou
f4bdb898c7 MDL-68098 ws: Fix WebServices broken by filters HTML 2020-09-23 12:08:40 +02:00
Sara Arjona
c83543095a Merge branch 'MDL-69521_310' of https://github.com/stronk7/moodle into MOODLE_310_STABLE 2020-09-09 08:08:29 +02:00
Andrew Nicols
ca6cf0bd21 MDL-68974 calendar: Use page context for block check 2020-09-08 08:54:33 +02:00