553 Commits

Author SHA1 Message Date
Víctor Déniz
ad3ba9d0b7 Merge branch 'MDL-74827-master' of https://github.com/rmady/moodle 2022-07-21 00:12:23 +01:00
Sujith Haridasan
73d604369d MDL-71062 core: Step 1 deprecation of print_error function 2022-07-13 08:20:54 +05:30
Rodrigo Mady da Silva
892047d3c8 MDL-74827 core_webservice: Add enablecustomreports in WS get_site_info 2022-06-23 12:00:43 -03:00
Marina Glancy
e3bd0f7348 MDL-29717 core_webservice: Display deprecated badge in API docs 2022-06-03 16:17:47 +02:00
Dmitrii Metelkin
a6cad23b1a MDL-73431 enrol: Introduce a sync interval 2022-05-30 15:58:22 +10:00
Eloy Lafuente (stronk7)
caf55abf17 MDL-74413 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:

- Moved to the level2 "privacy" namespace:
  - \mod_assign\privacy\feedback_legacy_polyfill_test
  - \mod_assign\privacy\submission_legacy_polyfill_test

- Moved to the level2 "task" namespace:
  - \core_message\task\migrate_message_data_test
  - \ltiservice_gradebookservices\task\cleanup_test
  - \message_email\task\send_email_test
  - \mod_lti\task\clean_access_tokens_test
  - \mod_workshop\task\cron_task_test

- Moved to the level2 "event" namespace:
  - \core_h5p\event\deleted_test
  - \core_h5p\event\viewed_test

- Renamed to a better name:
  - backup_forum_activity_task_test.php (missing "task")
2022-05-07 20:32:30 +02:00
Jun Pataleta
70f6b1605b MDL-74471 versions: bump all versions and requires near release 2022-04-13 10:37:36 +08:00
Paul Holden
17dd5bbae0 MDL-74202 webservice: fix protocol type in exception message. 2022-03-25 09:53:23 +00:00
Eloy Lafuente (stronk7)
100bc51f1d MDL-73485 phpunit: externallib, generator and filter tescase names
All externallib_test, generator_test and filter_test classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- 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 tests under testing/tests:

1) The core_testing component doesn't exist.
2) But testing/tests are allowed because there is a suite pointing to it (phpunit.xml).
3) So, the only possible namespace for them is "core".
4) And to avoid problems with other core testcases (under lib/tests)
   they have been renamed to have testing_xxxx as prefix.

Finally, also modified calendar/tests/events/events_test.php because it uses
some renamed (core_calendar_externallib_testcase => \core_calendar\externallib_test)
classes.
2022-01-21 19:48:23 +01:00
Sara Arjona
6ed6520d86 Merge branch 'MDL-73603' of https://github.com/paulholden/moodle 2022-01-20 17:23:42 +01:00
Paul Holden
b385e0da5e MDL-73603 webservice: fix user retrieval in token form callback. 2022-01-17 21:51:39 +00:00
Eloy Lafuente (stronk7)
0c53a3dec8 MDL-73476 phpunit: events, external and search tescase names
All events_test, external_test and search_test classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- 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 lib/external/tests/external_test.php:
- external is not a valid component
- hence, its only valid namespace is "core"
- also, it's testing lib/external/externallib.php
- hence, the file (and class) have been renamed to external_externallib_test.php
  (to avoid conflicts with other external_test that may exist in core)
2022-01-14 16:18:39 +01:00
Andrew Nicols
6c2a64dca1 Merge branch 'MDL-73575' of https://github.com/paulholden/moodle 2022-01-14 09:36:04 +08:00
Paul Holden
ef871e28b5 MDL-73575 webservice: ensure configured protocols are non-empty. 2022-01-13 12:21:29 +00:00
Marina Glancy
6f6586b164 MDL-73564 webservice: make sure to require webservice lib once 2022-01-12 13:19:58 +01:00
Eloy Lafuente (stronk7)
511801cb46 MDL-73352 phpunit: lib_test and locallib_test testcase names
All lib_test and locallib_test classes:

- Namespaced with component (and API whenever makes sense).
- Fixed incorrect use statements with leading backslash.
- Changed code to point to global scope when needed or add new uses.
- All them passing individually.
- Complete runs passing too.

Special mention to tests under login/tests:

1) The core_login component doesn't exist.
2) But login/tests are allowed because there is a suite pointing to it (phpunit.xml).
3) So, the only possible namespace for them is "core".
4) And to avoid problems with other core testcases (under lib/tests)
   they have been renamed to have login_xxxx as prefix.
2021-12-30 16:21:42 +01:00
Paul Holden
d4bd398ad7 MDL-73295 webservice: only pass around sesskey for tokens as needed. 2021-12-29 09:54:23 +00:00
Eloy Lafuente (stronk7)
e4a2d9c1d4 MDL-73348 phpunit: normalize all privacy provider tests
As far as now all them have correct privacy level2 namespace:
- Move them to "privacy" subdir.
- Rename the files to "provider_test.php", this includes old
  privacy_test.php and privacy_provider_test.php files
- Rename the testcase to provider_test too (to match file name)

Also, change some relative paths and comments to point to new
locations.
2021-12-17 14:21:02 +01:00
Eloy Lafuente (stronk7)
57e6fb7ad9 MDL-73348 phpunit: privacy and privacy_provider testcase names
All privacy_test and privacy_provider_test classes:

- Namespaced with component\privacy.
- Fixed incorrect use statements with leading backslash.
- Changed code to point to global scope when needed.
- Renamed a few files to make all be privacy_test or privacy_provider_test.php
- All them passing individually.
- Complete runs passing too.
2021-12-17 14:21:02 +01:00
Jun Pataleta
019df14c00 Merge branch 'MDL-67807-master' of git://github.com/jleyva/moodle 2021-12-03 12:24:42 +08:00
Juan Leyva
a5c48fe780 MDL-67804 webservice: Fix exception class to allow clients treat errors 2021-11-23 16:59:21 +01:00
Juan Leyva
c7e7229ccd MDL-67807 webservice: Return concurrent sessions information 2021-11-19 14:03:37 +01:00
Eloy Lafuente (stronk7)
fdc2dcf264 MDL-72871 cleanup: Remove incorrect whitespace from codebase
Differences can be checked with git diff --ignore-all-space and
that will show that the only non-whitespace change is in a test
in the git lib/tests/html2text_test.php file. In that case the
whitespace has been replaced by a quoted string (of whitespaces)
keeping the test 100% equivalent and workarrounding the whitespace.
2021-10-26 17:19:11 +02:00
Paul Holden
797cff78d5 MDL-72464 webservice: fix detection of non-expiring external tokens. 2021-10-10 20:40:14 +01:00
Paul Holden
7d177640b0 MDL-71760 admin: escape identity fields in token management table. 2021-07-08 23:30:33 +02:00
Eloy Lafuente (stronk7)
9d6aa39985 MDL-71583 versions: Add all the missing full-stops to version/requires
It seems that the new phpcs3 checker is now controlling those
line comments that previously were ignored.

This commit just looks for all the cases and bulk-add
them when needed. The bash script (mac) used to add all them is:

while read -r line; do
    arr=(${line//:/ })
    if [[ -n ${arr[0]} ]] && [[ -n ${arr[1]} ]]; then
        echo "  file ${arr[0]}, line ${arr[1]}"
        sed -i "${arr[1]}s/\$/\./" ${arr[0]}
    fi
done < <(find . -name version.php | xargs ag --nomultiline '>(version|requires) *=.*//.*[^;\.]$')
2021-05-11 20:11:07 +02:00
sam marshall
611e2569aa MDL-71215 core_user: User fields - remaining deprecated functions
This change removes references in code and comments to a few
deprecated functions that were accidentally missed in the larger
change.

The code changes only affect service_users.php. I made it support
custom user profile fields in this query, because it was easy
enough, rather than adding another TODO to fix later.
2021-03-31 11:12:16 +01:00
sam marshall
5e72715e4f MDL-71099 Lib: Move new user_fields class from core to core_user
This class would belong more appropriately within the 'user' API
(core_user) instead of within the 'core' API, since it is
directly related to user data.

Since the class has only just been added to Moodle, now is a good
time to move it.
2021-03-25 13:47:23 +00:00
Jun Pataleta
ebf078458d Merge branch 'MDL-71036' of https://github.com/stronk7/moodle 2021-03-17 20:05:25 +08:00
David Mudrák
4a9f864969 MDL-67748 admin: Add Behat tests for tokens filtering features
Credit goes to Andrew for Behat data generators for webservices.

Co-authored-by: Andrew Nicols <andrew@nicols.co.uk>
2021-03-16 10:51:39 +01:00
David Mudrák
b0fd376db3 MDL-67748 admin: Do not show missing capabilities for mobile app service
We used to display capabilities like "Manage any calendar entries",
"Delete evidence", "Manage competency frameworks", "View hidden courses"
and others as "Missing capabilities" for the mobile app service tokens.

This gave dangerous impression that the app will not work for students
without these capabilities granted. There are known cases of admins who
started to grant all these caps to the Authenticated user role because
they were afraid the app would not work for them.

The problem here is that the official mobile app service includes some
functions that have these capabilities declared as required. But they
are not really required to use the app. Either the app makes its own
clever checks of capabilities before calling the functions, or sometimes
the capabilities are not even correctly declared.

It is safer for everybody to display this information for custom
services only where the risk of the falsely missing caps is lower and
the information is more accurate.

Also, the help text has been improved so it does not suggest that these
capabilities must be always added. We do not know why the service has
them declared. In some cases, a service has capabilities declared just
because it makes use of them in the if-then fashion.

Additionally, the patch also displays the service short name because it
is actually needed to know.
2021-03-15 21:24:06 +01:00
David Mudrák
6ea3588d82 MDL-67748 admin: Show user identity fields on the manage tokens page
On sites with many users, the fullname itself may not be unique
identifier of users. Display the user identity fields below the token
owner's name.
2021-03-15 21:24:06 +01:00
David Mudrák
c4ad1bf2f6 MDL-67748 admin: Add filter to the WS tokens management page
The patch adds ability to filter the list of token by the token value,
the user and the service. Also the button to create a new token is made
more prominent and easier to spot.
2021-03-15 21:24:06 +01:00
David Mudrák
bcd8692fef MDL-67748 admin: Improve the display of tokens the user cannot see 2021-03-15 21:24:06 +01:00
David Mudrák
2c177ae4c1 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 21:24:06 +01:00
David Mudrák
596b0bb23e MDL-67748 admin: Improve the display of missing capabilities
The patch improves the display of the missing capabilities on the Manage
tokens page and the Select authorised users page. The list of
capabilities is rendered in a collapsible area and does not occupy too
much space by default.

Additionally on the later page, the patch improves the display of the
list of existing authorised users so that it respects the configured
identity fields.
2021-03-15 21:24:06 +01:00
David Mudrák
c07f15d791 MDL-67748 admin: Improve get_missing_capabilities_by_users()
The previous implementation falsely reported all implicit capabilities
inherited from the authenticated user archetype. That caused a lot of
capabilities reported as missing, even if they were correctly granted.

This new implementation uses a different logic. Instead of seeking for
explicitly assigned capabilities, it searches for capabilities that are
not assigned to any of the user's role across the system.

Please refer to the inline documentation. This should be still used for
informative reports only, not for actual permissions evaluation. The
context has been ignored here, as well as all the overrides etc. This
patch just makes it a lesser evil.
2021-03-15 21:24:06 +01:00
David Mudrák
0bcaab32ad MDL-67748 admin: Simplify the webservice token form
We can now use the autocomplete element to select the user. No need to
for the legacy behaviour.
2021-03-15 21:24:05 +01:00
David Mudrák
a7f6934297 MDL-67748 admin: Respect the viewfullnames cap at manage tokens table 2021-03-15 21:24:05 +01:00
David Mudrák
db723ad066 MDL-67748 admin: Move the web service token form to its own file 2021-03-15 21:21:43 +01:00
David Mudrák
2bf6db2d5a MDL-67748 admin: Move the web services under the server administration
I suppose the original reasoning was that the web services protocols are
pluggable and that plugins can provide external function. But those are
not good reasons to put the whole Web services section under plugins.
Web services are not a plugin type and they always felt very
counter-intuitive there.

From the server administrtaion perspective, web services are similar to
scheduled tasks and therefore, they should live in the same section.
2021-03-15 21:21:43 +01:00
Eloy Lafuente (stronk7)
713722c3fb 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:04:32 +01:00
Eloy Lafuente (stronk7)
81407f18ec 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:04:31 +01:00
sam marshall
558cc1b85e MDL-45242 Lib: Replace calls to deprecated functions
In all cases changes have been kept to a minimum while not making
the code completely horrible. For example, there are many instances
where it would probably be better to rewrite a query entirely, but
I have not done that (in order to reduce the risk of changes).
2021-03-10 10:57:10 +00:00
Juan Leyva
29c6b17d6b MDL-70128 webservice: New entry point for draftfiles 2020-12-03 14:28:12 +01:00
Eloy Lafuente (stronk7)
f6711bb394 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:45:59 +02:00
Sara Arjona
6bb0262ed8 Merge branch 'MDL-68098-master' of git://github.com/dpalou/moodle into master 2020-10-01 12:56:16 +02:00
Juan Leyva
d2aa3e054f MDL-69283 webservice: New external setting for forcing timezone 2020-09-25 19:08:59 +02:00
Dani Palou
25bc7a3d6b MDL-68098 ws: Add unit tests to test mathjax in WS 2020-09-23 11:18:41 +02:00
Eloy Lafuente (stronk7)
fbb0767536 MDL-69475 versions: bump all versions and requires in master
version = 2021052500 release version
requires= 2021052500 same than version

Why 20210525? (25th May 2021) ?

Because master is going to be Moodle 4.0, to be released
on November 2021. And, until then, we are going to have
a couple of "intermediate" releases:

- Moodle 3.10 to be released 9th November 2020. (2020110900)

  This version will be using versions from today to 2020110900
  (once it's released the YYYYMMDD part stops advancing).

- Moodle 3.11 to be released 10th May 2021. (2021051000)

  This version will be using versions from 3.10 release to 2021051000
  (once it's released the YYYYMMDD part stops advancing).

That means that all versions from today to 2021051000 are going
to be used by those 2 "intermediate" releases (3.10 and 3.11).

And we cannot use them in master, because it's forbidden to have
any overlapping of versions between branches (or different upgrade
paths will fail).

So, get that 2021051000, let's add it a couple of weeks to cover
the on-sync period (or a 2 weeks delay max!) and, the first version
that master can "own" in exclusive (without any overlap) is, exactly,
25th May 2021, hence our 20210525.
2020-08-18 00:47:15 +02:00