This is a followup to #1508104-5: [PATCH] Replace dynamically generated class with delegation.
Now that generated classes are eliminated from the files directory, the risk of ruining a site because of missing mailsystem classes as a result of moving configuration around is much lower than before. Therefore it is not necessary anymore to try to fix the registry and the mail_system variable on each page request via hook_init. Rather hook_requerements is implemented in order to notify the administrator whenever the mail-configuration is broken.
In order to give site-builders a chance on customizing which classes are inspected when discovering implementors of MailSystemInterface two new variables are introduced: mailsystem_get_classes_whitelist and mailsystem_get_classes_blacklist. The default behaviour is preserved (classname must end in "MailSystem" or the filename must contain the string ".mail."). Also the PHP function class_implements is now used when determining wheter a candidate class implements the MailSystemInterface. This goes without instantiation and therefore will hopefully lead to less trouble with third party modules.
Comments
Comment #1
pillarsdotnet commentedthanks; will review when I can.
Comment #2
sbrattla commentedWhich version are you using? I just downloaded 7.x-2.34 which makes my entire site go down when I activate it. A quick look at the logs gives me the following :
It appears that the version I've downloaded is still generating classes which are being put into the files directory. Somehow, that doesn't really work very well for me.
Comment #3
pillarsdotnet commentedYou are correct. The patch from this issue has not been rolled into production yet.
Comment #4
mrfelton commentedThis is great. Seeing massive performance improvements with this.
Comment #5
mrfelton commentedShould patch 004 really be removing the following from hook_init():
Issue #299138: Improve \Drupal\Core\Utility\Mail::htmlToText() is not yet resolved. Removing this breaks the htmlmail module.
Comment #6
mrfelton commentedHere is a version that removes the call to mailsystem_get_classes(), but leaves the mailsystem_html_to_text function definition.
Comment #7
znerol commentedRemoving the whole
hook_initimplementation goes hand in hand with #1538148: [PATCH] Extract mailsystem_html_to_text into a submodule . Actually just loading this include file does not result in any additional/improved functionality for thedrupal_html_to_textfunction. Rather it just frees contrib developers to load the file on their own which is IMHO not a good idea. Especially becausehook_initshould be avoided if possible because of performance reasons.Comment #8
pillarsdotnet commentedNoted.
Comment #9
pillarsdotnet commentedCommitted to 7.x-3.0-alpha1