Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
BACKGROUND - I copied the PRD database for a site to the DEV install and started getting a fatal error that a class could not be found. Error was from mailsystem.module line 293
PROBLEM - Attempting to instantiate a class without confirming that it has been defined.
SOLUTION - Added a class_exists()
// ORIGINAL
if ( ($autoload || preg_match('/MailSystem/', $classname))
&& ($object = new $classname)
&& ($object instanceof MailSystemInterface)
) {
// FATAL ERROR WENT AWAY
if ( ($autoload || preg_match('/MailSystem/', $classname))
&& class_exists( $classname )
&& ($object = new $classname)
&& ($object instanceof MailSystemInterface)
) {
Comment | File | Size | Author |
---|---|---|---|
#3 | mailsystem-2716371-3.patch | 455 bytes | Rob C |
Issue fork mailsystem-2716371
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
madelyncruz CreditAttribution: madelyncruz commentedThank you! Adding the condition provided above fixed the issue.
Comment #3
Rob C CreditAttribution: Rob C commentedLets add a patch.
Comment #4
Dinesh18 CreditAttribution: Dinesh18 at Singapore Press Holdings commented#3 looks good to me. +1 to RTBC
Comment #5
solideogloria CreditAttribution: solideogloria commentedI don't think this needs to be Minor. When combined with this issue: #2756205: Class filename should also work if it's stored outside of Drupal root, it can cause a fatal error when you create a new Class, causing the site to be inaccessible and Drush commands to not work.
Comment #6
solideogloria CreditAttribution: solideogloria commented+1 RTBC
Tested this and it works for me. To test, delete/rename the dynamic Class file then clear the cache. Rather than a fatal error, I now get a couple warnings and the mail system reverts to default. Thanks.
Hope it gets committed.
Comment #9
kunal_sahu CreditAttribution: kunal_sahu at Valuebound for Valuebound commentedHi , I have create an MR . Please merge. Thanks
Comment #10
apadernoComment #11
apadernoMR #3 is adding to the 8.x-4.x branch Drupal 7 code.