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

Migrate from objectmodel to doctrine #174

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d8353d1
add EntityManager for repositories
leemyongpakvn Jul 13, 2023
9ef9876
extends ServiceEntityRepository, migrate functions from OM to doctrine
leemyongpakvn Jul 13, 2023
ee934e7
mark migrated functions as Deprecated
leemyongpakvn Jul 13, 2023
8b07a78
replace OM functions by equivalent doctrine ones
leemyongpakvn Jul 13, 2023
a16013f
php-cs fix
leemyongpakvn Jul 13, 2023
15440da
phpstan and phpcsfixer fixes
leemyongpakvn Jul 14, 2023
683a40a
restore needed use
leemyongpakvn Jul 14, 2023
19f5d78
php-cs-fixer remove indirect use
leemyongpakvn Jul 14, 2023
7a4d172
backwards compatibility with DBAL 2.9
leemyongpakvn Jul 14, 2023
5f52306
migrate functions from OM to Doctrine
leemyongpakvn Jul 14, 2023
564d575
mark migrated functions as Deprecated
leemyongpakvn Jul 14, 2023
5d38a29
replace OM functions by Doctrine ones
leemyongpakvn Jul 14, 2023
bc546d5
add new ignoreErrors
leemyongpakvn Jul 14, 2023
ec9a3e1
use newer phpstan
leemyongpakvn Jul 14, 2023
658d63e
use latest phpstan
leemyongpakvn Jul 15, 2023
8e4a900
drop PHP5.6 and PS 1.7.6 check
leemyongpakvn Jul 15, 2023
865ec2c
typo
leemyongpakvn Jul 15, 2023
ece3949
ignore error from doctrine in obsolte phpstan
leemyongpakvn Jul 15, 2023
ac1afc9
line break
leemyongpakvn Jul 15, 2023
c28b142
correct patern
leemyongpakvn Jul 15, 2023
7fd0918
ServiceEntityRepository error happens only in PS 1.7.6 and 1.7.8
leemyongpakvn Jul 15, 2023
3454bc7
complete migration
leemyongpakvn Jul 24, 2023
7e1860f
resolve conflict
leemyongpakvn Jul 24, 2023
b8cde07
resolve conflict
leemyongpakvn Jul 24, 2023
1c3e88c
resolve conflict
leemyongpakvn Jul 24, 2023
db80adb
restore variable declarations
leemyongpakvn Jul 24, 2023
1e63d93
resolve conflict
leemyongpakvn Jul 24, 2023
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
14 changes: 7 additions & 7 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ on: [push, pull_request]
jobs:
# Check there is no syntax errors in the project
php-linter:
name: PHP Syntax check 5.6 => 8.1
name: PHP Syntax check 7.2 => 8.2
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: PHP syntax checker 5.6
uses: prestashop/github-action-php-lint/5.6@master

- name: PHP syntax checker 7.2
uses: prestashop/github-action-php-lint/7.2@master

Expand All @@ -27,6 +24,9 @@ jobs:
- name: PHP syntax checker 8.1
uses: prestashop/github-action-php-lint/8.1@master

- name: PHP syntax checker 8.2
uses: prestashop/github-action-php-lint/8.2@master

# Check the PHP code follow the coding standards
php-cs-fixer:
name: PHP-CS-Fixer
Expand All @@ -50,15 +50,15 @@ jobs:
run: composer install

- name: Run PHP-CS-Fixer
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no --diff-format udiff
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no

# Run PHPStan against the module and a PrestaShop release
phpstan:
name: PHPStan
runs-on: ubuntu-latest
strategy:
matrix:
presta-versions: ['1.7.6', '1.7.7', '1.7.8', 'latest']
presta-versions: ['1.7.7', '1.7.8', '8.0', 'latest']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -86,4 +86,4 @@ jobs:

# Docker images prestashop/prestashop may be used, even if the shop remains uninstalled
- name: Execute PHPStan on PrestaShop (Tag ${{ matrix.presta-versions }})
run: ./tests/phpstan.sh ${{ matrix.presta-versions }}
run: ./tests/phpstan.sh ${{ matrix.presta-versions }}
19 changes: 19 additions & 0 deletions ProductComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ public static function getRatings($id_product)
return Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->getRow($sql);
}

/**
* @deprecated 4.0.0
*/
public static function getAverageGrade($id_product)
{
$validate = Configuration::get('PRODUCT_COMMENTS_MODERATE');
Expand Down Expand Up @@ -235,6 +238,8 @@ public static function getAveragesByProduct($id_product, $id_lang)
* Return number of comments and average grade by products
*
* @return int|false
*
* @deprecated 4.0.0
*/
public static function getCommentNumber($id_product)
{
Expand Down Expand Up @@ -279,6 +284,8 @@ public static function getGradedCommentNumber($id_product)
* Get comments by Validation
*
* @return array Comments
*
* @deprecated 6.0.0
*/
public static function getByValidate($validate = '0', $deleted = false, $p = null, $limit = null, $skip_validate = false)
{
Expand Down Expand Up @@ -306,6 +313,8 @@ public static function getByValidate($validate = '0', $deleted = false, $p = nul
* Get numbers of comments by Validation
*
* @return int Count of comments
*
* @deprecated 6.0.0
*/
public static function getCountByValidate($validate = '0', $skip_validate = false)
{
Expand Down Expand Up @@ -360,6 +369,8 @@ public function validate($validate = '1')
* Delete a comment, grade and report data
*
* @return bool succeed
*
* @deprecated 6.0.0
*/
public function delete()
{
Expand All @@ -373,6 +384,8 @@ public function delete()
* Delete Grades
*
* @return bool succeed
*
* @deprecated 6.0.0
*/
public static function deleteGrades($id_product_comment)
{
Expand All @@ -389,6 +402,8 @@ public static function deleteGrades($id_product_comment)
* Delete Reports
*
* @return bool succeed
*
* @deprecated 6.0.0
*/
public static function deleteReports($id_product_comment)
{
Expand All @@ -405,6 +420,8 @@ public static function deleteReports($id_product_comment)
* Delete usefulness
*
* @return bool succeed
*
* @deprecated 6.0.0
*/
public static function deleteUsefulness($id_product_comment)
{
Expand Down Expand Up @@ -473,6 +490,8 @@ public static function isAlreadyUsefulness($id_product_comment, $id_customer)
* Get reported comments
*
* @return array Comments
*
* @deprecated 6.0.0
*/
public static function getReportedComments()
{
Expand Down
21 changes: 21 additions & 0 deletions ProductCommentCriterion.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ public function addCategory($id_category)
* Add grade to a criterion
*
* @return bool succeed
*
* @deprecated 4.0.0
*/
public function addGrade($id_product_comment, $grade)
{
Expand All @@ -154,6 +156,8 @@ public function addGrade($id_product_comment, $grade)
* Get criterion by Product
*
* @return array Criterion
*
* @deprecated 4.0.0
*/
public static function getByProduct($id_product, $id_lang)
{
Expand Down Expand Up @@ -201,6 +205,8 @@ public static function getByProduct($id_product, $id_lang)
* Get Criterions
*
* @return array Criterions
*
* @deprecated 6.0.0
*/
public static function getCriterions($id_lang, $type = false, $active = false)
{
Expand All @@ -224,6 +230,9 @@ public static function getCriterions($id_lang, $type = false, $active = false)
return $criterions;
}

/**
* @deprecated 6.0.0
*/
public function getProducts()
{
$res = Db::getInstance()->executeS('
Expand All @@ -240,6 +249,9 @@ public function getProducts()
return $products;
}

/**
* @deprecated 6.0.0
*/
public function getCategories()
{
$res = Db::getInstance()->executeS('
Expand All @@ -256,20 +268,29 @@ public function getCategories()
return $criterions;
}

/**
* @deprecated 6.0.0
*/
public function deleteCategories()
{
return Db::getInstance()->execute('
DELETE FROM `' . _DB_PREFIX_ . 'product_comment_criterion_category`
WHERE `id_product_comment_criterion` = ' . (int) $this->id);
}

/**
* @deprecated 6.0.0
*/
public function deleteProducts()
{
return Db::getInstance()->execute('
DELETE FROM `' . _DB_PREFIX_ . 'product_comment_criterion_product`
WHERE `id_product_comment_criterion` = ' . (int) $this->id);
}

/**
* @deprecated 6.0.0
*/
public static function getTypes()
{
// Instance of module class for translations
Expand Down
2 changes: 2 additions & 0 deletions config/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ services:
product_comment_criterion_repository:
class: PrestaShop\Module\ProductComment\Repository\ProductCommentCriterionRepository
arguments:
- '@doctrine'
- '@doctrine.dbal.default_connection'
- '%database_prefix%'

product_comment_repository:
class: PrestaShop\Module\ProductComment\Repository\ProductCommentRepository
arguments:
- '@doctrine'
- '@doctrine.dbal.default_connection'
- '%database_prefix%'
- '@=service("prestashop.adapter.legacy.configuration").get("PRODUCT_COMMENTS_ALLOW_GUESTS")'
Expand Down
Loading