-
Notifications
You must be signed in to change notification settings - Fork 93
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 (final) #177
Migrate from ObjectModel to Doctrine (final) #177
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @leemyongpakvn and bravo for this PR. I suggested some little things 😉 .
Also I see you have a lot of commits with the same commit message can you squash them?
And I'm afraid there are git conflicts
776c07b
to
da835f5
Compare
@matks Rebased and applied your suggestion. |
public function getCategories(int $id_criterion) | ||
{ | ||
$sql = ' | ||
SELECT pccc.id_category, pccc.id_product_comment_criterion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SELECT pccc.id_category, pccc.id_product_comment_criterion | |
SELECT pccc.id_category, pccc.id_product_comment_criterion |
there's something wrong with indentation, I'm surprised cs fixer didn't catch it, you should indent using spaces, also the indentation itself is wrong for the queries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation and tabs are copied from existing ObjectModel code. I have just replaced tabs by spaces. Be free to change queries' indentation if you think it is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We know php-cs-fixer and php-stan are not reliable in some cases.
*/ | ||
public function getTypes() | ||
{ | ||
$sfTranslator = SymfonyContainer::getInstance()->get('translator'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could inject translator service in the construtor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried inserting @translator
in common.yml but got this error
Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The service "product_comment_criterion_repository" has a dependency on a non-existent service "translator".
Then I discovered that ps_linklist uses @translator
in its services, Symfony\Contracts\Translation\TranslatorInterface
in its repository, and dropped support for both PS 1.7.8, PS 8.0 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the upgrade to symfony 4, Symfony\Component\Translation\TranslatorInterface
is transferred to Symfony\Contracts\Translation\TranslatorInterface
. On the other hand, the translator service is still present, it has just changed the package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Injecting translator service create error now so I'd prefer try to do it in the next minor version.
* @method ProductComment|null find($id, $lockMode = null, $lockVersion = null) | ||
* @method ProductComment|null findOneBy(array $criteria, array $orderBy = null) | ||
* @method ProductComment[] findAll() | ||
* @method ProductComment[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fun of such comments, what's the purpose of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are generated automatically when you run Symfony make:entity
in terminal . I think it is useful in case someone try to reinvent the wheel ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi !
I have 1 good piece of news and 1 bad 😞
The good news: for me this PR is valid 👍 I can approve it
The bad: this PR is modifying ProductComments module Doctrine entities, right?
Last week we released GDPR 2.0.1 module. This release also also modify module Doctrine entities. And it started to create failures for people trying to upgrade PrestaShop 8.x. So the module was rollbacked.
Right now, the problem is under analyzis but the main culprit is that the way modules handle Doctrine schema updates migth break the shop upgrade process.
So ... if we put this PR #177 inside release 6.0.0 of Productcomments, the same thing might happen. It might start crashing people shop upgrades 😞 .
So I'm really really really sad 😭 to say this but I'm afraid we should wait for the resolution of this upgrade problem before merging this PR. Because of the Doctrine entities being changed.
@matks when I check the code inside the class which is inside Entity directory, I don't see anything that could trigger schema upgrade |
I see 2 good news from matks's bad news 😆 |
Wait I might be wrong 😄 @leemyongpakvn you added |
@matks Correct, the ProductCommentCriterion Entity is MODIFIED, but 3 additional
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then let's ask QA team to test this PR 💪 we move to the next stage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small feedback :)
public function __construct() | ||
{ | ||
$langIsoIds = Language::getIsoIds(); | ||
$langString = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$langString = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused variable :)
public function isValid() | ||
{ | ||
$res = true; | ||
foreach ($this->names as $key => $value) { | ||
$res &= Validate::isGenericName($value); | ||
} | ||
|
||
return $res; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function isValid() | |
{ | |
$res = true; | |
foreach ($this->names as $key => $value) { | |
$res &= Validate::isGenericName($value); | |
} | |
return $res; | |
} | |
public function isValid() | |
{ | |
foreach ($this->getNames() as $value) { | |
if(!Validate::isGenericName($value)) { | |
return false; | |
} | |
} | |
return true; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Performances improvement :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->getNames()
returns $this->names
in fact, so I think we simply need removing unused $key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leemyongpakvn You don't need to loop all the names... just have a false for the condition to return false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PululuK You're right. Applied :)
@matks In need of re-approve after removing unused variables (small tweak, no logic change ;) |
@PululuK @M0rgan01 @kpodemski we need second approval on this PR 🙏 |
@hibatallahAouadni modules don't require two approvals, it's ok 👍🏻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @leemyongpakvn
Thanks for your PR 🚀
All module's functionalities works like expected ✅
@matks about the upgrade pb, do you want me test the upgrade with this PR? to check if there will be problems?
Waiting for your feedback.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed with @kpodemski no need to test the upgrade 😉
Check to make sure module works as usual in BO and FO.