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)
      ) {
CommentFileSizeAuthor
#3 mailsystem-2716371-3.patch455 bytesRob C

Issue fork mailsystem-2716371

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JasonSafro created an issue. See original summary.

madelyncruz’s picture

Thank you! Adding the condition provided above fixed the issue.

&& class_exists( $classname )
Rob C’s picture

Version: 7.x-2.34 » 7.x-2.x-dev
Status: Active » Needs review
FileSize
455 bytes

Lets add a patch.

Dinesh18’s picture

Status: Needs review » Reviewed & tested by the community

#3 looks good to me. +1 to RTBC

solideogloria’s picture

Priority: Minor » Normal

I 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.

solideogloria’s picture

+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.

kunal_sahu made their first commit to this issue’s fork.

kunal_sahu’s picture

Hi , I have create an MR . Please merge. Thanks

apaderno’s picture

Status: Reviewed & tested by the community » Needs review
apaderno’s picture

Status: Needs review » Needs work

MR #3 is adding to the 8.x-4.x branch Drupal 7 code.