Review main Merged

29431[CLEANUP] Extension Manager code

Markus Klein CR +2 V +2 Hard +264 −349 updated 04/30/14, 10:12

Commit message

* Add missing annotations
* Shorten unnecessary namespace annotations

Review

  • Code review CR +2
    • Stefan Neufeind +2
    • Alexander Opitz +1
    • Oliver Klee +1
  • Verified V +2
    • Stefan Neufeind +2
    • Alexander Opitz +1

Issues 1

Files 29

Show 9 more files

Review log 44

Show 19 earlier messages
  1. Mr. Jenkins commented on patch set 1 04/12/14, 15:49

  2. Markus Klein commented on patch set 1 CR -1 04/12/14, 16:05

    ActionController.php:81

    $this->getForceInstallationMessage(); Ouch I missed that one

    ExtensionListUtility.php:170

    one space too much
  3. Markus Klein uploaded patch set 2 04/12/14, 16:16

  4. Markus Klein uploaded patch set 3 04/12/14, 16:18

  5. Mr. Jenkins commented on patch set 2 04/12/14, 16:30

  6. Mr. Jenkins commented on patch set 3 04/12/14, 16:32

  7. Oliver Klee commented on patch set 3 CR -1 04/12/14, 17:15

    This code still looks like a WIP. Could you please mark it as WIP in the subject line? Thanks!

    Helper.php:254

    This still is WIP, I guess.

    ToggleExtensionInstallationStateViewHelper.php:59

    This is a change of behavior.
  8. Markus Klein commented on patch set 3 04/12/14, 17:21

    Sorry no WIP. See comment

    Helper.php:254 Reply

    No, not at all! This is commenting out code block that is causing a fatal, but need too much work to get it working. (Multi-Repository management is not available in EM)

    ToggleExtensionInstallationStateViewHelper.php:59 Reply

    This is, because the parameter of the action is renamed too
  9. Helmut Hummel commented on patch set 3 04/12/14, 17:25

    DownloadController.php:74

    I would not change this for consistency with other things the Extbase reflection service evaluates

    ExtensionRepository.php:263

    Is this used anywhere? if not, why is it introduced?

    Helper.php:254 Reply

    then this is no cleanup any more but a bugfix, right?

    ToggleExtensionInstallationStateViewHelper.php:59 Reply

    I think this is still fine, even if we change it here.
  10. Stefan Neufeind commented on patch set 3 04/12/14, 19:08

    After further discussion with Helmut and some thoughts, let me try to summarize my view on the topic: * we "could" change things like @param to not fully-qualified-named (fqn) since they are for documentation and not needed by extbase * we "could" change names in method-parameters since they are parsed by php but not evaluated by extbase afaik * we (currently) need keep using fqn for @inject etc since the ReflectionService so far can't resolve those with the current namespace. Helmut said thats in the plans/on the wishlist * for all other cases (class-extends, ...) we can of course shorten names So how about we keep (for the moment!) full names in all phpdoc since we need them for @inject etc anyway. That could be changed when the ReflecionService is finally extended. And imho it might then also make sense to keep the function-parameters the same fqn as used in @inject and @param etc. All other cases could be shortened where possible.
  11. Markus Klein commented on patch set 3 04/12/14, 23:03

    Hi! I highly disagree with the suggestion to have fqn in some places, but not in all. Please think practical here. If you let phpstorm "use" a class, it will shorten all places automatically. So I'm against introducing an extra burden, which forces me to shorten some places manually, or which shortens all places automatically and I have to re-establish the fqn in all phpdoc places. Also by default, if you use code auto-completion phpstorm will always try to "use" a class, hence it does not introduce fqn by default but goes for the use. I'd suggest to go the practical way and let the tools do the work for us. The one exception - the @inject - is something one can fix manually then. It's easy to remember one exception which occurs usually not more than 5 time per class. Furthermore it is a HUGE improvement for code reading if I have a short class name instead of the distracting whole namespace reference. For the current patch it is clear that if I have Extension $ext the model Extension is meant, as the whole EM is about extensions. If I'm still unsure, I can scroll up and double check with the use statement.

    ExtensionRepository.php:263 Reply

    Yes this is actually a bug in the code. This function is used, but was not present. So I introduced it.

    Helper.php:254 Reply

    Well, I see it as cleanup, since it does not FIX anything here. But that's a matter of taste. ;-) We can of course split this further.
  12. Markus Klein commented on patch set 3 04/13/14, 00:10

    btw: regarding the @inject see http://forge.typo3.org/issues/57856 I linked the tickets from Flow, they solved the type resolution, obviously incl. possible use statements. I cite a part of a commit message from Flow: "In the Coding Guidelines we encourage developers to import namespaces in order to increase readability."
  13. Helmut Hummel commented on patch set 3 04/13/14, 12:13

    Hi Markus. Thanks for your patch and your comments regarding importing namespaces. I agree with you that importing namespaces is something we want. The thing is, we can't have it (consistently) right now in Extbase context. Let me eleborate a bit more: Extbase evaluates types of method parameters and properties by using PHP Reflection to read comment block sections of methods and properties. To infer the type of a property or parameter it does string parsing of the PHP comment and uses the result of this paring operation as type of the parameter or property (including combined types like \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>). As you already mentioned Extbase (unlike TYPO3 Flow) does neither consider the class namespace nor imported namespaces using "use" statements. This means that we *must* use fully qualified class names in method or property comments for Extbase to work properly. Of course we *could* use short class names in places which Extbase does *not* evaluate like /** @var Foo $foo */. However as a developer you need deep inside knowledge of implementation details of the Extbase Framework to know where you can use short class names and where you *must* use fully qualified class names. Let's look at the the changes in this very patch: You imported the Domain/Model/Extension class and use short class names in action methods. And it works! But why? Considering the above statement about string parsing it should not. It works, because Extbase does not only parse the method comment, but also the type hints *if present*! Since getting the class type of a method type hint is a native PHP Reflection feature and PHP itself of course knows about use statements and namespaces, the fully qualified namespace is returned from the PHP Reflection and Extbase uses this class name then. However: If you remove the type hint and only leave the method parameter comment, Extbase will fail because of the reasons explained above. It is an implementation detail of the Extbase Reflection service that the type hint take precedence. In fact if a type hint is present, the comment block is completely ignored! See this gist what works and what does not: https://gist.github.com/helhum/10580317 Is this inconsistent? Yes! Should we use this inconsistency to our advantage and not use fully qualified in the only single place where this is possible? I would say no. Why? Here is why I have concerns: The code we have in the core serves as example for extension developers and core contributors. I fear that people will imply from this example that they must not use fully qualified class names, which will hit them hard when they do not know that there is only one place where they can do so. This is why I suggest to stay with fqn at least as long as Extbase Reflection *completely* support namespace and use statements in *all* places, which is not too easy to achieve and I fear will not make it into 6.2. For this patch I therefore suggest to not import the /Extension namespace, but clean this area up *after* Extbase changed to support that *everywhere* Long story short: I have concerns and I tried to elaborate them as precise as possible. If you still feel like changing that in the way you proposed, or think that my concerns have a lower priority than cleaning some areas up: Go ahead, I will not block it.
  14. Helmut Hummel commented on patch set 3 04/13/14, 12:31

    ExtensionRepository.php:263 Reply

    So this is a bugfix not a cleanup, which should go into a different change.
  15. Markus Klein commented on patch set 3 04/13/14, 12:35

    Thanks Helmut for this extensive description! Everyone should have a good picture now what's going on inside extbase. I'm fine with leaving out the shorting of class names *for now*. I disagree that it is hard to have full namespace support in the reflection. Look at the patch, or at the linked Flow patches. One function and we're done. What do you think is a blocking factor for having this in 6.2? https://review.typo3.org/29436 I want to give you another perspective (actually my experience, when I got in touch with extbase): If some person looks at examples from Core this does not necessarily mean that he/she concludes that full namespaces have to be used. Why should he? PHP does not require it. (My impression was: what an ugly code having all these redundant information everywhere. => bad example) Actually some beginner will always do what the language allows to do. And that is short names almost everywhere. This is natural. => doing so currently will give the beginner a free ride with head toward concrete. So we should strive to support this ASAP. Meanwhile I'm also convinced that we should take the performance penalty of parsing PHP files for use statement evaluation. (doctrine phpparser as used in Flow) Regarding the case here that type hints take precedence: Well that's also what one would expect. Language constructs always take precedence. Would be really strange if extbase would break that behavior/concept. We should shift this discussion now to the ticket http://forge.typo3.org/issues/57856 If one wants to undo the namespace shortening here, go ahead. I can't do it today. We have to get this done.
  16. Helmut Hummel commented on patch set 3 04/13/14, 12:38

    ExtensionRepository.php:263 Reply

    Btw: Repository classes have magic countBy* and findBy* methods for *all* properties in the Model. So it is not needed to implement those in a repository if the magic methods do what is needed
  17. Markus Klein commented on patch set 3 CR -1 04/13/14, 13:35

    ExtensionRepository.php:263 Reply

    Oh really. than this is "wrong"/superfluous.

    Helper.php:254 Reply

    Supposing now this is calling the magic method too. The Extension model does not have a property called repository, but the database table has. So is this magic working on the table then?
  18. Markus Klein uploaded patch set 4 04/13/14, 14:09

  19. Markus Klein commented on patch set 4 04/13/14, 14:14

    Ok, found some minutes and cleaned this up. Hope it is fine now.
  1. Mr. Jenkins commented on patch set 4 04/13/14, 14:22

  2. Helmut Hummel commented on patch set 4 CR -1 04/13/14, 14:34

    DependencyUtility.php:265

    These changes here also prevent me from merging straight away. These are heavy functional changes that (if not already) need to be covered by tests and is not easy cleanup any more

    ExtensionListUtility.php:189

    Wrong! if we have a title then TRUE is stored here instead of the title

    ExtensionListUtility.php:193

    same here!
  3. Helmut Hummel commented on patch set 3 04/13/14, 14:34

    Helper.php:254 Reply

    Same here: This is *not* causing a fatal, as this is a magic method from the repository class. The resulting SQL query is: SELECT COUNT(*) FROM tx_extensionmanager_domain_model_extension WHERE tx_extensionmanager_domain_model_extension.repository = '1' It still makes no sense to do a query like this as there is no multiple repository support, but I would still leave it like it is in this cleanup and fix this in another change properly
  4. Markus Klein commented on patch set 4 04/13/14, 14:37

    will follow up quickly

    DependencyUtility.php:265 Reply

    functional changes?? I just flipped the ifs. But I just see that there's still the skipSystemDependencyCheck stuff in it.

    ExtensionListUtility.php:193 Reply

    damn it. thanks for spotting this.
  5. Markus Klein uploaded patch set 5 04/13/14, 14:40

  6. Stefan Neufeind commented on patch set 5 CR +1 04/13/14, 14:44

    ActionController.php:82

    Great catch! Checked that this looks okay. Comes from EXT:extbase/Classes/Mvc/Controller/AbstractController.php
  7. Mr. Jenkins commented on patch set 5 04/13/14, 14:53

  8. Helmut Hummel commented on patch set 4 04/13/14, 15:17

    DependencyUtility.php:265 Reply

    ok, you are right. Looking a t the changes side by side not inline makes me confident, that this is fine.
  9. Helmut Hummel uploaded patch set 6 04/13/14, 15:23

  10. Helmut Hummel commented on patch set 6 V +1 CR +1 04/13/14, 15:24

    only removed not needed variables in dependency utility Great cleanup!
  11. Oliver Klee voted on patch set 6 CR +1 04/13/14, 15:45

  12. Mr. Jenkins commented on patch set 6 04/13/14, 15:45

  13. Stefan Neufeind voted on patch set 6 CR +1 04/13/14, 17:37

  14. Alexander Opitz commented on patch set 6 04/14/14, 06:48

    AbstractMirrorXmlParser.php:192

    Is there an "= NULL" missing?
  15. Markus Klein commented on patch set 6 04/14/14, 09:16

    AbstractMirrorXmlParser.php:192 Reply

    I thought so too and would make sense. Should we add it with this cleanup?
  16. Oliver Klee commented on patch set 6 04/14/14, 09:19

    AbstractMirrorXmlParser.php:192 Reply

    +1
  17. Markus Klein uploaded patch set 7 04/14/14, 09:28

  18. Markus Klein commented on patch set 7 04/14/14, 09:28

    Added the NULL.
  19. Mr. Jenkins commented on patch set 7 04/14/14, 09:42

  20. Stefan Neufeind commented on patch set 7 CR +1 04/14/14, 10:19

    Reapplying vote.
  21. Oliver Klee voted on patch set 7 CR +1 04/14/14, 10:23

  22. Alexander Opitz voted on patch set 7 V +1 CR +1 04/14/14, 12:22

  23. Stefan Neufeind commented on patch set 7 V +1 04/30/14, 10:12

    Carefully looked through the changes again and didn't spot any glitches. I also played around with the EM a bit, tested extension-fetching and installation etc. and didn't find warnings/errors or so. Since this cleanup has been standing quite a while now (luckily it still applies cleanly) and blocks other patches, I think we should have this in now to proceed further with EM-patches.
  24. Stefan Neufeind commented on patch set 7 V +2 CR +2 04/30/14, 10:12

    Carefully looked through the changes again and didn't spot any glitches. I also played around with the EM a bit, tested extension-fetching and installation etc. and didn't find warnings/errors or so. Since this cleanup has been standing quite a while now (luckily it still applies cleanly) and blocks other patches, I think we should have this in now to proceed further with EM-patches.
  25. Stefan Neufeind merged patch set 8 04/30/14, 10:12