Skip to content

Commit 6d201ac

Browse files
authored
Merge pull request mautic#7028 from mautic/release-2.15.0
Release 2.15.0
2 parents 816990f + 1abdfbd commit 6d201ac

389 files changed

Lines changed: 13104 additions & 3367 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
2.
2525

2626
#### Steps to test this PR:
27-
1.
27+
1. Load up [this PR](https://mautibox.com)
2828
2.
2929

3030
#### List deprecations along with the new alternative:
@@ -33,4 +33,4 @@
3333

3434
#### List backwards compatibility breaks:
3535
1.
36-
2.
36+
2.

.travis.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1-
dist: precise
2-
31
language: php
42

53
services:
64
- mysql
75

86
php:
9-
- 5.6.19
7+
- 5.6
108
- 7.0
119
- 7.1
10+
- 7.2
11+
12+
cache:
13+
directories:
14+
- $HOME/.composer/cache
1215

1316
before_install:
1417
# Create mautictest database
1518
- mysql -e 'CREATE DATABASE mautictest;'
1619

20+
# increase memory limit for all PHP processes
21+
- echo "memory_limit=4G" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
22+
1723
# turn off XDebug
1824
- phpenv config-rm xdebug.ini || return
1925

@@ -32,11 +38,11 @@ install:
3238
script:
3339

3440
# Run PHPUnit
35-
- bin/phpunit -d memory_limit=2048M --bootstrap vendor/autoload.php --configuration app/phpunit.xml.dist --fail-on-warning
41+
- bin/phpunit --bootstrap vendor/autoload.php --configuration app/phpunit.xml.dist --fail-on-warning
3642

3743
# Run PHPSTAN analysis for PHP 7+
3844
- if [[ ${TRAVIS_PHP_VERSION:0:3} != "5.6" ]]; then ~/.composer/vendor/phpstan/phpstan-shim/phpstan.phar analyse app/bundles/DashboardBundle app/bundles/ConfigBundle app/bundles/CampaignBundle app/bundles/WebhookBundle app/bundles/LeadBundle app/bundles/FormBundle; fi
3945

4046
# Check if the code standards weren't broken.
41-
# Run it only on PHP 7.1 which should be the fastest. No need to run it for all PHP versions
42-
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.1" ]]; then bin/php-cs-fixer fix -v --dry-run --diff; fi
47+
# Run it only on PHP 7.2 which should be the fastest. No need to run it for all PHP versions
48+
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.2" ]]; then bin/php-cs-fixer fix -v --dry-run --diff; fi

app/AppKernel.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ class AppKernel extends Kernel
3434
*
3535
* @const integer
3636
*/
37-
const MINOR_VERSION = 14;
37+
const MINOR_VERSION = 15;
3838

3939
/**
4040
* Patch version number.
4141
*
4242
* @const integer
4343
*/
44-
const PATCH_VERSION = 2;
44+
const PATCH_VERSION = 0;
4545

4646
/**
4747
* Extra version identifier.
@@ -92,12 +92,12 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
9292
$base = $request->getBaseUrl();
9393
$prefix = '';
9494
//check to see if the .htaccess file exists or if not running under apache
95-
if ((strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'apache') === false
95+
if (stripos($request->server->get('SERVER_SOFTWARE', ''), 'apache') === false
9696
|| !file_exists(__DIR__.'../.htaccess')
9797
&& strpos(
9898
$base,
9999
'index'
100-
) === false)
100+
) === false
101101
) {
102102
$prefix .= '/index.php';
103103
}
@@ -110,6 +110,14 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
110110
$this->boot();
111111
}
112112

113+
/*
114+
* If we've already sent the response headers, and we have a session
115+
* set in the request, set that as the session in the container.
116+
*/
117+
if (headers_sent() && $request->getSession()) {
118+
$this->getContainer()->set('session', $request->getSession());
119+
}
120+
113121
// Check for an an active db connection and die with error if unable to connect
114122
if (!defined('MAUTIC_INSTALLER')) {
115123
$db = $this->getContainer()->get('database_connection');
@@ -184,6 +192,7 @@ public function registerBundles()
184192
new LightSaml\SymfonyBridgeBundle\LightSamlSymfonyBridgeBundle(),
185193
new LightSaml\SpBundle\LightSamlSpBundle(),
186194
new Ivory\OrderedFormBundle\IvoryOrderedFormBundle(),
195+
new Noxlogic\RateLimitBundle\NoxlogicRateLimitBundle(),
187196
// These two bundles do DI based on config, so they need to be loaded after config is declared in MauticQueueBundle
188197
new OldSound\RabbitMqBundle\OldSoundRabbitMqBundle(),
189198
new Leezy\PheanstalkBundle\LeezyPheanstalkBundle(),
@@ -374,7 +383,7 @@ public function getCacheDir()
374383
{
375384
$parameters = $this->getLocalParams();
376385
if (isset($parameters['cache_path'])) {
377-
$envFolder = (strpos($parameters['cache_path'], -1) != '/') ? '/'.$this->environment : $this->environment;
386+
$envFolder = (substr($parameters['cache_path'], -1) != '/') ? '/'.$this->environment : $this->environment;
378387

379388
return str_replace('%kernel.root_dir%', $this->getRootDir(), $parameters['cache_path'].$envFolder);
380389
} else {

app/AppTestKernel.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* @copyright 2017 Mautic Contributors. All rights reserved
5+
* @author Mautic
6+
*
7+
* @link http://mautic.org
8+
*
9+
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
10+
*/
11+
312
class AppTestKernel extends AppKernel
413
{
514
/**

app/bundles/ApiBundle/Config/config.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@
115115
'mautic.api.model.client',
116116
],
117117
],
118+
'mautic.api.rate_limit_generate_key.subscriber' => [
119+
'class' => 'Mautic\ApiBundle\EventListener\RateLimitGenerateKeySubscriber',
120+
'arguments' => [
121+
'mautic.helper.core_parameters',
122+
],
123+
],
118124
],
119125
'forms' => [
120126
'mautic.form.type.apiclients' => [
@@ -183,5 +189,9 @@
183189
'api_oauth2_access_token_lifetime' => 60,
184190
'api_oauth2_refresh_token_lifetime' => 14,
185191
'api_batch_max_limit' => 200,
192+
'api_rate_limiter_limit' => 0,
193+
'api_rate_limiter_cache' => [
194+
'type' => 'file_system',
195+
],
186196
],
187197
];

app/bundles/ApiBundle/Controller/CommonApiController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ protected function processForm($entity, $parameters = null, $method = 'PUT')
12201220
*
12211221
* @return Response|array
12221222
*/
1223-
protected function returnError($msg, $code = Codes::HTTP_OK, $details = [])
1223+
protected function returnError($msg, $code = Codes::HTTP_INTERNAL_SERVER_ERROR, $details = [])
12241224
{
12251225
if ($this->get('translator')->hasId($msg, 'flashes')) {
12261226
$msg = $this->get('translator')->trans($msg, [], 'flashes');
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
/*
4+
* @copyright 2014 Mautic Contributors. All rights reserved
5+
* @author Mautic
6+
*
7+
* @link http://mautic.org
8+
*
9+
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
10+
*/
11+
12+
namespace Mautic\ApiBundle\EventListener;
13+
14+
use Mautic\CoreBundle\EventListener\CommonSubscriber;
15+
use Mautic\CoreBundle\Helper\CoreParametersHelper;
16+
use Noxlogic\RateLimitBundle\Events\GenerateKeyEvent;
17+
use Noxlogic\RateLimitBundle\Events\RateLimitEvents;
18+
19+
/**
20+
* Class RateLimitGenerateKeySubscriber.
21+
*/
22+
class RateLimitGenerateKeySubscriber extends CommonSubscriber
23+
{
24+
/**
25+
* @var CoreParametersHelper
26+
*/
27+
protected $coreParametersHelper;
28+
29+
/**
30+
* RateLimitGenerateKeySubscriber constructor.
31+
*
32+
* @param \Mautic\CoreBundle\Helper\CoreParametersHelper $coreParametersHelper
33+
*/
34+
public function __construct(CoreParametersHelper $coreParametersHelper)
35+
{
36+
$this->coreParametersHelper = $coreParametersHelper;
37+
}
38+
39+
/**
40+
* @return array
41+
*/
42+
public static function getSubscribedEvents()
43+
{
44+
return [
45+
RateLimitEvents::GENERATE_KEY => ['onGenerateKey', 0],
46+
];
47+
}
48+
49+
/**
50+
* @param \Noxlogic\RateLimitBundle\Events\GenerateKeyEvent $event
51+
*/
52+
public function onGenerateKey(GenerateKeyEvent $event)
53+
{
54+
$suffix = $this->coreParametersHelper->getParameter('site_url');
55+
$event->addToKey($suffix);
56+
}
57+
}

app/bundles/ApiBundle/Form/Type/ConfigType.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,26 @@ public function buildForm(FormBuilderInterface $builder, array $options)
8989
],
9090
]
9191
);
92+
93+
$builder->add(
94+
'api_rate_limiter_limit',
95+
'number',
96+
[
97+
'label' => 'mautic.api.config.form.api.rate_limiter_limit',
98+
'attr' => [
99+
'tooltip' => 'mautic.api.config.form.api.rate_limiter_limit.tooltip',
100+
'class' => 'form-control',
101+
'data-show-on' => '{"config_apiconfig_api_enabled_1":"checked"}',
102+
],
103+
'constraints' => [
104+
new NotBlank(
105+
[
106+
'message' => 'mautic.core.value.required',
107+
]
108+
),
109+
],
110+
]
111+
);
92112
}
93113

94114
/**

app/bundles/ApiBundle/Translations/en_US/messages.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,5 @@ mautic.core.error.badrequest="Bad request."
6060
mautic.api.error.api.disabled="API disabled. You need to enable the API in the API settings page of your Mautic account."
6161
mautic.api.error.basic.auth.disabled="Basic Auth disabled. You need to enable HTTP basic auth in the API settings page of your Mautic account."
6262
mautic.api.error.basic.auth.invalid.credentials="Authorization denied, invalid credentials."
63+
mautic.api.config.form.api.rate_limiter_limit="API request limit (requests per hours)"
64+
mautic.api.config.form.api.rate_limiter_limit.tooltip="The number of allowed API calls per hour for the whole instance (sum of all API keys). Set it to 0 to remove the limit."

app/bundles/AssetBundle/Assets/js/asset.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//AssetBundle
22
Mautic.assetOnLoad = function (container) {
3-
if (typeof mauticAssetUploadEndpoint !== 'undefined' && mQuery('div#dropzone').length) {
3+
if (typeof mauticAssetUploadEndpoint !== 'undefined' && typeof Mautic.assetDropzone == 'undefined' && mQuery('div#dropzone').length) {
44
Mautic.initializeDropzone();
55
}
66
};

0 commit comments

Comments
 (0)