Skip to content

Commit

Permalink
ENGCOM-4712: Fix for Issue #7227: 'x_forwarded_for' value is always e…
Browse files Browse the repository at this point in the history
…mpty in Order object #21787

 - Merge Pull Request #21787 from cmuench/magento2:x-forwarded-for-in-order
 - Merged commits:
   1. 6ce9ee7
   2. 056b526
   3. c4e4cbd
  • Loading branch information
magento-engcom-team committed Apr 22, 2019
2 parents 02dc377 + c4e4cbd commit 11cedb4
Show file tree
Hide file tree
Showing 537 changed files with 17,748 additions and 5,346 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4136,7 +4136,7 @@ Tests:
* Moved Multishipping functionality to newly created module Multishipping
* Extracted Product duplication behavior from Product model to Product\Copier model
* Replaced event "catalog_model_product_duplicate" with composite Product\Copier model
* Replaced event "catalog_product_prepare_save" with controller product initialization helper that can be customozed via plugins
* Replaced event "catalog_product_prepare_save" with controller product initialization helper that can be customized via plugins
* Consolidated Authorize.Net functionality in single module Authorizenet
* Eliminated dependency of Sales module on Shipping and Usa modules
* Eliminated dependency of Shipping module on Customer module
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting-edge, feature-rich eCommerce solution that gets results.

## Magento System Requirements
[Magento System Requirements](https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements2.html).
[Magento System Requirements](https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements.html).

## Install Magento

Expand Down Expand Up @@ -45,7 +45,7 @@ Please review the [Code Contributions guide](https://devdocs.magento.com/guides/

## Reporting Security Issues

To report security vulnerabilities in Magento software or web sites, please create a Bugcrowd researcher account [there](https://bugcrowd.com/magento) to submit and follow-up your issue. Learn more about reporting security issues [here](https://magento.com/security/reporting-magento-security-issue).
To report security vulnerabilities or learn more about reporting security issues in Magento software or web sites visit the [Magento Bug Bounty Program](https://hackerone.com/magento) on hackerone. Please create a hackerone account [there](https://hackerone.com/magento) to submit and follow-up your issue.

Stay up-to-date on the latest security news and patches for Magento by signing up for [Security Alert Notifications](https://magento.com/security/sign-up).

Expand Down
4 changes: 3 additions & 1 deletion app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
* Environment initialization
*/
error_reporting(E_ALL);
stream_wrapper_unregister('phar');
if (in_array('phar', \stream_get_wrappers())) {
stream_wrapper_unregister('phar');
}
#ini_set('display_errors', 1);

/* PHP version validation */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
<entity name="AdminMenuSystem">
<data key="pageTitle">System</data>
<data key="title">Notifications</data>
<data key="dataUiId">magento-backend-system</data>
</entity>
<entity name="AdminMenuSystemOtherSettingsNotifications">
<data key="pageTitle">Notifications</data>
<data key="title">Notifications</data>
<data key="dataUiId">magento-adminnotification-system-adminnotification</data>
</entity>
</entities>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminSystemNotificationNavigateMenuTest">
<annotations>
<features value="AdminNotification"/>
<stories value="Menu Navigation"/>
<title value="Admin system notification navigate menu test"/>
<description value="Admin should be able to navigate to System > Notifications"/>
<severity value="CRITICAL"/>
<testCaseId value="MC-14125"/>
<group value="menu"/>
<group value="mtf_migrated"/>
</annotations>
<before>
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>
</before>
<after>
<actionGroup ref="logout" stepKey="logout"/>
</after>
<actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToSystemNotificationPage">
<argument name="menuUiId" value="{{AdminMenuSystem.dataUiId}}"/>
<argument name="submenuUiId" value="{{AdminMenuSystemOtherSettingsNotifications.dataUiId}}"/>
</actionGroup>
<actionGroup ref="AdminAssertPageTitleActionGroup" stepKey="seePageTitle">
<argument name="title" value="{{AdminMenuSystemOtherSettingsNotifications.pageTitle}}"/>
</actionGroup>
</test>
</tests>
21 changes: 21 additions & 0 deletions app/code/Magento/Analytics/Test/Mftf/Data/AdminMenuData.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
<entity name="AdminMenuReports">
<data key="pageTitle">Reports</data>
<data key="title">Reports</data>
<data key="dataUiId">magento-reports-report</data>
</entity>
<entity name="AdminMenuReportsBusinessIntelligenceAdvancedReporting">
<data key="pageTitle">AdvancedReporting</data>
<data key="title">AdvancedReporting</data>
<data key="dataUiId">magento-analytics-advanced-reporting</data>
</entity>
</entities>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminAdvancedReportingNavigateMenuTest">
<annotations>
<features value="Analytics"/>
<stories value="Menu Navigation"/>
<title value="Admin advanced reporting navigate menu test"/>
<description value="Admin should be able to navigate through advanced reporting admin menu to BI reports page"/>
<severity value="CRITICAL"/>
<testCaseId value="MC-14152"/>
<group value="menu"/>
<group value="mtf_migrated"/>
</annotations>
<before>
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>
</before>
<after>
<actionGroup ref="logout" stepKey="logout"/>
</after>
<actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateAdvancedReportingPage">
<argument name="menuUiId" value="{{AdminMenuReports.dataUiId}}"/>
<argument name="submenuUiId" value="{{AdminMenuReportsBusinessIntelligenceAdvancedReporting.dataUiId}}"/>
</actionGroup>
<switchToNextTab stepKey="switchToNewTab"/>
<seeInCurrentUrl url="advancedreporting.rjmetrics.com/report" stepKey="seeAssertAdvancedReportingPageUrl"/>
</test>
</tests>
159 changes: 66 additions & 93 deletions app/code/Magento/Backend/Block/Dashboard/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Backend\Block\Dashboard;

/**
Expand All @@ -15,7 +17,7 @@ class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard
/**
* Api URL
*/
const API_URL = 'http://chart.apis.google.com/chart';
const API_URL = 'https://image-charts.com/chart';

/**
* All series
Expand Down Expand Up @@ -76,6 +78,7 @@ class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard
/**
* Google chart api data encoding
*
* @deprecated since the Google Image Charts API not accessible from March 14, 2019
* @var string
*/
protected $_encoding = 'e';
Expand Down Expand Up @@ -187,11 +190,12 @@ public function getChartUrl($directUrl = true)
{
$params = [
'cht' => 'lc',
'chf' => 'bg,s,ffffff',
'chco' => 'ef672f',
'chls' => '7',
'chxs' => '0,676056,15,0,l,676056|1,676056,15,0,l,676056',
'chm' => 'h,f2ebde,0,0:1:.1,1,-1',
'chf' => 'bg,s,f4f4f4|c,lg,90,ffffff,0.1,ededed,0',
'chm' => 'B,f4d4b2,0,0,0',
'chco' => 'db4814',
'chxs' => '0,0,11|1,0,11',
'chma' => '15,15,15,15'
];

$this->_allSeries = $this->getRowsData($this->_dataRows);
Expand Down Expand Up @@ -279,20 +283,11 @@ public function getChartUrl($directUrl = true)
$this->_axisLabels['x'] = $dates;
$this->_allSeries = $datas;

//Google encoding values
if ($this->_encoding == "s") {
// simple encoding
$params['chd'] = "s:";
$dataDelimiter = "";
$dataSetdelimiter = ",";
$dataMissing = "_";
} else {
// extended encoding
$params['chd'] = "e:";
$dataDelimiter = "";
$dataSetdelimiter = ",";
$dataMissing = "__";
}
// Image-Charts Awesome data format values
$params['chd'] = "a:";
$dataDelimiter = ",";
$dataSetdelimiter = "|";
$dataMissing = "_";

// process each string in the array, and find the max length
$localmaxvalue = [0];
Expand All @@ -306,7 +301,6 @@ public function getChartUrl($directUrl = true)
$minvalue = min($localminvalue);

// default values
$yrange = 0;
$yLabels = [];
$miny = 0;
$maxy = 0;
Expand All @@ -321,52 +315,21 @@ public function getChartUrl($directUrl = true)
$maxy = ceil($maxvalue + 1);
$yLabels = range($miny, $maxy, 1);
}
$yrange = $maxy;
$yorigin = 0;
}

$chartdata = [];

foreach ($this->getAllSeries() as $index => $serie) {
$thisdataarray = $serie;
if ($this->_encoding == "s") {
// SIMPLE ENCODING
for ($j = 0; $j < sizeof($thisdataarray); $j++) {
$currentvalue = $thisdataarray[$j];
if (is_numeric($currentvalue)) {
$ylocation = round(
(strlen($this->_simpleEncoding) - 1) * ($yorigin + $currentvalue) / $yrange
);
$chartdata[] = substr($this->_simpleEncoding, $ylocation, 1) . $dataDelimiter;
} else {
$chartdata[] = $dataMissing . $dataDelimiter;
}
}
} else {
// EXTENDED ENCODING
for ($j = 0; $j < sizeof($thisdataarray); $j++) {
$currentvalue = $thisdataarray[$j];
if (is_numeric($currentvalue)) {
if ($yrange) {
$ylocation = 4095 * ($yorigin + $currentvalue) / $yrange;
} else {
$ylocation = 0;
}
$firstchar = floor($ylocation / 64);
$secondchar = $ylocation % 64;
$mappedchar = substr(
$this->_extendedEncoding,
$firstchar,
1
) . substr(
$this->_extendedEncoding,
$secondchar,
1
);
$chartdata[] = $mappedchar . $dataDelimiter;
} else {
$chartdata[] = $dataMissing . $dataDelimiter;
}
$count = count($thisdataarray);
for ($j = 0; $j < $count; $j++) {
$currentvalue = $thisdataarray[$j];
if (is_numeric($currentvalue)) {
$ylocation = $yorigin + $currentvalue;
$chartdata[] = $ylocation . $dataDelimiter;
} else {
$chartdata[] = $dataMissing . $dataDelimiter;
}
}
$chartdata[] = $dataSetdelimiter;
Expand All @@ -381,45 +344,13 @@ public function getChartUrl($directUrl = true)

$valueBuffer = [];

if (sizeof($this->_axisLabels) > 0) {
if (count($this->_axisLabels) > 0) {
$params['chxt'] = implode(',', array_keys($this->_axisLabels));
$indexid = 0;
foreach ($this->_axisLabels as $idx => $labels) {
if ($idx == 'x') {
/**
* Format date
*/
foreach ($this->_axisLabels[$idx] as $_index => $_label) {
if ($_label != '') {
$period = new \DateTime($_label, new \DateTimeZone($timezoneLocal));
switch ($this->getDataHelper()->getParam('period')) {
case '24h':
$this->_axisLabels[$idx][$_index] = $this->_localeDate->formatDateTime(
$period->setTime($period->format('H'), 0, 0),
\IntlDateFormatter::NONE,
\IntlDateFormatter::SHORT
);
break;
case '7d':
case '1m':
$this->_axisLabels[$idx][$_index] = $this->_localeDate->formatDateTime(
$period,
\IntlDateFormatter::SHORT,
\IntlDateFormatter::NONE
);
break;
case '1y':
case '2y':
$this->_axisLabels[$idx][$_index] = date('m/Y', strtotime($_label));
break;
}
} else {
$this->_axisLabels[$idx][$_index] = '';
}
}

$this->formatAxisLabelDate($idx, $timezoneLocal);
$tmpstring = implode('|', $this->_axisLabels[$idx]);

$valueBuffer[] = $indexid . ":|" . $tmpstring;
} elseif ($idx == 'y') {
$valueBuffer[] = $indexid . ":|" . implode('|', $yLabels);
Expand Down Expand Up @@ -447,6 +378,46 @@ public function getChartUrl($directUrl = true)
}
}

/**
* Format dates for axis labels
*
* @param string $idx
* @param string $timezoneLocal
*
* @return void
*/
private function formatAxisLabelDate($idx, $timezoneLocal)
{
foreach ($this->_axisLabels[$idx] as $_index => $_label) {
if ($_label != '') {
$period = new \DateTime($_label, new \DateTimeZone($timezoneLocal));
switch ($this->getDataHelper()->getParam('period')) {
case '24h':
$this->_axisLabels[$idx][$_index] = $this->_localeDate->formatDateTime(
$period->setTime($period->format('H'), 0, 0),
\IntlDateFormatter::NONE,
\IntlDateFormatter::SHORT
);
break;
case '7d':
case '1m':
$this->_axisLabels[$idx][$_index] = $this->_localeDate->formatDateTime(
$period,
\IntlDateFormatter::SHORT,
\IntlDateFormatter::NONE
);
break;
case '1y':
case '2y':
$this->_axisLabels[$idx][$_index] = date('m/Y', strtotime($_label));
break;
}
} else {
$this->_axisLabels[$idx][$_index] = '';
}
}
}

/**
* Get rows data
*
Expand Down Expand Up @@ -540,6 +511,8 @@ protected function getHeight()
}

/**
* Sets data helper
*
* @param \Magento\Backend\Helper\Dashboard\AbstractDashboard $dataHelper
* @return void
*/
Expand Down
Loading

0 comments on commit 11cedb4

Please sign in to comment.