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

Camel Case variables fix #1082

Merged
merged 2 commits into from
Oct 4, 2019
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
10 changes: 5 additions & 5 deletions app/code/community/Ebizmarts/MailChimp/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Ebizmarts_MailChimp_Helper_Data extends Mage_Core_Helper_Abstract
*
* @var array
*/
public static $MAILCHIMP_LANGUAGES = array(
public static $LANGUAGES = array(
'en', // English
'ar', // Arabic
'af', // Afrikaans
Expand Down Expand Up @@ -2595,9 +2595,9 @@ protected function _migrateFrom1164($initialTime)
{
$dateHelper = $this->getDateHelper();
if (!$dateHelper->timePassed($initialTime)) {
$write_connection = $this->getCoreResource()->getConnection('core_write');
$writeConnection = $this->getCoreResource()->getConnection('core_write');
$resource = Mage::getResourceModel('mailchimp/ecommercesyncdata');
$write_connection->update($resource->getMainTable(), array('batch_id' => '1'), "batch_id = 0");
$writeConnection->update($resource->getMainTable(), array('batch_id' => '1'), "batch_id = 0");
$arrayMigrationConfigData = array('115' => false, '116' => false, '1164' => true);
$this->handleDeleteMigrationConfigData($arrayMigrationConfigData);
}
Expand Down Expand Up @@ -4109,11 +4109,11 @@ protected function _langToMCLanguage($languageCode = '')
{
$mailchimpLanguage = '';

if (in_array($languageCode, self::$MAILCHIMP_LANGUAGES)) {
if (in_array($languageCode, self::$LANGUAGES)) {
$mailchimpLanguage = $languageCode;
} else {
$langIso = substr($languageCode, 0, 2);
if (in_array($langIso, self::$MAILCHIMP_LANGUAGES)) {
if (in_array($langIso, self::$LANGUAGES)) {
$mailchimpLanguage = $langIso;
}
}
Expand Down
24 changes: 12 additions & 12 deletions app/code/community/Ebizmarts/MailChimp/Model/Api/Batches.php
Original file line number Diff line number Diff line change
Expand Up @@ -746,20 +746,20 @@ protected function processEachResponseFile($files, $batchId, $mailchimpStoreId,
$helper->resetCountersDataSentToMailchimp();

foreach ($files as $file) {
$items = json_decode(file_get_contents($file));
$items = json_decode(file_get_contents($file), true);

if ($items !== false) {
foreach ($items as $item) {
$line = explode('_', $item->operation_id);
$line = explode('_', $item['operation_id']);
$store = explode('-', $line[0]);
$type = $line[1];
$id = $line[3];

if ($item->status_code != 200) {
if ($item['status_code'] != 200) {
$mailchimpErrors = Mage::getModel('mailchimp/mailchimperrors');

//parse error
$response = json_decode($item->response);
$response = json_decode($item['response'], true);
$errorDetails = $this->_processFileErrors($response);

if (strstr($errorDetails, 'already exists')) {
Expand All @@ -782,9 +782,9 @@ protected function processEachResponseFile($files, $batchId, $mailchimpStoreId,
true
);

$mailchimpErrors->setType($response->type);
$mailchimpErrors->setTitle($response->title);
$mailchimpErrors->setStatus($item->status_code);
$mailchimpErrors->setType($response['type']);
$mailchimpErrors->setTitle($response['title']);
$mailchimpErrors->setStatus($item['status_code']);
$mailchimpErrors->setErrors($errorDetails);
$mailchimpErrors->setRegtype($type);
$mailchimpErrors->setOriginalId($id);
Expand Down Expand Up @@ -862,17 +862,17 @@ protected function _processFileErrors($response)
{
$errorDetails = "";

if (!empty($response->errors)) {
foreach ($response->errors as $error) {
if (isset($error->field) && isset($error->message)) {
if (!empty($response['errors'])) {
foreach ($response['errors'] as $error) {
if (isset($error['field']) && isset($error['message'])) {
$errorDetails .= $errorDetails != "" ? " / " : "";
$errorDetails .= $error->field . " : " . $error->message;
$errorDetails .= $error['field'] . " : " . $error['message'];
}
}
}

if ($errorDetails == "") {
$errorDetails = $response->detail;
$errorDetails = $response['detail'];
}

return $errorDetails;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public function downloadresponseAction()
$items = $this->getFileContent($file);
foreach ($items as $item) {
$fileContent[] = array(
'status_code' => $item->status_code,
'operation_id' => $item->operation_id,
'response' => json_decode($item->response)
'status_code' => $item['status_code'],
'operation_id' => $item['operation_id'],
'response' => json_decode($item['response'])
);
}

Expand Down Expand Up @@ -128,7 +128,7 @@ protected function getApiBatches()
*/
protected function getFileContent($file)
{
return json_decode(file_get_contents($file));
return json_decode(file_get_contents($file), true);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public function testDownloadresponseAction()
$mailchimpStoreId = 'a1s2d3f4g5h6j7k8l9n0';
$files = array('/magento/var/mailchimp/1f103d0176/c9cf317023.json');
$file = '/magento/var/mailchimp/1f103d0176/c9cf317023.json';
$item = new stdClass();
$item->status_code = 400;
$item->operation_id = 'storeid-1_CUS_2018-02-06-18-46-06-86970300_64';
$item->response = '{"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",'
$item = array();
$item['status_code'] = 400;
$item['operation_id'] = 'storeid-1_CUS_2018-02-06-18-46-06-86970300_64';
$item['response'] = '{"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",'
. '"title":"Invalid Resource","status":400,"detail":"The resource submitted could not be validated. '
. 'For field-specific details, see the \'errors\' array.","instance":"","errors":'
. '[{"field":"email_address","message":"This email address looks fake or invalid. '
Expand Down
6 changes: 3 additions & 3 deletions shell/getMailchimpResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
if ($err) {
printf("cURL Error #:" . $err);
} else {
$jsonResponse = json_decode($response);
if ($jsonResponse->status == 'finished') {
$fileUrl = $jsonResponse->response_body_url;
$jsonResponse = json_decode($response, true);
if ($jsonResponse['status'] == 'finished') {
$fileUrl = $jsonResponse['response_body_url'];
// check if the file is not expired
parse_str($fileUrl, $fileParams);
try {
Expand Down