start:overrides

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
start:overrides [2026/02/08 19:28] – [Customcripts] adminstart:overrides [2026/03/26 16:08] (Version actuelle) – [Tracking patches and customscriptings needs in plugin design] admin
Ligne 25: Ligne 25:
 Now we can address the notion of "Trouble". "Trouble" is a subjective notion, and wil not affect all actors the same way. Maintainers will have "Trouble" in having to maintain complex things and make it available for users. Users will be troubled in not having friendly enough or unefficiant tools, stakeholders will be troubled to get informed and harassed that thing do NOT WORK well. Now we can address the notion of "Trouble". "Trouble" is a subjective notion, and wil not affect all actors the same way. Maintainers will have "Trouble" in having to maintain complex things and make it available for users. Users will be troubled in not having friendly enough or unefficiant tools, stakeholders will be troubled to get informed and harassed that thing do NOT WORK well.
  
 +Now let propose a structural definition of the Trouble:
 +
 +<html><center style="font-size:170%">$Tb = k * \frac{Imp}{\sum_{r=1}^n{dCUi * NUi}}$</center></html>
 +
 +Let's explain now...
 +
 +The trouble raises when the Technical Impact raises. We just add a k constant factor to adjust units and scales.
 +
 +Oppositely, the trouble decreases when the "gain in process" (dCU) per user in a certain role and the role population (NU, as number of users) increases. In other words, the more users can gain in their own process (gain of time, gain of mental load), the more affordable the Technical Impact will be for the organisation.
  
  
Ligne 36: Ligne 45:
    $CFG->customscripts = '<moodlepath>/customscripts';    $CFG->customscripts = '<moodlepath>/customscripts';
  
-In your config file, then any request to a php script say: ''https:<nowiki>//</nowiki><mymoodle>/a/b/c.php'' that encounters an existing file names ''/customscripts/a/b/c.php'' will be derouted at end of the ''setup.php'' initialisation to that file, includes the file, then continue normal processing. +In your config file, then any request to a php script say: ''https:<nowiki>//</nowiki><mymoodle>/a/b/c.php'' that encounters an existing file named ''/customscripts/a/b/c.php'' will be derouted at end of the ''setup.php'' initialisation to that file, includes the file, then continue normal processing
 + 
 +Customscripts MUST NOT include ''config.php'', because it has already be done before routing to customscript. 
 + 
 +By ending the customscript by a ''die()'' or ''exit()'', the customscripted script REPLACES the standard behaviour. 
 + 
 +Customscripts MUST NOT redefine classes, functions or any "compilation time definitions", as the standard version has already be loaded into memory. 
 + 
 +===Good cases=== 
 + 
 +Customscripts work fine when the change is very superficial, and resides in the moodle page itself (vs. a deeper library). 
 + 
 +===Less good cases=== 
 + 
 +When the change is deeper, customscripting will force you to deroute deeper calls to derouted APIs, so the code path may need a lot of work to reach the changing point.   
 + 
 +Too complicated derouting will lead to replacing a LOT of standard code. As the standard code is occulted in your Moodle, it will not reveal upgrades or bugfixes, so your replaced code will diverge slowly from moodle standard state of the art. this can be problematic.
  
 ====Core patchs==== ====Core patchs====
  
 +Core patchs are the last extremity of overriding core code. All moodle developers are conscious that patching **IS BAD**, but sometime are the only reasonable solution we have to make things work as they //should work//.
 +
 +Core patches rais a real issu of middle term and long term maintenance, because upgrading a moodle instance results in a non trivial operation:
 +
 +   * **Trivial way (no patchs):** Get the moodle Zip archive, unpack it, copy all other third party plugins in it. check third party compatibility level, and upgrade, and that's it.
 +   * **Non trivial way (some patchs):** Do the some way than trivial **PLUS** report all patchs from the previous code base to the new codebase.
 +
 +and THIS can be the tough part, specially if:
 +
 +   * Patchs are **not documented**
 +   * Patchs are **not properly tagged** and identified in the code
 +   * There is **no tool** to help the process
 ====Tracking patches and customscriptings needs in plugin design==== ====Tracking patches and customscriptings needs in plugin design====
 +
 +In our plugins, a common structure to self-document and provide out-of-the-band info about moodle alteration we need to get the plugin run correctly is given as '<nowiki>__</nowiki>' prefixed directories in the plugin.
 +
 +   * **<nowiki>__</nowiki>patch:** contains core files with patches serving this plugin.
 +   * **<nowiki>__</nowiki>customscripts:** contains files to add to the moodle local 'customscript' folder, as defined in ''config.php'' with the key ''$CFG->customscripts''.
 +   * **<nowiki>__</nowiki>reference:** contains core files who serve as core source reference for the patchs, and are snapshot when the plugin is reviewed and packaged. Your installed core files may be somewhat different, if your minor version is not the exact one we use in our development faciity. 
 +
 +===What happens if several plugins need patching/customscripting the same files===
 +
 +This is a more tricky situation that can happen, as we aim to keep the modularity concept of Moodle as clean as possible, which means, many plugin do not have to car another plugin exist, moreover if there is no functional relation between them.
 +
 +As a consequence, a general packing rule has been to only pack whate was relative to the current plugin (or pluginset in case of real unbreakabke bundles).
 +
 +So it may be possible that assembling several unrelated plugins might need to overload the same core files.
 +
 +In case of patchs, all patchs are bounded strictly in ''<nowiki>//</nowiki> PATCH+'' and ''<nowiki>//</nowiki> PATCH-'' comments, so they are easy to locate in the code. In the future, we will have to make some effort in generalizing the @see tag so each patch refers to the plugin that required it.
 +
 +In case of customscripts, the case of collision is also possible. In most case we try to use ''<nowiki>//</nowiki> CHANGE +'' and ''<nowiki>//</nowiki> CHANGE-'' comments to locate them.
  
 [[:start|Back to general index]] [[:start|Back to general index]]
start/overrides.1770578891.txt.gz · Dernière modification : de admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki