Skip to content

Commit

Permalink
Merge pull request #580 from akeneo/release/v103.0.0
Browse files Browse the repository at this point in the history
release/v103.0.0 into master
  • Loading branch information
Dnd-Gimix authored May 19, 2022
2 parents 0826240 + 8efbec6 commit 3c95841
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 57 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,11 @@
* Fix "Since last successful import" mode not working on first product job without successful date
* Fix relations from "catalog_product_relation" table for grouped and bundle products being deleted during the product job
* Fix job status to "Error" if missing or wrong API credentials are set in the connector configuration

### Version 103.0.0 :
* Add compatibility for Magento 2.4.4 and PHP 8.1: (https://help.akeneo.com/magento2-connector/articles/all-pre-requisite.html#compatibility)
* Bump Akeneo API client to version 9
* Replace Guzzle HTTP client by Symfony HTTP Client
* Fix function usage for PHP 8
* Update extension PHP compatibility to 7.4 and 8.1
* Fix "special_price" and "cost" attribute being set to 0 when empty on MariaDB
6 changes: 3 additions & 3 deletions Executor/JobExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function execute(string $code, ?OutputInterface $output = null)
}

/** @var string[] $entities */
$entities = explode(',', $code);
$entities = explode(',', $code ?? '');
if (count($entities) > 1) {
$entities = $this->sortJobs($entities);

Expand Down Expand Up @@ -633,7 +633,7 @@ public function setMessage($message, $logger = null)
{
$this->message = $message;
if ($logger && $this->configHelper->isAdvancedLogActivated()) {
$this->currentJobClass->getLogger()->addDebug($message);
$this->currentJobClass->getLogger()->debug($message);
}

return $this;
Expand Down Expand Up @@ -801,7 +801,7 @@ public function setAdditionalMessage($message, $logger = null)
{
$this->message = $this->getMessageWithoutPrefix() . PHP_EOL . $message;
if ($logger && $this->configHelper->isAdvancedLogActivated()) {
$this->currentJobClass->getLogger()->addDebug($message);
$this->currentJobClass->getLogger()->debug($message);
}

return $this;
Expand Down
2 changes: 1 addition & 1 deletion Helper/AttributeFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ protected function addCodeFilter()
if (!$codes || empty($codes)) {
return;
}
$codes = explode(',', $codes);
$codes = explode(',', $codes ?? '');
$this->searchBuilder->addFilter('code', 'IN', $codes);

return;
Expand Down
4 changes: 2 additions & 2 deletions Helper/Authenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use Akeneo\Pim\ApiClient\AkeneoPimClientInterface;
use Akeneo\Pim\ApiClient\AkeneoPimClientBuilder;
use Akeneo\Connector\Helper\Config as ConfigHelper;
use Http\Adapter\Guzzle6\Client;
use Http\Factory\Guzzle\StreamFactory;
use Http\Factory\Guzzle\RequestFactory;
use Symfony\Component\HttpClient\Psr18Client;

/**
* Class Authenticator
Expand Down Expand Up @@ -64,7 +64,7 @@ public function getAkeneoApiClient()
/** @var AkeneoPimClientBuilder $akeneoClientBuilder */
$akeneoClientBuilder = new AkeneoPimClientBuilder($baseUri);

$akeneoClientBuilder->setHttpClient(new Client());
$akeneoClientBuilder->setHttpClient(new Psr18Client());
$akeneoClientBuilder->setStreamFactory(new StreamFactory());
$akeneoClientBuilder->setRequestFactory(new RequestFactory());

Expand Down
2 changes: 1 addition & 1 deletion Helper/CategoryFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function getCategoriesToImport()
$categoriesToImport = [];
if ($excludedCategories) {
/** @var string[] $explodedCategories */
$explodedCategories = explode(',', $excludedCategories);
$explodedCategories = explode(',', $excludedCategories ?? '');
$categoriesToImport = array_diff($allParentCategories, $explodedCategories);
} else {
$categoriesToImport = $allParentCategories;
Expand Down
2 changes: 1 addition & 1 deletion Helper/FamilyVariant.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function updateAxis()
);
while (($row = $variantFamily->fetch())) {
/** @var array $axisAttributes */
$axisAttributes = explode(',', $row['_axis']);
$axisAttributes = explode(',', $row['_axis'] ?? '');
/** @var array $axis */
$axis = [];
/** @var string $code */
Expand Down
8 changes: 5 additions & 3 deletions Helper/Import/Entities.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class Entities
*/
protected $passIfEmpty = [
'price',
'special_price',
'cost',
];
/**
* Mapped catalog attributes with relative scope
Expand Down Expand Up @@ -802,7 +804,7 @@ public function prefixToLowerCase($values)
$newValues = [];
foreach ($values as $key => $data) {
/** @var string[] $keyParts */
$keyParts = explode('-', $key, 2);
$keyParts = explode('-', $key ?? '', 2);
$keyParts[0] = strtolower($keyParts[0]);
if (count($keyParts) > 1) {
$newValues[$keyParts[0] . '-' . $keyParts[1]] = $data;
Expand Down Expand Up @@ -869,13 +871,13 @@ public function formatUrlKeyColumn($tmpTable, $local = null)
public function formatMediaName($filename)
{
/** @var string[] $filenameParts */
$filenameParts = explode('.', $filename);
$filenameParts = explode('.', $filename ?? '');
// Get the extention
/** @var string $extension */
$extension = array_pop($filenameParts);
// Get the hash
$filename = implode('.', $filenameParts);
$filename = explode('_', $filename);
$filename = explode('_', $filename ?? '');
/** @var string $shortHash */
$shortHash = array_shift($filename);
$shortHash = substr($shortHash, 0, 4);
Expand Down
2 changes: 1 addition & 1 deletion Helper/ProductFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ protected function addCompletenessFilter()
/** @var mixed $locales */
$locales = $this->configHelper->getCompletenessLocalesFilter();
/** @var string[] $locales */
$locales = explode(',', $locales);
$locales = explode(',', $locales ?? '');
$options['locales'] = $locales;
}

Expand Down
10 changes: 5 additions & 5 deletions Job/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ public function createTable()
__('Path to log file : %1', $this->handler->getFilename()),
$this->logger
);
$this->logger->addDebug(__('Import identifier : %1', $this->jobExecutor->getIdentifier()));
$this->logger->addDebug(__('Attribute API call Filters : ') . print_r($filters, true));
$this->logger->debug(__('Import identifier : %1', $this->jobExecutor->getIdentifier()));
$this->logger->debug(__('Attribute API call Filters : ') . print_r($filters, true));
}
/** @var PageInterface $attributes */
$attributes = $this->akeneoClient->getAttributeApi()->listPerPage(1, false, $filters);
Expand Down Expand Up @@ -640,7 +640,7 @@ public function addAttributes()

/* Add Attribute to group and family */
if ($row['_attribute_set_id'] && $row['group']) {
$attributeSetIds = explode(',', $row['_attribute_set_id']);
$attributeSetIds = explode(',', $row['_attribute_set_id'] ?? '');

if (is_numeric($row['group'])) {
$row['group'] = 'PIM' . $row['group'];
Expand Down Expand Up @@ -810,7 +810,7 @@ public function cleanCache()
}

/** @var string[] $types */
$types = explode(',', $configurations);
$types = explode(',', $configurations ?? '');
/** @var string[] $types */
$cacheTypeLabels = $this->cacheTypeList->getTypeLabels();

Expand Down Expand Up @@ -843,7 +843,7 @@ public function refreshIndex()
}

/** @var string[] $types */
$types = explode(',', $configurations);
$types = explode(',', $configurations ?? '');
/** @var string[] $typesFlushed */
$typesFlushed = [];

Expand Down
12 changes: 6 additions & 6 deletions Job/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ public function createTable()
{
if ($this->configHelper->isAdvancedLogActivated()) {
$this->jobExecutor->setAdditionalMessage(__('Path to log file : %1', $this->handler->getFilename()), $this->logger);
$this->logger->addDebug(__('Import identifier : %1', $this->jobExecutor->getIdentifier()));
$this->logger->addDebug(
$this->logger->debug(__('Import identifier : %1', $this->jobExecutor->getIdentifier()));
$this->logger->debug(
__('Category API call Filters : ') . print_r($this->categoryFilters->getParentFilters(), true)
);
}
Expand Down Expand Up @@ -740,7 +740,7 @@ public function removeCategoriesByFilter()
$tableName = $this->entitiesHelper->getTableName($this->jobExecutor->getCurrentJob()->getCode());
/** @var AdapterInterface $connection */
$connection = $this->entitiesHelper->getConnection();
$filteredCategories = explode(',', $filteredCategories);
$filteredCategories = explode(',', $filteredCategories ?? '');
/** @var mixed[]|null $categoriesToDelete */
$categoriesToDelete = $connection->fetchAll(
$connection->select()->from($tableName)->where('code IN (?)', $filteredCategories)
Expand Down Expand Up @@ -977,7 +977,7 @@ protected function isCategoryIsInStore(
/** @var string $rootCategoryId */
$currentRootCategoryId = $rootCategoriesAndStores[$storeId];
/** @var string[] $currentCategoryPath */
$currentCategoryPath = explode('/', $categoriesPath[$categoryId]);
$currentCategoryPath = explode('/', $categoriesPath[$categoryId] ?? '');

return in_array($currentRootCategoryId, $currentCategoryPath, false);
}
Expand Down Expand Up @@ -1011,7 +1011,7 @@ public function cleanCache()
}

/** @var string[] $types */
$types = explode(',', $configurations);
$types = explode(',', $configurations ?? '');
/** @var string[] $types */
$cacheTypeLabels = $this->cacheTypeList->getTypeLabels();

Expand Down Expand Up @@ -1044,7 +1044,7 @@ public function refreshIndex()
}

/** @var string[] $types */
$types = explode(',', $configurations);
$types = explode(',', $configurations ?? '');
/** @var string[] $typesFlushed */
$typesFlushed = [];

Expand Down
10 changes: 5 additions & 5 deletions Job/Family.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ public function createTable()
$filters = $this->familyFilters->getFilters();
if ($this->configHelper->isAdvancedLogActivated()) {
$this->jobExecutor->setAdditionalMessage(__('Path to log file : %1', $this->handler->getFilename()), $this->logger);
$this->logger->addDebug(__('Import identifier : %1', $this->jobExecutor->getIdentifier()));
$this->logger->addDebug(__('Family API call Filters : ') . print_r($filters, true));
$this->logger->debug(__('Import identifier : %1', $this->jobExecutor->getIdentifier()));
$this->logger->debug(__('Family API call Filters : ') . print_r($filters, true));
}
/** @var PageInterface $families */
$families = $this->akeneoClient->getFamilyApi()->listPerPage(1, false, $filters);
Expand Down Expand Up @@ -313,7 +313,7 @@ public function insertFamiliesAttributeRelations()
/** @var array $row */
while ($row = $query->fetch()) {
/** @var array $attributes */
$attributes = explode(',', $row['attribute_code']);
$attributes = explode(',', $row['attribute_code'] ?? '');
/** @var string $attribute */
foreach ($attributes as $attribute) {
$connection->insert(
Expand Down Expand Up @@ -393,7 +393,7 @@ public function cleanCache()
}

/** @var string[] $types */
$types = explode(',', $configurations);
$types = explode(',', $configurations ?? '');
/** @var string[] $types */
$cacheTypeLabels = $this->cacheTypeList->getTypeLabels();

Expand Down Expand Up @@ -426,7 +426,7 @@ public function refreshIndex()
}

/** @var string[] $types */
$types = explode(',', $configurations);
$types = explode(',', $configurations ?? '');
/** @var string[] $typesFlushed */
$typesFlushed = [];

Expand Down
4 changes: 2 additions & 2 deletions Job/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,11 @@ public function logImportedEntities($logger = null, $newEntities = false, $ident
$identifierColumn
);
if ($newEntities) {
$logger->addDebug(__('Imported new entities : %1', implode(',', $existingEntities)));
$logger->debug(__('Imported new entities : %1', implode(',', $existingEntities)));

return;
}
$logger->addDebug(__('Imported entities : %1', implode(',', $existingEntities)));
$logger->debug(__('Imported entities : %1', implode(',', $existingEntities)));
}
}
}
8 changes: 4 additions & 4 deletions Job/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function createTable()
__('Path to log file : %1', $this->handler->getFilename()),
$this->logger
);
$this->logger->addDebug(__('Import identifier : %1', $this->jobExecutor->getIdentifier()));
$this->logger->debug(__('Import identifier : %1', $this->jobExecutor->getIdentifier()));
}
/** @var PageInterface $attributes */
$attributes = $this->getAllAttributes(true);
Expand Down Expand Up @@ -458,7 +458,7 @@ public function cleanCache()
}

/** @var string[] $types */
$types = explode(',', $configurations);
$types = explode(',', $configurations ?? '');
/** @var string[] $types */
$cacheTypeLabels = $this->cacheTypeList->getTypeLabels();

Expand Down Expand Up @@ -491,7 +491,7 @@ public function refreshIndex()
}

/** @var string[] $types */
$types = explode(',', $configurations);
$types = explode(',', $configurations ?? '');
/** @var string[] $typesFlushed */
$typesFlushed = [];

Expand Down Expand Up @@ -553,7 +553,7 @@ public function getAllAttributes($logging = false)
/** @var string[] $filters */
$filters = $this->attributeFilters->getFilters();
if ($this->configHelper->isAdvancedLogActivated() && $logging) {
$this->logger->addDebug(__('Attribute API call Filters : ') . print_r($filters, true));
$this->logger->debug(__('Attribute API call Filters : ') . print_r($filters, true));
}
$this->attributes = $this->akeneoClient->getAttributeApi()->all($paginationSize, $filters);
}
Expand Down
Loading

0 comments on commit 3c95841

Please sign in to comment.