Closed (fixed)
Project:
Media entity
Version:
8.x-2.x-dev
Component:
Code
Priority:
Critical
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
17 Oct 2017 at 23:08 UTC
Updated:
23 Nov 2017 at 13:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
seanbPatch is attached.
Comment #3
marcoscanoAdded this to the master plan as well.
Comment #4
marcoscanoAnother important thing to fix here is that our validation that aborts
drush updatedbis not being picked up by Drush 9.I'm working on it.
Comment #5
marcoscanoBumping to major because many people will upgrade directly to Drush 9 when moving to core 8.4.0.
Comment #6
marcoscanoThis does 2 things:
- Refactors our requirements checks to be in a service, so all the logic is only in one place, instead of duplicated code all around.
- Implements the validate hook for drush9. However, unfortunately this validate hook is not being picked up yet, I'm not sure if this is a drush9 bug or I'm doing something wrong. (the same mechanism for defining the validate hook can abort other commands, but not the
updatedb, for some reason.)Comment #7
marcoscanoWow, not sure how that dump got into the patch, but sorry about that!
Comment #8
marcoscanoJust talked to Moshe Weitzman in slack, and he confirmed me that our validate hook in drush9 will not be able to abort the
drush updatedbcommand, because these hooks only fire on commands that fully bootstrap Drupal. He said though, that he would move forward https://github.com/drush-ops/drush/pull/2708. If that is fixed, then at least people using the latest drush will be covered by the originalhook_requirements().So to summarize, we have:
- Misconfigured sites using the UI at /update.php will have the process aborted by our
hook_requirements()- Misconfigured sites using
drush updatedbon drush 8 (before that PR is fixed) will be covered by ourdrush_hook_COMMAND_validate()implementation- Misconfigured sites using
drush updatedbon drush 8 (after that PR is fixed) will be covered byhook_requirements()- Misconfigured sites using
drush updatedbon drush 9 (before that PR is fixed) will not be covered, meaning that if they don't usedrush mecuto check requirements are OK before running the updates, the process will break.- Misconfigured sites using
drush updatedbon drush 9 (after that PR is fixed) will be covered byhook_requirements()I don't think there's much else we can do, apart from emphasizing in the upgrade instructions that some Drush 9 users are really encouraged to check the requirements with
drush mecubefore going straight to running DB updates.Comment #9
marcoscanoComment #10
phenaproximaGave this a shallow review and found some nitpicks, but overall it looks quite good.
Can we rename this to make it clearer that these are Drush commands, as opposed to Console commands? Maybe media_entity.commands.drush would be a better name? The class, too, could be renamed DrushCommands instead of MediaEntityCommands.
Can we just call the class CliService? It's already in the media_entity namespace, so prefixing it with MediaEntity just makes it longer to type. :)
Supernit: Drush is a proper noun and should be capitalized.
Any chance we can inject the media_entity.cli service?
Supernit: s/drush/Drush
I think we could use module_load_install()?
Can we use StringTranslationTrait and $this->t()?
Let's inject the module handler.
Comment #11
marcoscanoThanks for reviewing @phenaproxima!
Addressed all points in #10 but:
1:
Isn't having the file name called
drush.services.ymland the tagdrush.commandenough to indicate that this is a place for Drush commands (and not Console ones)? Also for the class naming, I was under the assumption (after reading https://weitzman.github.io/blog/port-to-drush9) that the best practice would be to have a module's command under a class called ModulenameCommands, but maybe I'm wrong. In any case, no strong feelings about any of this, just let me know if you think we really should change it!Comment #12
seanbRegarding #8:
I think we should really emphasize runningdrush mecuis crucial. We should also add this to the release notes of the alpha and the upgrade path notes because the information in your comment is super relevant for people that start the upgrade.Just saw this was done already! Marcoscano++
Comment #13
seanbFixed #10.1. Manually tested everything works and I guess it looks a little clearer.
Comment #14
phenaproximaThis looks pretty good. I'll do some manual testing.
Let's remove the comment, and just leave it marked @internal. It's possible that this will be needed by a Drupal Console version of this command.
Are we sure this should be >=, not >?
Comment #15
marcoscanoAddressed #14.1
Re: #14.2, the last update hook for ME 1.x was 8003, so I believe it can be either
>= 8004or> 8003. Changed to the latter because it appears to be more self-explanatory.Comment #16
marcoscanoActually what really makes sense is
>= 8201, which is where we start our upgrade stuff.< /nit >
Comment #17
woprrr commentedAll looks good to me. I have tested it manually and works like a charm :) @see screenshots
drush mecu :

drush updb

Just small NIT / Coding standards feedback :
- I think small forgetted \ When importing a class with "use"
- Namespaced classes/interfaces/traits should be referenced with use statements
- Array closing indentation error(s)
- Short array syntax must be used to define arrays
Comment #18
phenaproximaI found nitpicks. It's what I do. I'd be fine fixing all of these in a follow-up issue, though! I merely want to document them here for posterity.
None of these should block RTBC or commit.
I'm also marking this issue critical because it effectively blocks the upgrade path to core.
We can remove the @package annotation.
Nit: Can we rephrase this to: 'The contributed "Media" module is not installed.'?
Can we make this sentence begin with "Before continuing, please make sure..."
Nit: Let's remove the "Successfully checked that". And let's end this sentence with "are up-to-date."
Can we rephrase this as "The media_entity_generic module is installed."?
Nit: Constructor arguments are usually $snake_case.
Let's call $this->logger() once, at the top of the method, so that we can re-use the return value. It'll make the method slightly more readable.
Comment #19
marcoscano@phenaproxima thanks for reviewing!
This should fix all your nits :)
Comment #20
woprrr commentedLGTM :) marcoscano++ :D ready to RTBC :O *_*
Comment #21
woprrr commentedComment #22
phenaproximaPatch no longer applies against 8.x-2.x :(
Comment #23
woprrr commentedRe-roll of patch on top of media_entity 2.x.
Comment #24
woprrr commentedAnd manual tests processed :
Comment #25
phenaproximaSince it's just a reroll, I feel OK re-RTBCing this.
Comment #27
phenaproximaThanks, everyone!