The function mailsystem_create_class() is working OK unless the files directory of a site is physically stored outside of the Drupal root. This is the case e.g. if you have Drupal installed in /var/www and the /var/www/sites/default/files is a symbolic link to e.g. /mnt/files
Some hosting strategies are locating the writable directories outside of the Drupal root for security reasons and/or for better permission management and/or for an easier backup strategy.
In this case we end up with the new class in the registry table as '/mnt/files/mailsystem//MimeMailSystem__SmtpMailSystem.mail.inc' or what ever the class name happens to be. But such a class won't be found by Drupal's autoloader as it expects all the classes to be defined relative to the Drupal root.
This module currently tries to achieve this by stripping the Drupal root from the class file name but that fails when that name is outside of the Drupal root.
A pretty simple patch is resolving that issue and of course produces the same result for all the default cases where the files directory is inside of the Drupal root.
I'll submit that patch in a second.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 2756205-6.patch | 1.6 KB | shubham.prakash |
| #4 | interdiff-2756205-3-4.txt | 553 bytes | loziju |
| #4 | mailsystem-fix_for_private_file_outside_drupal_root-2756205-4.patch | 1.51 KB | loziju |
| #3 | mailsystem-fix_for_private_file_outside_drupal_root-2756205-3.patch | 1.33 KB | loziju |
| #2 | class_filename_should-2756205-2.patch | 1.55 KB | jurgenhaas |
Issue fork mailsystem-2756205
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
jurgenhaasComment #3
loziju commentedPatch #2 works. Rerolled the patch for the latest commit in dev branch. Rewrote variable names to follow Drupal coding standards.
Comment #4
loziju commentedThe code didn't work well if the private file path is a relative path. This may be due to the different method used in generating the $class_file in the previous dev version.
Attached is the updated patch to check if class file already contains a relative path and thus use that straightaway.
Comment #5
manuel garcia commentedLet's add a description to these.
Coding standards.
Nit: Let's combine these into one $class_file declaration
Comment #6
shubham.prakash commentedMade the changes suggested in #5
Comment #7
solideogloria commentedBeen using #6 for a couple months with no problem in combination with this patch: https://www.drupal.org/project/mailsystem/issues/2716371#comment-13328102.
Comment #10
kunal_sahu commentedHi I have created an MR , please merge , thanks