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

Make flexmailer mandatory #25110

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CRM/Upgrade/Incremental/php/FiveFiftySeven.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class CRM_Upgrade_Incremental_php_FiveFiftySeven extends CRM_Upgrade_Incremental
public function upgrade_5_57_alpha1($rev): void {
$this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
$this->addExtensionTask('Enable SearchKit extension', ['org.civicrm.search_kit'], 1100);
$this->addExtensionTask('Enable Flexmailer extension', ['org.civicrm.flexmailer']);
}

}
25 changes: 0 additions & 25 deletions api/v3/examples/Setting/GetFields.ex.php
Original file line number Diff line number Diff line change
Expand Up @@ -3256,31 +3256,6 @@ function setting_getfields_expectedresult() {
'0' => 'financialacls_toggle',
],
],
'flexmailer_traditional' => [
'group_name' => 'Flexmailer Preferences',
'group' => 'flexmailer',
'name' => 'flexmailer_traditional',
'type' => 'String',
'html_type' => 'select',
'html_attributes' => [
'class' => 'crm-select2',
],
'pseudoconstant' => [
'callback' => '_flexmailer_traditional_options',
],
'default' => 'auto',
'add' => '5.13',
'title' => 'Traditional Mailing Handler',
'is_domain' => 1,
'is_contact' => 0,
'description' => 'For greater backward-compatibility, process \"<code>traditional</code>\" mailings with the CiviMail\'s hard-coded BAO.<br/>For greater forward-compatibility, process \"<code>traditional</code>\" mailings with Flexmailer\'s extensible pipeline.',
'help_text' => '',
'settings_pages' => [
'flexmailer' => [
'weight' => 5,
],
],
],
'recaptchaPublicKey' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
Expand Down
3 changes: 3 additions & 0 deletions ext/flexmailer/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<compatibility>
<ver>5.57</ver>
</compatibility>
<tags>
<tag>mgmt:required</tag>
</tags>
<classloader>
<psr4 prefix="Civi\FlexMailer\" path="src"/>
</classloader>
Expand Down
28 changes: 0 additions & 28 deletions ext/flexmailer/settings/flexmailer.setting.php

This file was deleted.

13 changes: 1 addition & 12 deletions ext/flexmailer/src/Listener/Abdicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,7 @@ public static function isFlexmailPreferred($mailing) {
if ($mailing->template_type && $mailing->template_type !== 'traditional') {
return TRUE;
}

switch (\Civi::settings()->get('flexmailer_traditional')) {
case 'bao':
return FALSE;

case 'auto':
case 'flexmailer':
return TRUE;

default:
throw new \RuntimeException("Unrecognized value for setting 'flexmailer_traditional'");
}
return TRUE;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function setUp(): void {
}

parent::setUp();
\Civi::settings()->set('flexmailer_traditional', 'flexmailer');
}

public function getHrefExamples() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function setUp(): void {
}

parent::setUp();
\Civi::settings()->set('flexmailer_traditional', 'flexmailer');
}

public function getHrefExamples() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,6 @@ public function setUp(): void {
}

parent::setUp();

\Civi::settings()->set('flexmailer_traditional', 'flexmailer');
}

public function tearDown(): void {
// We're building on someone else's test and don't fully trust them to
// protect our settings. Make sure they did.
$ok = ('flexmailer' == \Civi::settings()->get('flexmailer_traditional'))
&& ('s:10:"flexmailer";' === \CRM_Core_DAO::singleValueQuery('SELECT value FROM civicrm_setting WHERE name ="flexmailer_traditional"'));

parent::tearDown();

$this->assertTrue($ok, 'FlexMailer remained active during testing');
}

// ---- Boilerplate ----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public function setUp(): void {
}

parent::setUp();
\Civi::settings()->set('flexmailer_traditional', 'flexmailer');

$dispatcher = \Civi::service('dispatcher');
foreach (FlexMailer::getEventTypes() as $event => $class) {
Expand Down Expand Up @@ -110,28 +109,6 @@ public function testUrlTracking(
parent::testUrlTracking($inputHtml, $htmlUrlRegex, $textUrlRegex, $params);
}

/**
*
* This takes CiviMail's own ones, but removes one that tested for a
* non-feature (i.e. that tokenised links are not handled).
*
* @return array
*/
public function urlTrackingExamples() {
$cases = parent::urlTrackingExamples();

// When it comes to URLs with embedded tokens, support diverges - Flexmailer
// can track them, but BAO mailer cannot.
$cases[6] = [
'<p><a href="http://example.net/?id={contact.contact_id}">Foo</a></p>',
';<p><a href=[\'"].*(extern/url.php|civicrm/mailing/url)(\?|&amp\\;)u=\d+.*&amp\\;id=\d+.*[\'"]>Foo</a></p>;',
';\\[1\\] .*(extern/url.php|civicrm/mailing/url)[\?&]u=\d+.*&id=\d+.*;',
['url_tracking' => 1],
];

return $cases;
}

public function testBasicHeaders(): void {
parent::testBasicHeaders();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public function setUp(): void {

parent::setUp();

\Civi::settings()->set('flexmailer_traditional', 'flexmailer');

$this->useTransaction();
// DGW
\CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public function setUp(): void {
}

parent::setUp();
\Civi::settings()->set('flexmailer_traditional', 'flexmailer');
}

public function getExamples() {
Expand Down
11 changes: 0 additions & 11 deletions ext/flexmailer/xml/Menu/flexmailer.xml

This file was deleted.

13 changes: 6 additions & 7 deletions tests/phpunit/CRM/Mailing/BaseMailingSystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,13 @@ public function urlTrackingExamples() {
';\\[1\\] .*(extern/url.php|civicrm/mailing/url)[\?&]u=\d+.*;',
['url_tracking' => 1],
];
$cases[6] = [
// FIXME: CiviMail URL tracking doesn't track tokenized links.
$cases['url_trackin_enabled'] = [
'<p><a href="http://example.net/?id={contact.contact_id}">Foo</a></p>',
// FIXME: Legacy tracker adds extra quote after URL
';<p><a href="http://example\.net/\?id=\d+""?>Foo</a></p>;',
';\\[1\\] http://example\.net/\?id=\d+;',
';<p><a href=[\'"].*(extern/url.php|civicrm/mailing/url)(\?|&amp\\;)u=\d+.*&amp\\;id=\d+.*[\'"]>Foo</a></p>;',
';\\[1\\] .*(extern/url.php|civicrm/mailing/url)[\?&]u=\d+.*&id=\d+.*;',
['url_tracking' => 1],
];

$cases[7] = [
// It would be redundant/slow to track the action URLs?
'<p><a href="{action.optOutUrl}">Foo</a></p>',
Expand Down Expand Up @@ -391,13 +390,13 @@ protected function createContactsInGroup(
*/
protected function runMailingSuccess($params) {
$mailingParams = array_merge($this->defaultParams, $params);
$this->callAPISuccess('mailing', 'create', $mailingParams);
$this->callAPISuccess('Mailing', 'create', $mailingParams);
$this->_mut->assertRecipients([]);
$this->callAPISuccess('job', 'process_mailing', ['runInNonProductionEnvironment' => TRUE]);

$allMessages = $this->_mut->getAllMessages('ezc');
// There are exactly two contacts produced by setUp().
$this->assertEquals(2, count($allMessages));
$this->assertCount(2, $allMessages);

return $allMessages;
}
Expand Down
19 changes: 7 additions & 12 deletions tests/phpunit/CRM/Mailing/MailingSystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,16 @@ class CRM_Mailing_MailingSystemTest extends CRM_Mailing_BaseMailingSystemTest {
*/
public function setUp(): void {
parent::setUp();
// If we happen to execute with flexmailer active, use BAO mode.
// There is a parallel FlexMailerSystemTest which runs in flexmailer mode.
Civi::settings()->add(['flexmailer_traditional' => 'bao']);

$hooks = \CRM_Utils_Hook::singleton();
$hooks->setHook('civicrm_alterMailParams',
[$this, 'hook_alterMailParams']);
error_reporting(E_ALL && !E_USER_DEPRECATED);
}

/**
* @see CRM_Utils_Hook::alterMailParams
*/
public function hook_alterMailParams(&$params, $context = NULL): void {
public function hook_alterMailParams(): void {
$this->counts['hook_alterMailParams'] = 1;
if ($this->checkMailParamsContext) {
$this->assertEquals('civimail', $context);
}
}

/**
Expand All @@ -90,6 +82,7 @@ public function testMailerPreviewExtraScheme(): void {
$this->assertNotEmpty($displayName);

$params = $this->_params;
/** @noinspection HttpUrlsUsage */
$params['body_html'] = '<a href="http://{action.forward}">Forward this email written in ckeditor</a>';
$params['api.Mailing.preview'] = [
'id' => '$value.id',
Expand All @@ -113,13 +106,15 @@ public function testMailerPreviewExtraScheme(): void {
* Generate a fully-formatted mailing (with body_html content).
*
* @dataProvider urlTrackingExamples
*
* @throws \CRM_Core_Exception
*/
public function testUrlTracking(
$inputHtml,
$htmlUrlRegex,
$textUrlRegex,
$params
) {
): void {
parent::testUrlTracking($inputHtml, $htmlUrlRegex, $textUrlRegex, $params);
}

Expand Down Expand Up @@ -175,7 +170,7 @@ public function testMailingReplyAutoRespond(): void {

$replyComponent = $this->callAPISuccess('MailingComponent', 'get', ['id' => CRM_Mailing_PseudoConstant::defaultComponent('Reply', ''), 'sequential' => 1])['values'][0];
$replyComponent['body_html'] .= ' {domain.address} ';
$replyComponent['body_txt'] .= ' {domain.address} ';
$replyComponent['body_txt'] = $replyComponent['body_txt'] ?? '' . ' {domain.address} ';
$this->callAPISuccess('MailingComponent', 'create', $replyComponent);

// Create initial mailing to the group.
Expand Down Expand Up @@ -258,7 +253,7 @@ public function multiLingual() {
* @dataProvider multiLingual
*
*/
public function testGitLabIssue1108($isMultiLingual) {
public function testGitLabIssue1108($isMultiLingual): void {

// We need to make sure the mailing IDs are higher than the groupIDs.
// We do this by adding mailings until the mailing.id value is at least 10
Expand Down