Skip to content

Commit

Permalink
fix: disable php-scoper (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
fox-john authored Apr 18, 2024
1 parent 53adaa4 commit bfc4647
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 178 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ composer.phar
.php_cs
install.lock
composer-setup.php
php-scoper.phar

# Mac OS
.DS_Store
Expand Down
18 changes: 6 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
19 changes: 0 additions & 19 deletions php-scoper-fix.php

This file was deleted.

4 changes: 2 additions & 2 deletions ps_eventbus.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1639,7 +1639,7 @@ private function insertDeletedObject($objectId, $type, $date, $shopId)
if ((int) $objectId === 0) {
return;
}

/** @var DeletedObjectsRepository $deletedObjectsRepository */
$deletedObjectsRepository = $this->getService(DeletedObjectsRepository::class);

Expand Down
135 changes: 0 additions & 135 deletions scoper.inc.php

This file was deleted.

20 changes: 11 additions & 9 deletions src/Repository/IncrementalSyncRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace PrestaShop\Module\PsEventbus\Repository;

use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface;
use PrestaShopDatabaseException;

class IncrementalSyncRepository
{
Expand Down Expand Up @@ -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) . '"'
Expand Down

0 comments on commit bfc4647

Please sign in to comment.