I wonder why I wrote "please post a patch here before commit" above
Anyway here is a review:
–
1/ It is strongly discouraged to use functions from libraries in main db/upgrade.php, the reason is that the library may require some db structure that is not yet upgraded - we were bitten by this many times before in roles code, so please remove the following and replace it with hardcoded db inserts:
require_once($CFG->libdir . '/licenselib.php');
license_manager::install_licenses();
Please note the plugin upgrades are something different, there we should always use the latest API calls.
—
2/ Hmm, how are we going to deal with translation of license names?
—
3/ why is the enabled flag in the license table? when and how is it going to be used?
In general if some setting is used more often we store it in the config table and access through the CFG because it is one less DB query.
—
4/ grrrr - the new setting adds one more db query to admin tree loading - please please stop adding more requests there, we do need to lower the number there significantly - simply add new config class which loads the options only when necessary and also requires the lib only when really necessary.
—
5/ I guess you have forgotten to install the licenses in fresh new installs, right? (db/install.php)
–
6/ I do not think it is good idea to add the default license when adding new file - that is really asking for legal trouble, better to know we actually do not know the license
if ($file_record->license === '') {
$file_record->license = $CFG->sitedefaultlicense;
}
–
7/ please, stop doing this in all new code:
if ($license_id = $DB->insert_record('license', $license)) {
–
8/ the new standard for empty result from license_manager::get() should be array() instead of null, the same way as $DB->get_records()
license_manager::get() returns NULL, object or array of objects - that is weird, it should return only array
please do not invent those superflexible function parameters again - create two separate methods with different parameters instead if really necessary
–
9/ I absolutely do not understand the hardcoded list of license in the licenseib.php.
- How can I add my own licenses.
- Why does it link only english version
- How are we going to upgrade this list?
- What does the "enable" actually mean - previous existing files in moodle are made inancessible? Is it only for external systems?
–
10/ how does somebody specify the license when uploading new file from local PC?
–
11/
Oops, issue description doesn't support text formatting.