stronk7

Untitled

Dec 10th, 2019
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.28 KB | None | 0 0
  1. index 87b3c8ac475..8cf9ffcdc6d 100644
  2. --- a/lib/filestorage/file_system.php
  3. +++ b/lib/filestorage/file_system.php
  4. @@ -416,11 +416,16 @@ abstract class file_system {
  5.      protected function get_imageinfo_from_path($path) {
  6.          $imageinfo = getimagesize($path);
  7.  
  8. +        if (!is_array($imageinfo)) {
  9. +            return false; // Nothing to process, the file was not recognised as image by GD.
  10. +        }
  11. +
  12.          $image = array(
  13. -                'width'     => !empty($imageinfo[0]) ? $imageinfo[0] : null,
  14. -                'height'    => !empty($imageinfo[1]) ? $imageinfo[1] : null,
  15. -                'mimetype'  => !empty($imageinfo[2]) ? image_type_to_mime_type($imageinfo[2]) : null,
  16. +                'width'     => $imageinfo[0],
  17. +                'height'    => $imageinfo[1],
  18. +                'mimetype'  => image_type_to_mime_type($imageinfo[2]),
  19.              );
  20. +
  21.          if (empty($image['width']) or empty($image['height']) or empty($image['mimetype'])) {
  22.              // GD can not parse it, sorry.
  23.              return false;
  24. diff --git a/lib/form/filetypes.php b/lib/form/filetypes.php
  25. index 14c56019d16..9c70b5a8ff5 100644
  26. --- a/lib/form/filetypes.php
  27. +++ b/lib/form/filetypes.php
  28. @@ -221,7 +221,7 @@ class MoodleQuickForm_filetypes extends MoodleQuickForm_group {
  29.       */
  30.      public function validateSubmitValue($value) {
  31.  
  32. -        $value = $value ?? ['filetypes' => null]; // A null $value can arrive here. Coallesce, creating the default array.
  33. +        $value = $value ?? ['filetypes' => null]; // A null $value can arrive here. Coalesce, creating the default array.
  34.  
  35.          if (!$this->allowall) {
  36.              // Assert that there is an actual list provided.
  37. diff --git a/lib/tests/session_manager_test.php b/lib/tests/session_manager_test.php
  38. index fe20515e759..bbafd02aa10 100644
  39. --- a/lib/tests/session_manager_test.php
  40. +++ b/lib/tests/session_manager_test.php
  41. @@ -835,7 +835,7 @@ class core_session_manager_testcase extends advanced_testcase {
  42.          $SESSION->recentsessionlocks = $this->sessionlock_history();
  43.  
  44.          $page = \core\session\manager::get_locked_page_at($time);
  45. -        $this->assertEquals($url, is_array($page) ? $page['url'] : $page);
  46. +        $this->assertEquals($url, is_array($page) ? $page['url'] : null);
  47.      }
  48.  
  49.      /**
Advertisement
Add Comment
Please, Sign In to add comment