diff --git a/.gitignore b/.gitignore index ad5ba653..3ccb114b 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,6 @@ composer.phar .php_cs install.lock composer-setup.php -php-scoper.phar # Mac OS .DS_Store diff --git a/Makefile b/Makefile index 2348d411..f5d752ee 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,6 @@ PHP_VERSION ?= 8.1 PS_VERSION ?= 8.1.3 TESTING_IMAGE ?= prestashop/prestashop-flashlight:${PS_VERSION} PS_ROOT_DIR ?= $(shell pwd)/prestashop/prestashop-${PS_VERSION} -PHP_SCOPER_DIR=php-scoper export PHP_CS_FIXER_IGNORE_ENV = 1 export _PS_ROOT_DIR_ ?= ${PS_ROOT_DIR} @@ -22,14 +21,12 @@ endef define create_module $(eval TMP_DIR := $(shell mktemp -d)) - mkdir -p ${TMP_DIR}/tmp; - cp -r $(shell cat .zip-contents) ${TMP_DIR}/tmp; - VERSION=${PACKAGE} TMP_FOLDER=${TMP_DIR}/tmp php php-scoper.phar add-prefix --output-dir=${TMP_DIR}/${MODULE_NAME} --force + mkdir -p ${TMP_DIR}/${MODULE_NAME}; + cp -r $(shell cat .zip-contents) ${TMP_DIR}/${MODULE_NAME}; $(call replace_version,${TMP_DIR}/${MODULE_NAME},${SEM_VERSION}) ./tools/vendor/bin/autoindex prestashop:add:index ${TMP_DIR} cp $1 ${TMP_DIR}/${MODULE_NAME}/config/parameters.yml cd ${TMP_DIR}/${MODULE_NAME} && composer dump-autoload - SCOPER_FOLDER=${TMP_DIR}/${MODULE_NAME} php php-scoper-fix.php echo ${TMP_DIR} endef @@ -83,22 +80,22 @@ zip: zip-prod zip-inte zip-e2e # target: zip-e2e - Bundle a local E2E integrable zip .PHONY: zip-e2e -zip-e2e: php-scoper.phar vendor tools/vendor dist +zip-e2e: vendor tools/vendor dist @$(call zip_it,./config/parameters.yml,${PACKAGE}_e2e.zip) # target: zip-inte - Bundle an integration zip .PHONY: zip-inte -zip-inte: php-scoper.phar vendor tools/vendor dist +zip-inte: vendor tools/vendor dist @$(call zip_it,.config.inte.yml,${PACKAGE}_integration.zip) # target: zip-prod - Bundle a production zip .PHONY: zip-prod -zip-prod: php-scoper.phar vendor tools/vendor dist +zip-prod: vendor tools/vendor dist @$(call zip_it,.config.prod.yml,${PACKAGE}.zip) # target: zip-unzipped - Bundle a production module, but without zip step (only to check sources) .PHONY: zip-unzipped -zip-unzipped: php-scoper.phar vendor tools/vendor dist +zip-unzipped: vendor tools/vendor dist @$(call no_zip_it,.config.prod.yml) # target: build - Setup PHP & Node.js locally @@ -209,9 +206,6 @@ phpstan-baseline: prestashop/prestashop-${PS_VERSION} phpstan .PHONY: docker-test docker-test: docker-lint docker-phpstan docker-phpunit -php-scoper.phar: - @php -r "copy('https://github.com/humbug/php-scoper/releases/latest/download/php-scoper.phar', 'php-scoper.phar');"; - define COMMENT Fixme: add "allure-framework/allure-phpunit" in composer.json to solve this. Currently failing to resolve devDeps: diff --git a/php-scoper-fix.php b/php-scoper-fix.php deleted file mode 100644 index 67dc6977..00000000 --- a/php-scoper-fix.php +++ /dev/null @@ -1,19 +0,0 @@ - __DIR__ \. (.*?),/', '\'PsEventbus$1\' => __DIR__ . $2,', $static_loader); -file_put_contents($static_loader_path, $static_loader); -$files_loader_path = $scoper_path . '/autoload_files.php'; -echo "Fixing $files_loader_path \n"; -$files_loader = file_get_contents($files_loader_path); -$files_loader = \preg_replace('/\'(.*?)\' => (.*?),/', '\'PsEventbus$1\' => $2,', $files_loader); -file_put_contents($files_loader_path, $files_loader); diff --git a/ps_eventbus.php b/ps_eventbus.php index ee4a7168..89fec34c 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -1581,7 +1581,7 @@ private function insertIncrementalSyncObject($objectId, $type, $date, $shopId, $ /** @var EventbusSyncRepository $eventbusSyncRepository */ $eventbusSyncRepository = $this->getService(EventbusSyncRepository::class); - /** + /* * randomly check if outbox for this shop-content contain more of 100k entries. * When random number == 10, we count number of entry exist in database for this specific shop content * If count > 100 000, we removed all entry corresponding to this shop content, and we enable full sync for this @@ -1639,7 +1639,7 @@ private function insertDeletedObject($objectId, $type, $date, $shopId) if ((int) $objectId === 0) { return; } - + /** @var DeletedObjectsRepository $deletedObjectsRepository */ $deletedObjectsRepository = $this->getService(DeletedObjectsRepository::class); diff --git a/scoper.inc.php b/scoper.inc.php deleted file mode 100644 index 1218f148..00000000 --- a/scoper.inc.php +++ /dev/null @@ -1,135 +0,0 @@ - $version, - 'output-dir' => null, - 'finders' => [ - Finder::create() - ->files() - ->in($_SERVER['TMP_FOLDER']), - ], - 'patchers' => [ - static function (string $filePath, string $prefix, string $contents): string { - if (strpos($filePath, '/vendor/sentry/sentry/lib/Raven/Client.php')) { - return str_replace( - 'Raven_Processor_SanitizeDataProcessor', - "{$prefix}\\Raven_Processor_SanitizeDataProcessor", - $contents - ); - } - - if (strpos($filePath, 'vendor/segmentio/analytics-php/lib/Segment/Client.php')) { - return str_replace( - '$consumers = array("socket" => "Segment_Consumer_Socket", "file" => "Segment_Consumer_File", "fork_curl" => "Segment_Consumer_ForkCurl");', - "\$consumers = array(\"socket\" => \"{$prefix}\\Segment_Consumer_Socket\", \"file\" => \"Segment_Consumer_File\", \"fork_curl\" => \"Segment_Consumer_ForkCurl\");", - $contents - ); - } - - /* Exclude ps_eventbus class for namspacing */ - if (strpos($filePath, '/ps_eventbus.php')) { - $newContent = str_replace( - "namespace {$prefix};", - '', - $contents - ); - - return str_replace( - "\\class_alias('{$prefix}\\\\Ps_eventbus', 'Ps_eventbus', \\false);", - '', - $newContent - ); - } - - /* Exclude upgrade folder for namespacing */ - if (strpos($filePath, '/upgrade') && strpos($filePath, '/vendor') === false) { - return str_replace( - "namespace {$prefix};", - '', - $contents - ); - } - - /* Exclude front controller folder for namespacing */ - if (strpos($filePath, '/controllers') && strpos($filePath, '/vendor') === false) { - return str_replace( - "namespace {$prefix};", - '', - $contents - ); - } - - return $contents; - }, - ], - 'exclude-files' => [], - 'exclude-namespaces' => [ - '~^PrestaShop\\\\Module\\\\Ps_metrics~', - '~^PrestaShop\\\\Module\\\\PsAccounts~', - '~^PrestaShop\\\\Module\\\\PsEventbus~', - '~^PrestaShopBundle~', - '~^PrestaShop\\\\PrestaShop~', - '~^PrestaShop\\\\ModuleLibServiceContainer~', - '~^Http\\\\Client~', - '~^Symfony~', - '~^GuzzleHttp~', - '~^Psr~', - ], - 'exclude-classes' => [ - '\Ps_eventbus', - '\Ps_accounts', - '\Country', - '\Currency', - '\RangePrice', - '\RangeWeight', - '\Carrier', - '\Db', - '\DbQuery', - '\Employee', - '\Hook', - '\Language', - '\Address', - '\Link', - '\Media', - '\Module', - '\ModuleCore', - '\ModuleFrontController', - '\PrestaShopException', - '\PrestaShopDatabaseException', - '\Tab', - '\Tools', - '\Shop', - '\Tax', - '\Product', - '\DateTime', - '\DateTimeZone', - '\Validate', - '\Group', - '\GroupReduction', - '\SpecificPrice', - '\Cache', - '\Configuration', - '\Combination', - '\Customization', - '\TaxManagerFactory', - '\Context', - ], - 'exclude-functions' => [], - 'exclude-constants' => [], - 'expose-global-constants' => true, - 'expose-global-classes' => false, - 'expose-global-functions' => true, - 'expose-namespaces' => [], - 'expose-classes' => [ - '\Ps_eventbus', - ], - 'expose-functions' => [], - 'expose-constants' => [], -]; diff --git a/src/Repository/IncrementalSyncRepository.php b/src/Repository/IncrementalSyncRepository.php index 874b7937..fcda5c0c 100644 --- a/src/Repository/IncrementalSyncRepository.php +++ b/src/Repository/IncrementalSyncRepository.php @@ -3,7 +3,6 @@ namespace PrestaShop\Module\PsEventbus\Repository; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface; -use PrestaShopDatabaseException; class IncrementalSyncRepository { @@ -159,25 +158,28 @@ public function removeIncrementalSyncObject($type, $objectId) } /** - * @param string $type + * @param string $type + * * @return int */ - public function getIncrementalSyncObjectCountByType($type) { + public function getIncrementalSyncObjectCountByType($type) + { $query = new \DbQuery(); $query->select('COUNT(type) as count') ->from(self::INCREMENTAL_SYNC_TABLE) ->where('type = "' . psql($type) . '"'); - - return (int) $this->db->getValue($query); + + return (int) $this->db->getValue($query); } /** - * - * @param string $type - * @return bool + * @param string $type + * + * @return bool */ - public function removeIncrementaSyncObjectByType($type) { + public function removeIncrementaSyncObjectByType($type) + { return $this->db->delete( self::INCREMENTAL_SYNC_TABLE, 'type = "' . pSQL($type) . '"'