Commit graph

28528 commits

Author SHA1 Message Date
David Mudrák
4983142e5a MDL-71169 external: Do not explicitly specify the default methodname 2021-03-22 15:49:59 +01:00
David Mudrák
9da861ea63 MDL-71169 external: Use execute as the default external method name
If the 'methodname' is not explicitly specified in db/services.php,
expect it to be 'execute'.
2021-03-22 15:35:52 +01:00
Andrew Nicols
608852f3a0 Merge branch 'MDL-70816-311-4' of git://github.com/rezaies/moodle into MOODLE_311_STABLE 2021-03-22 13:33:48 +08:00
Shamim Rezaie
7c16ba2fa4 MDL-70816 core: Activity date details base class
* Base class for fetching an activity module's important date for a user
2021-03-22 16:19:02 +11:00
Andrew Nicols
eee0b6865c MDL-71159 output: Do not run content prefetch during install 2021-03-22 13:15:26 +08:00
Andrew Nicols
9882503572 Merge branch 'MDL-70919-311' of git://github.com/marinaglancy/moodle into MOODLE_311_STABLE 2021-03-22 07:48:42 +08:00
Eloy Lafuente (stronk7)
0fc17af158 MDL-71149 install: update the list of stale files for 3.11 2021-03-19 17:31:11 +01:00
Sara Arjona
e2585ce116 MDL-65776 libraries: Set moodle files after jsbeautify upgrade 2021-03-19 15:23:06 +01:00
Sara Arjona
ec602cf244 MDL-65776 libraries: Upgrade jsbeautify to 1.13 2021-03-19 15:23:05 +01:00
Sara Arjona
1517765cca MDL-69792 core_badges: deprecated backpack.js and BADGE_BACKPACKURL
Final deprecation for constant BADGE_BACKPACKURL (it has been removed)
and badges/backpack.js file (it has been removed too).
Besides, some methods have started the deprecation process too:
 - badges_check_backpack_accessibility
 - badges_setup_backpack_js()
 - badges_local_backpack_js()

Apart from that, string 'addbackpack' has been deprecated here
because it's not used anywhere.
2021-03-19 15:14:09 +01:00
Ilya Tregubov
c8edf4e5c8 MDL-70318 core: Moodle customisations. 2021-03-19 10:19:33 +02:00
Ilya Tregubov
62d1082bab MDL-70318 core: Upgrade CFPropertyList to 2.0.2. 2021-03-19 10:19:33 +02:00
sam marshall
45844a161c MDL-70537 Availability: Avoid recursive calls to $cm->name
These recursive calls didn't work in PHP 7.3 and below, but in PHP
7.4 they also cause a fatal error which means if you have invalid
availability data, the whole page might die.
2021-03-18 15:55:31 +00:00
Marina Glancy
f878850277 MDL-70919 core_form: non-static method can not be called statically 2021-03-18 12:16:12 +01:00
Jun Pataleta
9f904c2b5e Merge branch 'MDL-70992-311' of https://github.com/NashTechOpenUniversity/moodle into MOODLE_311_STABLE 2021-03-18 12:23:39 +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
Adrian Greeve
2b2e3e8ef8 Merge branch 'MDL-71048-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2021-03-18 11:10:59 +08:00
Eloy Lafuente (stronk7)
c0c276e49d Merge branch 'MDL-70901-311' of git://github.com/marinaglancy/moodle into MOODLE_311_STABLE 2021-03-18 00:40:55 +01:00
Eloy Lafuente (stronk7)
d42107e093 Merge branch 'MDL-70968-311' of git://github.com/marinaglancy/moodle into MOODLE_311_STABLE 2021-03-18 00:29:46 +01: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
Eloy Lafuente (stronk7)
b76e9b6551 Merge branch 'MDL-70689-311' of git://github.com/sarjona/moodle into MOODLE_311_STABLE 2021-03-17 23:20:50 +01:00
Jun Pataleta
3a9b41613c Merge branch 'MDL-71036_311' of https://github.com/stronk7/moodle into MOODLE_311_STABLE 2021-03-17 20:05:17 +08:00
sangnguyen
2929e6234f MDL-70992 Folder: Unnecessary tab stops to the left of files 2021-03-17 09:34:23 +07:00
Eloy Lafuente (stronk7)
88847544c4 Merge branch 'MOODLE_311_MDL-71044_v3' of https://github.com/golenkovm/moodle into MOODLE_311_STABLE 2021-03-16 22:39:02 +01:00
Eloy Lafuente (stronk7)
50520ae4ad Merge branch 'MDL-67748-311-managewebservices' of git://github.com/mudrd8mz/moodle into MOODLE_311_STABLE 2021-03-16 19:29:04 +01:00
Eloy Lafuente (stronk7)
24c62a15c5 MDL-69474 accessibility: page->url can be not set, protect against that
Both in unit tests, but also in other areas (say blocks, for example)
it's possible that page->url has not been set yet.

So, let's change current code to always check if we have something
(page->url) to compare.

Note the use of has_set_url() is needed, because page->url is magic
method and it doesn't work as expected. Hate magics!
2021-03-16 12:56:40 +08:00
David Mudrák
cb7d5a0939 MDL-67748 admin: Refactor tokens management as an external page
No need to have a dedicated admin_setting_managewebservicetokens admin
setting subclass, and yet do not use almost any of its features. So the
patch merges the list and the forms handling into a single external
page.

Similarly, it feels like overkill to have a renderer method for a
simple confirmation widget - especially given that the URLs were
hard-coded in it. So that one was dropped.
2021-03-15 19:09:26 +01:00
David Mudrák
b6be1e9822 MDL-67748 user: Add a new core_user_search_identity external function
The purpose of this external function is to provide data for
asynchronous user selectors and similar widgets. It allows to search
users matching the given query in their name or other available identity
fields.
2021-03-15 19:09:25 +01:00
Eloy Lafuente (stronk7)
df5a880db6 Merge branch 'MDL-69474-311' of https://github.com/NashTechOpenUniversity/moodle into MOODLE_311_STABLE 2021-03-15 16:54:51 +01:00
Sara Arjona
3329494332 Merge branch 'MDL-44613-311-1' of git://github.com/mihailges/moodle into MOODLE_311_STABLE 2021-03-15 15:53:44 +01:00
Paul Holden
e2e4b15285 MDL-70924 course: ensure required fields present when getting courses. 2021-03-15 12:46:41 +00:00
Peter Dias
e72dbd0752 MDL-70313 core: Update the thirdpartylib.xml 2021-03-15 10:28:03 +08:00
Peter Dias
c4b0667582 MDL-70313 core: Rebuilt module files 2021-03-15 10:28:03 +08:00
Peter Dias
63b9f338ed MDL-70313 core: Update codemirror to 5.59.4 2021-03-15 10:28:03 +08:00
Dmitrii Metelkin
88a150467f MDL-66667 course: add course image cache 2021-03-15 12:53:40 +11:00
Mihail Geshoski
3bc58c98d0 MDL-44613 behat: strftime format in time to timestamp transformation
Modifies the 'string time to timestamp' behat trasformation to use
userdate() instead of date(). The userdate() method is generally used
throught Moodle for constructing formatted date strings and this change
will provide more consistency and prevent any potential behat failures.
Therefore, if the date format is defined in the given trasformation, it
has to be strftime compatible. Example:
'I should see "##tomorrow noon##%A, %d %B %Y, %I:%M %p##"'
2021-03-15 08:26:17 +08:00
Sara Arjona
c9110ffdce MDL-70689 oauth2: unit tests for new IMS OBv2.1
Apart from adding new unit tests for covering new IMS OBv2.1 issuer,
some extra tests have been added to test existing issuers and confirm
they are still working as expected after the changes.
2021-03-12 12:33:54 +01:00
Sara Arjona
9941e04857 MDL-70689 oauth2: self-register IMS OBv2.1 services
IMS OBv2.1 services have a registration endpoint to get client id
and secret.
This patch adds and implements the "register" method for the IMS
Open Badges Connect discovery system, to get the proper client id
and secret values.
2021-03-12 12:33:54 +01:00
Sara Arjona
84e51fb0fd MDL-70689 oauth2: add support to IMS OBv2.1 service
In order to make easier to create and maintain new OAuth2 services,
a couple of classes have been added:

- discovery\* contains methods related to the discovery system. Until
now, only OpenID Connect was supported by Moodle so all the code was
centralised in api.php.
With this patch, as IMS OBv2.1 has a different discovery system, a new
abstract class (base_definition) has been added to be called and let
every discovery system (OpenID Connect, IMS Badge Connect...)
implement their own methods.

- service\* . Instead of keep adding methods to the api, the service
namespace has been created to store all the standard issuer services.
An interface (issuer_interface) has been created and all the services
should implement it.
This patch creates the "IMS OBv2.1" and "Custom" services and moves
the methods for "Google" service because it uses the OpenID connect
discovery system.
2021-03-12 12:33:53 +01: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)
e2e333c9cd MDL-71036 phpunit: Add all the noticeable changes to upgrade notes 2021-03-11 23:07:31 +01:00
Eloy Lafuente (stronk7)
790237a77f MDL-71036 phpunit: xml config - switch coverage info to new includes
This applies the "whitelist" => "include" changes to all the core
phpunit_coverage_info occurrences, so core won't emit any deprecation
warning (see previous commit).

At the same time, modified a bunch of comments in coverage files
to be more readable/understandable.
2021-03-11 23:07:31 +01:00
Eloy Lafuente (stronk7)
a9c0c3d5a9 MDL-71036 phpunit: xml config - deprecate whitelist from coverage
Following the changes in the schema, from "whitelists" to "includes",
we are deprecating these two properties from phpunit_coverage_info:

- whitelistfolders => includelistfolders
- whitelistfiles   => includelistfiles

They will continue working over the deprecation period but the init/util
scripts will throw some warnings about them being deprecated for 3.11 and
the way to replace them.

Standard 2y deprecation applies with final removed to happen @ MDL-71067
2021-03-11 23:07:31 +01:00
Eloy Lafuente (stronk7)
50e3bb8546 MDL-71036 phpunit: xml config - change generation code to follow xsd
This performs all the changes needed in the util generator to
produce XML files compliant with the new schema (see previous
commit for description of changes).

- All the occurrences in code of filter => coverage.
- All the occurrences in code of whitelist => include.
- Apply all the changes to comply with the new schema.

- Remove processUncoveredFilesFromWhitelist attribute, useless (false
    is its default value, and now have another name).
- Move from 4-spaces indented XML to 2-spaces indented.
- Small linefeed tweaks to generate better-looking XML.
2021-03-11 23:07:31 +01:00
Eloy Lafuente (stronk7)
cf38a34904 MDL-71036 phpunit: xml config - add new (9.5) validation xsd
PHPUnit 9 comes with various changes in the XML
configuration file, namely:

  - the old "filter" section has been renamed to "coverage".
  - "whitelist" has been renamed to "include"
  - "exclude" is not a child of "include" anymore, but of "coverage".
  - "include" cannot have configuration attributes anymore, only
    "coverage" can"

Visually it means that the old section (invented example):
```
<filter>
  <whitelist attributes_may_go_here="xx">
    <directory suffix=".php">classes</directory>
    <directory suffix=".php">externallib.php</directory>
    <exclude>
      <directory suffix="_test.php">.</directory>
    </exclude>
  </whitelist>
</filter>
```
Now looks like:
```
<coverage attributes_may_go_here="xx">
  <include>
    <directory suffix=".php">classes</directory>
    <directory suffix=".php">externallib.php</directory>
  </include>
  <exclude>
    <directory suffix="_test.php">.</directory>
  </exclude>
</filter>
```

So, switching to the new xsd so we can validate the remaining changes.
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)
8940f67486 MDL-71036 phpunit: ->at() matcher is deprecated
Mocke at() matcher is being deprecated with phpunit9 and
will be removed with phpunit10.

Source: https://github.com/sebastianbergmann/phpunit/issues/4297

Luckily we are using those deprecated matchers only in completionlib
tests, so there aren't many cases to modify. Now, we are using
supported matchers (once, exactly, never...) and the tests have
been reorganised to better represent the expected behavior (how
many times stuff is called, with which params and return values).
2021-03-11 23:07:30 +01:00
Eloy Lafuente (stronk7)
ad249ced07 MDL-71036 phpunit: Remove custom autoloader
Custom autoloaders are deprecated with PHPUnit 9 and will be removed
with PHPUnit 10.

Since PHPUnit 8.5 custom autoloaders don't do much because that
version removed the ability to launch unit tests by class name
and that's exactly the reason we had a custom autoloader (to map
class names to files within our tests). See MDL-67673 about
when direct use of classes was deprecated (8.5), now removed (9.5).

So, as far as it's unused, removing it now, test still can be
selectively using any of:

- a relative path to file (although there are some restrictions comming
  with PHPUnit 9, see https://github.com/sebastianbergmann/phpunit/issues/4105
- using --filter, to point to any classname[::method]
- using --testsuite to run a complete suite
- using --config to point to custom components.

Also, commented out the lib/ajax/tests directory because it doesn't
exist / is empty and PHPUnit 9 emits error when a configured test
directory does not exist. See
https://github.com/sebastianbergmann/phpunit/issues/4493.

Alternative was to completely remove the configuration line, but
decided to keep it around in case some day we want to add some
test there.
2021-03-11 23:07:30 +01:00
Eloy Lafuente (stronk7)
6d5eb09218 MDL-71036 phpunit: XML load() method has been moved to new loader class
Used by our custom assertTag() and assertNotTag() assertions, that some
day we should deprecate... the loading of XML content for further
processing has been moved to new classes within the PHPUnit utils. We
are just following the move here.
2021-03-11 23:07:30 +01:00