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

PIMAG-687 | Bugfix: Fix first setup:upgrade issues #822 #835

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/end-2-end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
run: |
docker exec magento-project-community-edition php /data/merge-config.php
docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment"
docker exec magento-project-community-edition ./retry "php bin/magento setup:upgrade --no-interaction"
docker exec magento-project-community-edition ./retry "php bin/magento setup:upgrade --keep-generated --no-interaction"
docker exec magento-project-community-edition /bin/bash /data/configure-mollie.sh
docker exec magento-project-community-edition ./retry "bin/magento config:set payment/mollie_general/use_webhooks custom_url"
docker exec magento-project-community-edition ./retry "bin/magento config:set payment/mollie_general/custom_webhook_url ${{ env.magento_url }}/mollie/checkout/webhook"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ && docker exec magento-project-community-edition ./install-composer-package mollie/magento2:@dev

- name: Activate the extension
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade"
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade --keep-generated"

- name: Run tests
run: docker exec magento-project-community-edition bash -c "cd /data/dev/tests/integration/ && /data/vendor/bin/phpunit -c /data/dev/tests/integration/phpunit.xml"
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: docker exec magento-project-community-edition ./install-composer-package mollie/magento2:@dev

- name: Activate the extension
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade && php bin/magento setup:di:compile"
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade --keep-generated && php bin/magento setup:di:compile"

- name: Run PHPStan
continue-on-error: ${{ matrix.PHPSTAN_LEVEL == 2 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ && docker exec magento-project-community-edition ./install-composer-package mollie/magento2:@dev

- name: Activate the extension
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade && php bin/magento setup:di:compile"
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade --keep-generated && php bin/magento setup:di:compile"

- name: Run tests
run: docker exec magento-project-community-edition bash -c "vendor/bin/phpunit extensions/*/Test/Unit"
51 changes: 0 additions & 51 deletions Setup/Patch/Data/AddMollieShipmentIdAttribute.php

This file was deleted.

51 changes: 0 additions & 51 deletions Setup/Patch/Data/AddMollieTransactionIdAttribute.php

This file was deleted.

39 changes: 17 additions & 22 deletions Setup/Patch/Data/EncryptFallbackKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,48 @@

namespace Mollie\Payment\Setup\Patch\Data;

use Magento\Framework\Api\Search\SearchCriteriaBuilder;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Encryption\EncryptorInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Mollie\Payment\Api\ApiKeyFallbackRepositoryInterface;

class EncryptFallbackKeys implements DataPatchInterface
{
/**
* @var SearchCriteriaBuilder
*/
private $searchCriteriaBuilder;
/**
* @var ApiKeyFallbackRepositoryInterface
*/
private $apiKeyFallbackRepository;
/**
* @var EncryptorInterface
*/
private $encryptor;
/**
* @var ResourceConnection
*/
private $resourceConnection;

public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder,
ApiKeyFallbackRepositoryInterface $apiKeyFallbackRepository,
EncryptorInterface $encryptor
EncryptorInterface $encryptor,
ResourceConnection $resourceConnection
) {
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->apiKeyFallbackRepository = $apiKeyFallbackRepository;
$this->encryptor = $encryptor;
$this->resourceConnection = $resourceConnection;
}

public function apply()
{
$criteria = $this->searchCriteriaBuilder->create();
$list = $this->apiKeyFallbackRepository->getList($criteria);
$connection = $this->resourceConnection->getConnection();
$tableName = $connection->getTableName('mollie_payment_apikey_fallback');

if ($list->getTotalCount() === 0) {
if (!$connection->isTableExists($tableName)) {
return $this;
}

foreach ($list->getItems() as $item) {
$start = substr($item->getApiKey(), 0, 4);
$query = 'select * from ' . $tableName;
$result = $connection->fetchAll($query);
foreach ($result as $row) {
$start = substr($row['api_key'], 0, 4);
if (!in_array($start, ['live', 'test'])) {
continue;
}

$item->setApiKey($this->encryptor->encrypt($item->getApiKey()));
$this->apiKeyFallbackRepository->save($item);
$encrypted = $this->encryptor->encrypt($row['api_key']);
$connection->update($tableName, ['api_key' => $encrypted], ['id = ?' => $row['id']]);
}

return $this;
Expand Down
Loading