GDToolkit::load() wrongly calls GDToolkit::isValid()

Created on 9 December 2019, about 5 years ago
Updated 23 March 2023, almost 2 years ago

GDToolkit::getResource() checks GDToolkit::$resource is a resource; if it's not, it calls GDToolkit::load(), which first calls GDToolkit::isValid(), which checks that either GDToolkit::$preloadInfo or GDToolkit::$resource has been set.

GDToolkit::load() should not call GDToolkit::isValid(). GDToolkit::load() is a protected method called to initialize GDToolkit::$resource; checking if GDToolkit::$resource has been set and returning FALSE if it was not doesn't make sense. The method should check if GDToolkit::$preloadInfo has been set, which means that GDToolkit::parseFile() has returned TRUE (i.e., the file whose filename is set with GDToolkit::setSource() possibly contains an image).

GDToolkit::isValid() doesn't return FALSE simply because the Image constructor calls GDToolkit::parseFile() after calling GDToolkit::setSource(); still, checking the value of GDToolkit::$resource twice doesn't make sense.

🐛 Bug report
Status

Needs work

Version

10.1

Component
Base 

Last updated 1 day ago

Created by

🇮🇹Italy apaderno Brescia, 🇮🇹

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024