714 Commits

Author SHA1 Message Date
Marina Glancy
1766e6a17f MDL-52284 core: PHP7 engine errors have type Throwable 2015-12-10 10:49:37 +08:00
David Monllao
0ee52b8214 Merge branch 'MDL-51830-master' of git://github.com/lucisgit/moodle 2015-12-03 11:11:04 +01:00
Marina Glancy
49f3c89324 MDL-52332 calendar: load settings using API 2015-11-30 11:36:50 +08:00
David Mudrák
ade03c067a MDL-52214 core: Fix case sensitivity in user agent comparison
The previous 2.9 implementation of is_web_crawler() used stripos() in
certain cases. The unit tests re-added in the previous commit revealed
that certain crawlers (such as BaiDuSpider) were not correctly detected
in the new refactored implementation.

It seems lesser evil and safe enough to use /i in the regex search even
though it is not 100% same logic as before - as stripos() was used in
some cases only, not always.
2015-11-23 09:44:43 +01:00
Ruslan Kabalin
fa29c0c3d4 MDL-51830 course: Add course section deletion event. 2015-11-12 11:19:37 +00:00
Andrew Nicols
693ed49c10 Merge branch 'MDL-51707-m' of https://github.com/micaherne/moodle 2015-11-02 14:36:10 +08:00
Eloy Lafuente (stronk7)
7c549a17f4 MDL-51893 core_date: Stop using Pacific/Norfolk as 11.5 replacement
Norfolk Island's standard time (NFT) was on UTC+11:30 until 4 October
2015, when it was changed to UTC+11:00. So it's not suitable for 11.5
bad mapping replacement anymore.

It seems that there isn't any other location using such 11.5 timezone
so completely getting rid of it for conversions.
2015-10-27 10:17:05 +01:00
Dan Poltawski
0a05907873 Merge branch 'MDL-51737-master-3' of git://github.com/andrewnicols/moodle 2015-10-22 14:43:20 +01:00
Andrew Nicols
39a731efb4 MDL-51737 core: Add Edge UserAgent support 2015-10-22 08:37:27 +08:00
Eloy Lafuente (stronk7)
9062fa25ae Merge branch 'MDL-49329-master-multiplug' of git://github.com/mudrd8mz/moodle 2015-10-19 18:10:40 +02:00
David Mudrák
c8a6d162a0 MDL-51832 tests: Fix failing code manager unit tests on Windows 2015-10-19 18:08:59 +02:00
Dan Poltawski
293197afb3 Merge branch 'MDL-49329-master-multiplug' of git://github.com/mudrd8mz/moodle 2015-10-16 14:53:26 +01:00
Dan Poltawski
52fa3d09d7 Merge branch 'MDL-51563-master' of git://github.com/jleyva/moodle 2015-10-15 13:50:10 +01:00
Mark Nelson
f74fe5ba52 MDL-51781 tool_log: marked log values as NOT_MAPPED if mapping not found 2015-10-15 01:25:43 -07:00
David Monllao
ee58df52da Merge branch 'MDL-46455-master-20151012' of git://github.com/damyon/moodle 2015-10-13 11:42:40 +08:00
Juan Leyva
d1b30757bd MDL-51563 core_user: Fix invalid passed parameteres in get_user 2015-10-12 13:53:57 +02:00
Damyon Wiese
ac82a9a8b4 MDL-46455 Events: Add db mapping info even if not part of backup
We can return db mapping info even for objects that are not included
in backup/restore and it may be useful in future (no use in core yet).
2015-10-12 16:41:02 +08:00
Mark Nelson
607021c14b MDL-46455 events: added more mapping
Also fixed a few bugs.
2015-10-11 18:52:36 -07:00
Damyon Wiese
63b5a5faad MDL-46455 event: Make the debugging messages print the event class.
Because they are in the base class, it was impossible to find which event
triggered the debugging.
2015-10-11 18:14:58 -07:00
Damyon Wiese
0817451470 MDL-46455 events: Add mapping info to events
This commit covers all events outside of /mod/. It adds mapping info for restoring
events, or the default implementation which returns false if mapping is not required.
2015-10-11 18:14:58 -07:00
Mark Nelson
901a7ff7f2 MDL-46455 restore: added restore support for 'other' in events 2015-10-11 18:14:51 -07:00
David Mudrák
30c264211e MDL-49329 admin: Fix reported coding style warnings 2015-10-10 09:15:27 +02:00
David Mudrák
dbdd02c1fe MDL-49329 admin: Start using API 1.3 for fetching available updates
This is not really necessary as there is no actual change in the
behaviour of the updates API between 1.2 and 1.3. However, as we plan to
use the new \core\update\api client for this in the future, it makes
only sense to have these two synced already now. In other words, Moodle
3.0 site will use the same version 1.3 for all download.moodle.org/api
end points.
2015-10-10 09:15:27 +02:00
David Mudrák
b0fc789878 MDL-49329 admin: Clean up disabling of plugins code management features
The admin setting updateautodeploy no longer exists. The two existing
config.php flags $CFG->disableupdateautodeploy and
$CFG->disableonclickaddoninstall merged into a single one.
2015-10-10 09:11:19 +02:00
Mark Nelson
6920d3904c MDL-46455 restore: added restore support for the 'objectid' in events 2015-10-09 16:23:09 -07:00
David Mudrák
c20e9ae836 MDL-49329 admin: Add ability to cancel upgrade of the plugin
If there is an available archived zip with the version of the plugin
currently installed, we can use it to cancel/abort the upgrade of the
plugin. This is internally handled as the installation of the archived
zip and goes through all the validation and confirmation.

Additionally, some other parts were improved. Most notably, renderer no
longer decides itself if some installation can be cancelled but it
always asks the controller (plugin manager).

The button for installation was moved to the left so there should be
first buttons to add things, and then buttons to cancel things (which is
common in normal forms).
2015-10-09 23:37:32 +02:00
David Mudrák
80c3c6501d MDL-49329 admin: Clean up code manager methods
The method move_plugin_directory() was a relict from previous 2.9
implementation within tool_installadon_installer and was originally
supposed to be used to move whole plugin folders. The archiving feature
has been finally implemented via using zip files (so that we do not have
actual PHP code present in the dataroot) and we do not need this method.
2015-10-09 14:43:33 +02:00
David Mudrák
a2e1e0d0f1 MDL-49329 admin: Archive plugin code before removing it from dirroot
This should allow the admin to revert the upgrade of existing plugins,
such when the dependency chain leads to a dead-end. Additionally, we
archive (as a last-chance copy) the to-be-installed plugins when
cancelling their installation. This is mainly for developers who could
otherwise loose their code. For the same reason, plugins are being
archived upon uninstallation, too.
2015-10-09 14:33:47 +02:00
Dan Poltawski
0496ac6305 MDL-50788 classloader: Prevent cryptic errors on unreadable classes dir
Do not attempt to read an unreadable directory because previously the generated
errors were hard to fathom.

Thanks to James McQuillan for the basis of the patch.
2015-10-09 10:36:59 +01:00
David Mudrák
4d7528f9bc MDL-49329 admin: Require confirmation before cancelling plugin install 2015-10-09 09:50:46 +02:00
David Mudrák
2d00be61f1 MDL-49329 admin: Make plugin manager able to install from local zips too
The plugin manager's method install_remote_plugins() has been changed to
install_plugins() and it is now able to install plugins from the
provided list of locally available ZIP files, too. This is used by the
Install plugins admin tool.
2015-10-09 09:50:46 +02:00
David Mudrák
da54cf11a4 MDL-49329 admin: Call opcache_reset() after installing new plugin code
During the testing, I was experiencing weird behaviour - after a single
plugin updated was installed, I ended up on admin/index.php?cache=1. I
believe it was caused by the missing opcache_reset().
2015-10-09 09:50:45 +02:00
David Mudrák
c948b813ae MDL-49329 admin: Add plugin manager method for installing remote packs
The new method core_plugin_manager::install_remote_plugins() will serve
as a backend for all the ways of installing ZIP packages from the moodle
plugins directory, such as installing new plugins (by clicking the
Install button in the plugins directory), installing available updates
(single and bulk mode) and installing missing dependencies (single and
bulk mode).

The method should be used both for validation pre-check screen and,
after the confirmation, for actual installation. Note that we
intentionally repeat the whole procedure after confirmation. Unzipping
plugins is cheap and fast and the ZIPs themselves are already available
in the \core\update\code_manager's cache.

We will need to add support for archiving existing code to prevent
accidental data-loss.

This basically provides what mdeploy.php was doing, but better. We now
have consistent way of installing all remote ZIP packages, always
validate them and we can perform bulk operations, too.
2015-10-09 09:50:44 +02:00
David Mudrák
8acee4b53d MDL-49329 admin: Improve the plugin package validator
Previously, the validator was used for installation of the new plugins
only. We now validate every incoming plugin package. As a result, we
must no longer insists on the target location is empty. Instead, warning
is raised.
2015-10-08 23:32:05 +02:00
David Mudrák
fd2d146218 MDL-49329 admin: Validate the contents of the cached plugin ZIP package 2015-10-08 23:32:05 +02:00
David Mudrák
4f18a4e60c MDL-49329 admin: Introduce new \core\update\remote_info class
This is just a thin wrapper for normal objects, allowing us to have
explicit type hinting / declarations in method signatures.
2015-10-08 23:32:05 +02:00
David Mudrák
cc5bc55ead MDL-49329 admin: Add core_plugin_manager::available_updates() method
The new method is going to be used to support the "Update all plugins"
feature.
2015-10-08 23:32:04 +02:00
David Mudrák
3bca7dbfa6 MDL-49329 admin: Get rid of mdeploy and \core\update\deployer class
The mdeploy.php standalone script (used to download and unzip plugins
into the dirroot) and the \core\update\deployer class (as a
communication bridge between the core and the mdeploy.php) was
originally designed and implemented with the assumption that it would be
eventually used for updating the Moodle core itself, too. Therefore it
was written as standalone utility without dependency on the Moodle core
libraries.

However, it never happened and there is no real demand for that. So now
there is no need to have and maintain a completely parallel solution for
common things like fetching and unzipping plugin ZIPs.

Additional reasoning for mdeploy.php was that the core is not very
reliable during the core upgrade and we could run into various troubles.
This does not seem to be that bad. We rely on a lot of core
functionality (such as output rendering, DB access etc) and plugins
deployment seems to work well (and better) with common core libraries.

So long mdeploy, and thanks for all the hard work you did for us.
2015-10-08 23:32:04 +02:00
David Mudrák
36977a6d08 MDL-49329 admin: If unable to install a plugin, display the reason 2015-10-08 23:32:04 +02:00
David Mudrák
4441d5e5fb MDL-49329 admin: Fix report on required core version in missing plugins
If the plugin was missing from disk, the required core version was
displayed as "Moodle {$a}" because the core dependency resolver always
returns an object.
2015-10-08 23:32:04 +02:00
David Mudrák
35f2b67442 MDL-49329 admin: Fix the API for getting remote plugin info
The previous version of the plugin manager's method
get_remote_plugin_info() was suitable for installing missing
dependencies only. To make use of for installing new plugins and/or
available updates, it must be clear that we are requesting information
for the particular plugin version only, not "given or higher" version.
2015-10-08 23:32:04 +02:00
David Mudrák
d6e38c2a9d MDL-49329 admin: Validate pluginfo service response
The new client's method makes sure that the returned data structure has
expected format so that the plugin manager can safely rely on it.
2015-10-08 23:32:04 +02:00
David Mudrák
9137a89a1a MDL-49329 admin: Improve the UI for installing dependencies 2015-10-08 23:32:03 +02:00
David Mudrák
2f29cf6e63 MDL-49329 admin: Add ability to cancel installation of a new plugin
The plugins check screen now provides buttons to cancel installation of
a plugin. Available only for new installations (not upgrades) and for
additional plugins (not standard), given that the web server process has
write access to the plugin folder.

This has also been reported as MDL-48535.

As a part of the patch, there is improved processing of page URLs during
the upgrade. All this dancing around $reload URL is not needed once the
$PAGE->url is properly set to guide the admin on the correct page during
the upgrade process.
2015-10-08 23:32:03 +02:00
David Mudrák
f2d8ed45e3 MDL-49329 admin: Introduce new \core\update\validator class
This is not really new class. Originally, the validator was implemented
in the scope of the tool_installaddon plugin. But we need its features
in other parts at the core level (e.g. during the upgrade to validate
available missing dependencies or available updates). Looking back, it
was a mistake to have it implemented at the plugin level rather than the
core level.

So this patch moves the tool_installaddon_validator class to
\core\update\validator class, together with associated unit tests,
fixture files and strings. There were changes made in the
tool_installaddon to make use of this new class instead of the old one.

This is a great step towards the bright future, hopefully there won't be
many regressions.

AMOS BEGIN
 MOV [validationmsg_componentmatch,tool_installaddon],[validationmsg_componentmatch,core_plugin]
 MOV [validationmsg_componentmismatchname,tool_installaddon],[validationmsg_componentmismatchname,core_plugin]
 MOV [validationmsg_componentmismatchname_help,tool_installaddon],[validationmsg_componentmismatchname_help,core_plugin]
 MOV [validationmsg_componentmismatchname_info,tool_installaddon],[validationmsg_componentmismatchname_info,core_plugin]
 MOV [validationmsg_componentmismatchtype,tool_installaddon],[validationmsg_componentmismatchtype,core_plugin]
 MOV [validationmsg_componentmismatchtype_info,tool_installaddon],[validationmsg_componentmismatchtype_info,core_plugin]
 MOV [validationmsg_filenotexists,tool_installaddon],[validationmsg_filenotexists,core_plugin]
 MOV [validationmsg_filesnumber,tool_installaddon],[validationmsg_filesnumber,core_plugin]
 MOV [validationmsg_filestatus,tool_installaddon],[validationmsg_filestatus,core_plugin]
 MOV [validationmsg_filestatus_info,tool_installaddon],[validationmsg_filestatus_info,core_plugin]
 MOV [validationmsg_foundlangfile,tool_installaddon],[validationmsg_foundlangfile,core_plugin]
 MOV [validationmsg_maturity,tool_installaddon],[validationmsg_maturity,core_plugin]
 MOV [validationmsg_maturity_help,tool_installaddon],[validationmsg_maturity_help,core_plugin]
 MOV [validationmsg_missingcomponent,tool_installaddon],[validationmsg_missingcomponent,core_plugin]
 MOV [validationmsg_missingcomponent_help,tool_installaddon],[validationmsg_missingcomponent_help,core_plugin]
 MOV [validationmsg_missingcomponent_link,tool_installaddon],[validationmsg_missingcomponent_link,core_plugin]
 MOV [validationmsg_missingexpectedlangenfile,tool_installaddon],[validationmsg_missingexpectedlangenfile,core_plugin]
 MOV [validationmsg_missingexpectedlangenfile_info,tool_installaddon],[validationmsg_missingexpectedlangenfile_info,core_plugin]
 MOV [validationmsg_missinglangenfile,tool_installaddon],[validationmsg_missinglangenfile,core_plugin]
 MOV [validationmsg_missinglangenfolder,tool_installaddon],[validationmsg_missinglangenfolder,core_plugin]
 MOV [validationmsg_missingversion,tool_installaddon],[validationmsg_missingversion,core_plugin]
 MOV [validationmsg_missingversionphp,tool_installaddon],[validationmsg_missingversionphp,core_plugin]
 MOV [validationmsg_multiplelangenfiles,tool_installaddon],[validationmsg_multiplelangenfiles,core_plugin]
 MOV [validationmsg_onedir,tool_installaddon],[validationmsg_onedir,core_plugin]
 MOV [validationmsg_onedir_help,tool_installaddon],[validationmsg_onedir_help,core_plugin]
 MOV [validationmsg_pathwritable,tool_installaddon],[validationmsg_pathwritable,core_plugin]
 MOV [validationmsg_pluginversion,tool_installaddon],[validationmsg_pluginversion,core_plugin]
 MOV [validationmsg_release,tool_installaddon],[validationmsg_release,core_plugin]
 MOV [validationmsg_requiresmoodle,tool_installaddon],[validationmsg_requiresmoodle,core_plugin]
 MOV [validationmsg_rootdir,tool_installaddon],[validationmsg_rootdir,core_plugin]
 MOV [validationmsg_rootdir_help,tool_installaddon],[validationmsg_rootdir_help,core_plugin]
 MOV [validationmsg_rootdirinvalid,tool_installaddon],[validationmsg_rootdirinvalid,core_plugin]
 MOV [validationmsg_rootdirinvalid_help,tool_installaddon],[validationmsg_rootdirinvalid_help,core_plugin]
 MOV [validationmsg_targetexists,tool_installaddon],[validationmsg_targetexists,core_plugin]
 MOV [validationmsg_targetexists_help,tool_installaddon],[validationmsg_targetexists_help,core_plugin]
 MOV [validationmsg_unknowntype,tool_installaddon],[validationmsg_unknowntype,core_plugin]
 MOV [validationmsg_versionphpsyntax,tool_installaddon],[validationmsg_versionphpsyntax,core_plugin]
 MOV [validationmsglevel_debug,tool_installaddon],[validationmsglevel_debug,core_plugin]
 MOV [validationmsglevel_error,tool_installaddon],[validationmsglevel_error,core_plugin]
 MOV [validationmsglevel_info,tool_installaddon],[validationmsglevel_info,core_plugin]
 MOV [validationmsglevel_warning,tool_installaddon],[validationmsglevel_warning,core_plugin]
AMOS END
2015-10-08 23:32:03 +02:00
David Mudrák
0e442ee776 MDL-49329 admin: Introduce new \core\update\core_manager tool
The plan is to have a single tool looking after all operations with
plugin ZIP packages (downloading, unzipping, moving to the dirroot and
back). For legacy reasons, we have that logic currently duplicated in
mdeploy and tool_installaddon. I would like to unify and simplify the
whole machinery to use the same code for available updates, manual
installation and plugin dependencies.
2015-10-08 23:32:03 +02:00
David Mudrák
5a92cd0b8d MDL-49329 admin: Display missing dependencies on plugins check screen
The patch improves the dependencies resolution in the plugin manager so
that the information about availability of the missing dependency is
included and can be displayed at the Plugins check screen during the
upgrade.
2015-10-08 23:32:03 +02:00
David Mudrák
48900324b3 MDL-49329 admin: Introduce new \core\update\api client class
The purpose of this class is to provide a general client for all APIs
available at https://download.moodle.org/api/ (e.g. available updates,
plugin info, plugins list etc). Currently, fetching data from this API
is done separately at several places. This leads to code duplication and
harder maintenance (I know it well).

Additionally, the existing client was implemented as
tool_installaddon_pluginfo_client in the admin/tool/installaddon/ scope.
I will soon need to use the same functionality in the
core_plugin_manager and it would hurt my karma if the core was depending
on a class provided by a admin tool plugin (even if it is standard one).

So, there is new \core\update\api client implementing the version 1.3 of
the pluginfo API. There is a TODO note left for remaining services.
2015-10-08 23:32:03 +02:00
David Mudrák
7eb87eff65 MDL-49329 admin: Move requirements resolving to the plugin manager
The patch moves the resolving logic from the renderer (where it should
not really be) to the plugin manager (controller). This is needed
because we will need the very same logic to be used at other places.
2015-10-08 23:32:02 +02:00
David Mudrák
c44bbe35bf MDL-49329 admin: Improve loading of available updates info
The actual loading of available updates info objects is moved back to
the plugin manager class. As we can now mockup the manager in unit
tests, this allows us to bypass the real \core\update\checker and have
unit tests for \core\plugininfo\base::available_updates().
2015-10-08 23:32:02 +02:00