Skip to content

Work In Progress

Benjamin Ellis edited this page Feb 17, 2017 · 6 revisions

Work In Progress

[QuickForm2 Migration Advise] (http://pear.php.net/manual/en/package.html.html-quickform2.qf-migration.php)

16th Feb 2017

Laptop issues nearly resolved - had to re-install.

Working on class MoodleQuickForm (lib/form/moodlequickform.php) - removed QuickForm2 parent due to differences in call parameters between the different versions of QuickForm object methods. QuickForm2 object being added as property of MoodleQuickForm as $_qform2. The idea is to map the old calls into new calls.

Only 2 hours done so not much accomplished.

8th Feb 2017

Having decided to upgrade my laptop whilst enjoying my birthday, it did not complete properly and I had to rescue a broken computer that is no longer the same :(

7th Feb 2017

Day off - my birthday - yeah - maybe

6th Feb 2017

Git Repository Setup

Dev Server Setup

QuickForms2 Setup

Realised that to get QF2, need to update Pear libraries including HTML::Common -> HTML::Common2. Other Pear libraries in use are :

Auth::RADIUS

Hacked Notes:

1/ Changed static call to correct alternative (MDL-38373): - From: PEAR::loadExtension('radius'); (in global scope) - To: $this->loadExtension('radius'); (in constructor)

2/ Upgraded to version 1.1.0 (see MDL-51523). Changes made to the lib/pear/Auth/RADIUS.php file that was downloaded. - Added "require_once('PEAR.php')". - Changed the 'Auth_RADIUS' class so that it extends the 'PEAR' class. - Changed the function 'loadExtension' to public.

Crypt::CHAP

Hacked Notes:

MDL-52285 - made all constructors PHP7 compatible

There is a mention of hacks to XML/Parser but library is not included in M3.2. Additionally PEAR libraries have been modified :

_Changed constructors in classes PEAR and PEAR_ERROR to be construct(). This has been already changed upstream in 1.10.0, remove this line after upgrade.

Likely that this will be replicated in new files.

QuickForm Hacks

  • MDL-20876 - replaced split() with explode() or preg_split() where appropriate
  • MDL-40267 - Moodle core_text strlen functions used for range rule rule to be utf8 safe.
  • MDL-46467 - $mform->hardfreeze causes labels to loose their for HTML attribute
  • MDL-52081 - made all constructors PHP7 compatible
  • MDL-52826 - Remove onsubmit events pointing to the global validation functions and script tag moved after the HTML
  • MDL-50484 - _getPersistantData() returns id with _persistant prefixed to element id.
  • MDL-55123 - corrected call to non-static functions in HTML_QuickForm to be PHP7.1-compliant

What's Going to break - lib/ but not in lib/pear/

  • ./formslib.php:require_once 'HTML/QuickForm.php';
  • ./formslib.php:require_once 'HTML/QuickForm/DHTMLRulesTableless.php';
  • ./formslib.php:require_once 'HTML/QuickForm/Renderer/Tableless.php';
  • ./formslib.php:require_once 'HTML/QuickForm/Rule.php';
  • ./formslib.php: include_once('HTML/QuickForm/RuleRegistry.php');
  • ./form/url.php:require_once("HTML/QuickForm/text.php");
  • ./form/checkbox.php:require_once('HTML/QuickForm/checkbox.php');
  • ./form/button.php:require_once("HTML/QuickForm/button.php");
  • ./form/radio.php:require_once('HTML/QuickForm/radio.php');
  • ./form/dateselector.php: include_once('HTML/QuickForm/Renderer/Default.php');
  • ./form/select.php:require_once('HTML/QuickForm/select.php');
  • ./form/filepicker.php:require_once("HTML/QuickForm/button.php");
  • ./form/header.php:require_once 'HTML/QuickForm/header.php';
  • ./form/warning.php:require_once("HTML/QuickForm/static.php");
  • ./form/duration.php: include_once('HTML/QuickForm/Renderer/Default.php');
  • ./form/advcheckbox.php:require_once('HTML/QuickForm/advcheckbox.php');
  • ./form/password.php:require_once('HTML/QuickForm/password.php');
  • ./form/filemanager.php:require_once('HTML/QuickForm/element.php');
  • ./form/hidden.php:require_once('HTML/QuickForm/hidden.php');
  • ./form/submit.php:require_once("HTML/QuickForm/submit.php");
  • ./form/group.php:require_once("HTML/QuickForm/group.php");
  • ./form/group.php: include_once('HTML/QuickForm/Renderer/Default.php');
  • ./form/group.php: // Replicates the separator logic from 'pear/HTML/QuickForm/Renderer/Default.php'.
  • ./form/selectgroups.php:require_once('HTML/QuickForm/element.php');
  • ./form/text.php:require_once("HTML/QuickForm/text.php");
  • ./form/editor.php:require_once('HTML/QuickForm/element.php');
  • ./form/modgrade.php:require_once("HTML/QuickForm/element.php");
  • ./form/recaptcha.php:require_once('HTML/QuickForm/input.php');
  • ./form/listing.php:require_once("HTML/QuickForm/input.php");
  • ./form/grading.php:require_once("HTML/QuickForm/element.php");
  • ./form/selectwithlink.php:require_once('HTML/QuickForm/select.php');
  • ./form/textarea.php:require_once('HTML/QuickForm/textarea.php');
  • ./form/static.php:require_once("HTML/QuickForm/static.php");
  • ./form/datetimeselector.php: include_once('HTML/QuickForm/Renderer/Default.php');
  • ./tests/formslib_test.php: require_once('HTML/QuickForm/Rule/Range.php'); // Requires this pear stuff.

What's Going to break - Outside the lib folder

  • ./grade/grading/form/guide/guideeditor.php:require_once("HTML/QuickForm/input.php");
  • ./grade/grading/form/rubric/rubriceditor.php:require_once("HTML/QuickForm/input.php");
  • ./mod/wiki/editors/wikifiletable.php:require_once('HTML/QuickForm/element.php');
  • ./mod/assign/gradeform.php:require_once('HTML/QuickForm/input.php');

Migration Attempt

  • Replace lib/pear folder contents with updated PEAR libraries

  • Replaced Tableless libraries with QuickForm2 - in lib/formslib.php

    • HTML_QuickForm_DHTMLRulesTableless -> HTML_QuickForm2
    • HTML_QuickForm_Renderer_Tableless -> HTML_QuickForm2_Renderer
  • Call to HTML::Common in MoodleQuickForm::__construct() replaced with HTML::Common2 call

  • Attempt run - login OK but errors:

    • PHP Strict Standards: Declaration of MoodleQuickForm::addRule() should be compatible w ith HTML_QuickForm2_Node::addRule($rule, $messageOrRunAt = '', $options = NULL, $runAt = HTML_QuickForm2_Rule::SERVER) in /mnt/data/www/moodleqf2/html/lib/formslib.php
    • PHP Fatal error: Declaration of MoodleQuickForm_Renderer::renderElement() must be comp atible with HTML_QuickForm2_Renderer::renderElement(HTML_QuickForm2_Node $element) in /mnt/data/www/moodleqf2/html/lib/formslib.php
  • Split all classes out of lib/formslib.php - as per coding standard and to make life easier

    • class moodleform -> lib/form/moodleform.php
    • class MoodleQuickForm -> lib/form/moodlequickform.php
    • class MoodleQuickForm_Renderer -> lib/form/moodlequickform_renderer.php
    • class MoodleQuickForm_Rule_Required -> lib/form/moodlequickform_rule_required.php

Done for The Day