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)
) {
Comments
Comment #2
madelyncruz commentedThank you! Adding the condition provided above fixed the issue.
Comment #3
rob c commentedLets add a patch.
Comment #4
dinesh18 commented#3 looks good to me. +1 to RTBC
Comment #5
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 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 commentedHi , I have create an MR . Please merge. Thanks
Comment #10
avpadernoComment #11
avpadernoMR #3 is adding to the 8.x-4.x branch Drupal 7 code.