Skip to content

Commit f870907

Browse files
committed
Merge remote-tracking branch 'remotes/dev/1.10' into 1.10
2 parents e5bcfbf + 2974c18 commit f870907

File tree

8 files changed

+102
-30
lines changed

8 files changed

+102
-30
lines changed

UPGRADE-1.10.3.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
UPGRADE FROM 1.10.2 to 1.10.3
2+
=============================
3+
4+
####CaseBundle
5+
- `OroCRM/Bundle/CaseBundle/Entity/CaseMailboxProcessSettings` extends `OroCRM\Bundle\CaseBundle\Model\ExtendCaseMailboxProcessSettings`
6+
7+
####SalesBundle
8+
- `OroCRM/Bundle/SalesBundle/Entity/LeadMailboxProcessSettings` extends `OroCRM\Bundle\SalesBundle\Model\ExtendLeadMailboxProcessSettings`

src/OroCRM/Bundle/AnalyticsBundle/Tests/Unit/Validator/CategoriesValidatorTest.php

+11-8
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,24 @@ public function testValidate($collection, $type, $expectedViolationsMessages = [
4242
/** @var \PHPUnit_Framework_MockObject_MockObject|ExecutionContextInterface $context */
4343
$context = $this->getMockForAbstractClass('Symfony\Component\Validator\ExecutionContextInterface');
4444

45-
$this->validator->initialize($context);
45+
if (!$expectedViolationsMessages) {
46+
$context->expects($this->never())
47+
->method('addViolationAt');
48+
} else {
49+
foreach ($expectedViolationsMessages as $key => $expectedViolationsMessage) {
50+
$context->expects($this->at($key))
51+
->method('addViolationAt')
52+
->with($this->equalTo($type), $this->equalTo($expectedViolationsMessage), $this->isType('array'));
53+
}
54+
}
4655

4756
/** @var \PHPUnit_Framework_MockObject_MockObject|CategoriesConstraint $constraint */
4857
$constraint = $this->getMock('OroCRM\Bundle\AnalyticsBundle\Validator\CategoriesConstraint');
49-
50-
foreach ($expectedViolationsMessages as $key => $expectedViolationsMessage) {
51-
$context->expects($this->at($key))
52-
->method('addViolationAt')
53-
->with($this->equalTo($type), $this->equalTo($expectedViolationsMessage), $this->isType('array'));
54-
}
55-
5658
$constraint->expects($this->any())
5759
->method('getType')
5860
->will($this->returnValue($type));
5961

62+
$this->validator->initialize($context);
6063
$this->validator->validate($collection, $constraint);
6164
}
6265

src/OroCRM/Bundle/AnalyticsBundle/Validator/CategoriesValidator.php

+28-17
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ protected function validateOrder(PersistentCollection $value, CategoriesConstrai
135135
$isIncreasing = $this->isIncreasing($orderedByIndex);
136136
$orderedByValueArray = $value->toArray();
137137

138-
$isValid = true;
139-
140138
if ($isIncreasing) {
141139
$inversion = 1;
142140
$criteria = Criteria::ASC;
@@ -145,21 +143,7 @@ protected function validateOrder(PersistentCollection $value, CategoriesConstrai
145143
$criteria = Criteria::DESC;
146144
}
147145

148-
usort(
149-
$orderedByValueArray,
150-
function (RFMMetricCategory $item1, RFMMetricCategory $item2) use (&$isValid, $inversion) {
151-
$minValue1 = $item1->getMinValue();
152-
$minValue2 = $item2->getMinValue();
153-
154-
if ($minValue1 === $minValue2 ||
155-
(!is_null($item1->getMaxValue()) && $item1->getMaxValue() <= $minValue1)) {
156-
$isValid = false;
157-
}
158-
159-
return (($minValue1 < $minValue2) ? 1 : -1) * $inversion;
160-
}
161-
);
162-
146+
$isValid = $this->orderByValue($orderedByValueArray, $inversion);
163147
if (!$isValid || $orderedByValueArray !== $orderedByIndex->toArray()) {
164148
$this->context->addViolationAt($constraint->getType(), $constraint->message, ['%order%' => $criteria]);
165149
}
@@ -182,4 +166,31 @@ protected function isIncreasing(Collection $orderedByIndex)
182166
return is_null($orderedByIndex->first()->getMinValue())
183167
&& is_null($orderedByIndex->last()->getMaxValue());
184168
}
169+
170+
/**
171+
* @param array $value
172+
* @param int $inversion
173+
*
174+
* @return boolean
175+
*/
176+
protected function orderByValue(array &$value, $inversion)
177+
{
178+
$isValid = true;
179+
uasort(
180+
$value,
181+
function (RFMMetricCategory $item1, RFMMetricCategory $item2) use (&$isValid, $inversion) {
182+
$minValue1 = $item1->getMinValue();
183+
$minValue2 = $item2->getMinValue();
184+
185+
if ($minValue1 === $minValue2 ||
186+
(!is_null($item1->getMaxValue()) && $item1->getMaxValue() <= $minValue1)) {
187+
$isValid = false;
188+
}
189+
190+
return (($minValue1 < $minValue2) ? -1 : 1) * $inversion;
191+
}
192+
);
193+
194+
return $isValid;
195+
}
185196
}

src/OroCRM/Bundle/CampaignBundle/Entity/Repository/TrackingEventSummaryRepository.php

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function getSummarizedStatistic(Campaign $campaign)
2626
'DATE(trackingEvent.loggedAt) as loggedAtDate',
2727
]
2828
)
29+
->andWhere('trackingEvent.website IS NOT NULL')
2930
->andWhere('trackingEvent.code = :trackingEventCode')
3031
->andWhere('DATE(trackingEvent.loggedAt) < DATE(:today)')
3132
->setParameter('trackingEventCode', $campaign->getCode())

src/OroCRM/Bundle/MagentoBundle/Controller/SoapController.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use OroCRM\Bundle\MagentoBundle\Provider\ExtensionVersionAwareInterface;
1919
use OroCRM\Bundle\MagentoBundle\Provider\Iterator\StoresSoapIterator;
2020
use OroCRM\Bundle\MagentoBundle\Provider\Transport\SoapTransport;
21+
use OroCRM\Bundle\MagentoBundle\Utils\ValidationUtils;
2122

2223
class SoapController extends Controller
2324
{
@@ -56,7 +57,8 @@ public function checkAction(Request $request)
5657
'adminUrl' => $transport->getAdminUrl(),
5758
];
5859
} catch (\Exception $e) {
59-
$this->get('logger')->critical(sprintf('MageCheck error: %s: %s', $e->getCode(), $e->getMessage()));
60+
$message = ValidationUtils::sanitizeSecureInfo($e->getMessage());
61+
$this->get('logger')->critical(sprintf('MageCheck error: %s: %s', $e->getCode(), $message));
6062
}
6163

6264
return new JsonResponse($response);

src/OroCRM/Bundle/MagentoBundle/EventListener/IntegrationSyncAfterEventListener.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace OroCRM\Bundle\MagentoBundle\EventListener;
44

55
use Oro\Bundle\IntegrationBundle\Event\SyncEvent;
6+
use OroCRM\Bundle\MagentoBundle\Utils\ValidationUtils;
67

78
class IntegrationSyncAfterEventListener
89
{
@@ -20,10 +21,7 @@ public function process(SyncEvent $event)
2021
$jobResult = $event->getJobResult();
2122
$exceptions = array_map(
2223
function ($exception) {
23-
if (is_string($exception)) {
24-
return preg_replace('#(<apiKey.*?>)(.*)(</apiKey>)#i', '$1***$3', $exception);
25-
}
26-
24+
$exception = ValidationUtils::sanitizeSecureInfo($exception);
2725
return $exception;
2826
},
2927
$jobResult->getFailureExceptions()

src/OroCRM/Bundle/MagentoBundle/Tests/Unit/Utils/ValidationUtilsTest.php

+33
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,37 @@ public function entityProvider()
3838
'should not provoke error, show default message' => [$cartStatus, self::TEST_DEFAULT_MESSAGE]
3939
];
4040
}
41+
42+
/**
43+
* @dataProvider messageProvider
44+
*
45+
* @param string $exceptionMessage
46+
* @param string $expectedMessage
47+
*/
48+
public function testSanitizeSecureInfo($exceptionMessage, $expectedMessage)
49+
{
50+
$sanitisedMessage = ValidationUtils::sanitizeSecureInfo($exceptionMessage);
51+
$this->assertEquals($expectedMessage, $sanitisedMessage);
52+
}
53+
54+
/**
55+
* @return array
56+
*/
57+
public function messageProvider()
58+
{
59+
return [
60+
'some other text' => [
61+
'$exceptionMessage' => 'some message text',
62+
'$expectedMessage' => 'some message text'
63+
],
64+
'sanitized exception message' => [
65+
'$exceptionMessage' => '<?xml version="1.0" encoding="UTF-8"?>' .
66+
'<SOAP-ENV:Body><ns1:login><username xsi:type="xsd:string">abc</username>' .
67+
'<apiKey xsi:type="xsd:string">abcabc1</apiKey></ns1:login></SOAP-ENV:Body></SOAP-ENV:Envelope>',
68+
'$expectedMessage' => '<?xml version="1.0" encoding="UTF-8"?>' .
69+
'<SOAP-ENV:Body><ns1:login><username xsi:type="xsd:string">abc</username>' .
70+
'<apiKey xsi:type="xsd:string">***</apiKey></ns1:login></SOAP-ENV:Body></SOAP-ENV:Envelope>'
71+
]
72+
];
73+
}
4174
}

src/OroCRM/Bundle/MagentoBundle/Utils/ValidationUtils.php

+16
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,20 @@ public static function guessValidationMessagePrefix($entity)
2424

2525
return $prefix;
2626
}
27+
28+
/**
29+
* Sanitise error message for secure info
30+
*
31+
* @param string
32+
*
33+
* @return string
34+
*/
35+
public static function sanitizeSecureInfo($message)
36+
{
37+
if (is_string($message)) {
38+
return preg_replace('#(<apiKey.*?>)(.*)(</apiKey>)#i', '$1***$3', $message);
39+
}
40+
41+
return $message;
42+
}
2743
}

0 commit comments

Comments
 (0)