From 44c332251eb27dbbef4a71be52dd8da133ea2e3d Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Thu, 29 Jan 2026 13:13:59 +0800 Subject: [PATCH] MDL-87789 libraries: patch lti1p3 for certification support https://github.com/packbackbooks/lti-1-3-php-library/issues/169 blocks us from using the new build.1edtech certification tooling. This issue commits that fix as a library customisation/hack for stables, so the suite can be used for annual/bi-annual re-certification. --- public/lib/lti1p3/readme_moodle.txt | 20 +++++++++++-------- .../lti1p3/src/DeepLinkResources/Resource.php | 6 +++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/public/lib/lti1p3/readme_moodle.txt b/public/lib/lti1p3/readme_moodle.txt index ddb6b0778b4..09dc16be20f 100644 --- a/public/lib/lti1p3/readme_moodle.txt +++ b/public/lib/lti1p3/readme_moodle.txt @@ -2,19 +2,23 @@ LTI 1.3 Tool Library import instructions This library is a patched for use in Moodle - it requires the following changes be applied on top of the packback upstream base: 1. Removal of phpseclib dependency (replaces a single call with openssl equivalent) +2. The fix included in MDL-87789, ensuring optional lineitem properties are omitted if not set. To upgrade to a new version of this library: 1. Clone the latest version of the upstream library from github: https://github.com/packbackbooks/lti-1-3-php-library/tags 2. Apply the changes mentioned above from the moodle-fixes branch of this repository: https://github.com/snake/lti-1-3-php-library/tree/moodle-fixes +3. Apply the local fix to the library from MDL-87789, unless already fixed +upstream (https://github.com/packbackbooks/lti-1-3-php-library/issues/169) Apply these commits on top of the upstream clone. -3. Replace lib/lti1p3/src/ with the library's /src directory -4. Copy LICENSE.md to lib/lti1p3/ -5. Copy README.md to lib/lti1p3/ -6. Update the library entry in lib/thirdpartylibs.xml -7. Update the dependency note in lib/php-jwt/readme_moodle.txt, recording the version of php-jwt lib/lti1p3 depends on, if needed. -8. Check the upstream library's release notes and UPGRADES.md for any backwards incompatible changes to names, etc. +4. Replace lib/lti1p3/src/ with the library's /src directory +5. Copy LICENSE.md to lib/lti1p3/ +6. Copy README.md to lib/lti1p3/ +7. Copy composer.json to lib/lti1p3/ +8. Update the library entry in lib/thirdpartylibs.xml +9. Update the dependency note in lib/php-jwt/readme_moodle.txt, recording the version of php-jwt lib/lti1p3 depends on, if needed. +10. Check the upstream library's release notes and UPGRADES.md for any backwards incompatible changes to names, etc. Moodle's calling code may require updates if changes are breaking - so check this and make any changes if needed. -9. Run all unit tests in enrol/lti and auth/lti. -10. Regression test Moodle-to-Moodle LTI using LTI Advantage (not legacy) using the relevant MDLQA tests as a guide. +11. Run all unit tests in enrol/lti and auth/lti. +12. Regression test Moodle-to-Moodle LTI using LTI Advantage (not legacy) using the relevant MDLQA tests as a guide. diff --git a/public/lib/lti1p3/src/DeepLinkResources/Resource.php b/public/lib/lti1p3/src/DeepLinkResources/Resource.php index 16a11c389f5..730602af51a 100644 --- a/public/lib/lti1p3/src/DeepLinkResources/Resource.php +++ b/public/lib/lti1p3/src/DeepLinkResources/Resource.php @@ -50,9 +50,9 @@ class Resource if (isset($this->line_item)) { $resource['lineItem'] = [ 'scoreMaximum' => $this->line_item->getScoreMaximum(), - 'label' => $this->line_item->getLabel(), - 'resourceId' => $this->line_item->getResourceId(), - 'tag' => $this->line_item->getTag(), + ...(!is_null($this->line_item->getLabel()) ? ['label' => $this->line_item->getLabel()] : []), + ...(!is_null($this->line_item->getResourceId()) ? ['resourceId' => $this->line_item->getResourceId()] : []), + ...(!is_null($this->line_item->getTag()) ? ['tag' => $this->line_item->getTag()] : []), ]; }