Skip to content
Snippets Groups Projects

GD toolkit & operations should catch \Throwable

Closes #2583041

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
498 545 return [IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_WEBP];
499 546 }
500 547
548 /**
549 * Checks that there is enough memory available for a GD operation.
  • Showing nicer error messages is good, but I'm wary about this - it could prevent operations that would actually succeed if they just fit in memory. At least should we be trying to free up memory beforehand via gc_collect_cycles or similar?

  • Author Contributor

    IMHO here we should be seeing this as a safety net for very significant miscalculations of dimensions - I have seen this reported sometimes for % rescaling, where one dimension was much smaller then the other and then a x times resizing would blow everything. The problem is that at the moment we only get WSOD and no info of what's wrong. Anyway, added a gc_collect_cycles() as a last resort before failing.

  • Please register or sign in to reply
  • 452 452 $this->assertTrue($image->isValid(), 'CreateNew with valid arguments validates the Image.');
    453 453 }
    454 454
    455 /**
    456 * Tests creation of an image that will exceed the memory limit.
    457 */
    458 public function testInsufficientMemory(): void {
    459 $image = $this->imageFactory->get('core/tests/fixtures/files/image-test.png');
    460
    461 $oldGdImage = $image->getToolkit()->getResource();
    462 $this->assertFalse($image->createNew(200000, 200000));
    • This might start failing if DrupalCI memory limit is increased. And it definitely might fail locally if someone has a memory limit of -1. I think we need to set the memory limit here - perhaps to different amounts to sure it passing and then failing.

    • mondrake changed this line in version 9 of the diff

      changed this line in version 9 of the diff

    • Author Contributor
      • Skipped test if no memory limit is set.
      • Changed the test dimensions to 2Mio x 2Mio pixels which would require 191 Terabytes of RAM to process - hopefully enough :smile:
      • The testInsufficientAvailableMemory() test just below tests by setting memory limit.
    • Please register or sign in to reply
  • mondrake added 1 commit
  • it needs rebase to be mergable

  • mondrake added 17 commits

    added 17 commits

    Compare with previous version

  • closed

  • Please register or sign in to reply
    Loading