Skip to content

Bugfix SVG logo upload#65

Merged
bluetom merged 1 commit into
mainfrom
bugfix-svg-logo
Jun 3, 2026
Merged

Bugfix SVG logo upload#65
bluetom merged 1 commit into
mainfrom
bugfix-svg-logo

Conversation

@lenaherf

@lenaherf lenaherf commented Jun 3, 2026

Copy link
Copy Markdown

Note: Please fill out all relevant sections and remove irrelevant ones.

🔀 Purpose of this PR:

  • Fixes a bug
  • Updates for a new Moodle version
  • Adds a new feature of functionality
  • Improves or enhances existing features
  • Refactoring: restructures code for better performance or maintainability
  • Testing: add missing or improve existing tests
  • Miscellaneous: code cleaning (without functional changes), documentation, configuration, ...

📝 Description:

This PR fixes the bug that appeared when uploading an SVG file with a format that was not supported. This threw an uncaught DivisionByZero error on PHP 8+.

The root cause is in classes/output_image.php, method get_logo_aspect_ratio(): the function unconditionally reads index [2] and [3] from the exploded viewBox attribute. If the uploaded SVG has no viewBox attribute, these indices are undefined and the resulting '' / '' division crashes the request on PHP 8+.

With the bugfix it is possible to also upload SVG files that only have width/heigt attributes.


📋 Checklist

Please confirm the following (check all that apply):

  • I have phpunit and/or behat tests that cover my changes or additions.
  • Code passes the code checker without errors and warnings.
  • Code passes the moodle-ci/cd pipeline on all supported Moodle versions or the ones the plugin supports.
  • Code does not have var_dump() or var_export or any other debugging statements (or commented out code) that
    should not appear on the productive branch.
  • Code only uses language strings instead of hard-coded strings.
  • If there are changes in the database: I updated/created the necessary upgrade steps in db/upgrade.php and
    updated the version.php.
  • If there are changes in javascript: I build new .min files with the grunt amd command.
  • If it is a Moodle update PR: I read the release notes, updated the version.php and the CHANGES.md.
    I ran all tests thoroughly checking for errors. I checked if bootstrap had any changes/deprecations that require
    changes in the plugins UI.

🔍 Related Issues

  • Related to #64

🧾📸🌐 Additional Information (like screenshots, documentation, links, etc.)

Any other relevant information.


@lenaherf lenaherf marked this pull request as ready for review June 3, 2026 12:32
@bluetom bluetom merged commit dd8c772 into main Jun 3, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants