Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn privates to protecteds to fix EmailMan overrides #8841

Merged
merged 1 commit into from
Aug 14, 2020

Conversation

pgorod
Copy link
Contributor

@pgorod pgorod commented Aug 9, 2020

Description

Problems customizing EmailMan class with a custom class.

How To Test This

Create custom class in custom/modules/EmailMan/CustomEmailMan.phpwith something like this...

require_once 'modules/EmailMan/EmailMan.php';

class CustomEmailMan extends EmailMan {

    public function sendEmail(SugarPHPMailer $mail, $save_emails = 1, $testmode = false, $previewmode = false) {
         [... code copied from original function, using function $this->shouldBlockEmail() ....]
    }
}

You get a PHP error:

Sun Aug  9 18:47:59 2020 [1183][1][PHP S] [E_ERROR] 
'Uncaught Error: Call to private method EmailMan::shouldBlockEmail() 
from context 'CustomEmailMan' 
in custom/modules/EmailMan/CustomEmailMan.php:126

This is wrong because this class is meant to be overridable, so these functions should be either public or protected.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Final checklist

  • My code follows the code style of this project found here.
  • My change requires a change to the documentation.
  • I have read the How to Contribute guidelines.

@codecov-commenter
Copy link

Codecov Report

Merging #8841 into hotfix-7.10.x will not change coverage.
The diff coverage is 0.00%.

@@              Coverage Diff               @@
##           hotfix-7.10.x    #8841   +/-   ##
==============================================
  Coverage          10.69%   10.69%           
==============================================
  Files               3230     3230           
  Lines             241063   241063           
==============================================
  Hits               25792    25792           
  Misses            215271   215271           

@mattlorimer mattlorimer merged commit 7ed021a into salesagility:hotfix-7.10.x Aug 14, 2020
@pgorod pgorod deleted the patch-14 branch August 14, 2020 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants