Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Convert this page callback to a new-style Controller, using the instructions on http://drupal.org/node/1800686
Comment | File | Size | Author |
---|---|---|---|
#43 | action-1939024-43.patch | 4.62 KB | tim.plunkett |
#43 | interdiff.txt | 3.07 KB | tim.plunkett |
#41 | action-1939024-41.patch | 1.56 KB | tim.plunkett |
#31 | drupal-action-manage-1939024-31.patch | 12.62 KB | Alan Evans |
#31 | interdiff.txt | 1.17 KB | Alan Evans |
Comments
Comment #1
Alan Evans CreditAttribution: Alan Evans commentedLooking into this - seems it would need to be merged with #1939026: Convert action_admin_remove_orphans to a new-style Controller at some point.
Comment #2
Alan Evans CreditAttribution: Alan Evans commentedAttaching a patch for status/progress update - it works, but I want to convert the form also (which for one thing avoids using that module_load_include in this patch).
Comment #3
Alan Evans CreditAttribution: Alan Evans commentedComment #4
Alan Evans CreditAttribution: Alan Evans commentedComment #5
Alan Evans CreditAttribution: Alan Evans commentedAdded form conversion, confirmed form does what it should ... a little unsure on some naming conventions.
Comment #6
Crell CreditAttribution: Crell commentedNeeds an @file docblock.
Because this controller uses the database, we should inject the database connection here, save it to $this->database, and then modify the code below to not use db_query() but use $this->database->query(). (And similar.)
Drupal coding standards say to always "use" the class at the top of the file, and then just use its short name here (ActionAdminManageForm).
Otherwise, I think this seems reasonable.
Comment #7
mtiftI merged this patch with #1939026: Convert action_admin_remove_orphans to a new-style Controller, incorporated Crell's comments from both issues, and closed 1939026.
The one piece I did not understand was what it means to "inject the database connection." I couldn't find any other uses of "$this->database", but if you could point me to an example or documentation I would gladly look into it.
Comment #9
mtiftSorry for not including the interdiff.txt. I made my changes before I committed the original patches.
Comment #10
Alan Evans CreditAttribution: Alan Evans commented@Crell - thanks for the review! I was hoping someone would point me in the right direction on the database injection thing.
@mtift - thanks for working on this, but there seems to be a lot of changes missing from your patch... almost looks like you only posted an interdiff, and not the original. I'll look into merging everything together again including both our changes.
Comment #11
mtiftAlan, you are correct about the interdiff -- I was wondering why that patch failed so badly. I was trying to be helpful, and it was a good learning experience for me, so hopefully you can still just jump back in where you were. :)
Comment #12
Alan Evans CreditAttribution: Alan Evans commentedYep, glad of the help, thanks.
The patch applies cleanly to where I was, so your changes have been incorporated and I'm just planning to put in Crell's database suggestions before uploading a new one.
Comment #13
Alan Evans CreditAttribution: Alan Evans commentedHere's where I'm at - I don't think it's 100% done still. Current patch contains:
Couple of problems remaining:
Long story short - I think this patch still needs a little tweaking to resolve this local task issue. Any input on the multiple paths for a single item appreciated. I'll take a look when I can if the single default local task had any visible effect in the previous version.
Comment #14
Alan Evans CreditAttribution: Alan Evans commentedAnd I will fix that newline dammit! ... next iteration ...
Comment #15
Alan Evans CreditAttribution: Alan Evans commentedMaybe this is the way to handle that default argument on the local task:
Comment #16
Alan Evans CreditAttribution: Alan Evans commentedReviewed the functionality of the page in vanilla 8.x - that local task doesn't create a tab at all, so I really have no idea what it's doing there. I'd propose just removing the lower level (the default local task) on that and be done.
Comment #18
Alan Evans CreditAttribution: Alan Evans commentedThe above test fails are reasonable, because the path the tests are using is no longer correct, though clicking through you'd never see that.
Not sure why I didn't see this patch blow up earlier - I can only imagine I was typing in urls manually instead of clicking around. The tests have the path hardcoded, so they naturally blow up when it changes, and the tests probably don't notice if the higher path (without /manage) fails.
I'm not keen on changing the path as part of this, so I guess make 2 routes pointing to the same place?
Comment #19
Alan Evans CreditAttribution: Alan Evans commentedProgress ... should be all green now (at least it is locally - fingers crossed).
Comment #20
Alan Evans CreditAttribution: Alan Evans commentedComment #21
Crell CreditAttribution: Crell commentedNeeds a docblock with a @var delcaration for the class itself. That way IDEs can auto-complete off of it.
Needs a docblock, even if it's a trivial one. "Constructs a new ActionController" (plus @param) is sufficient.
Otherwise, if the menu is still working I think we're good here. Thanks, you two! Let's tidy up the docs and get this put to bed.
Comment #22
Alan Evans CreditAttribution: Alan Evans commentedThanks for the review and for bearing with me! Added some more docs ...
Would like to do one last manual runthrough to check it all works as it should (I was seeing a little disconnect between test results and real life results at the beginning of this thread), but I'll have to leave that for another day.
Comment #23
tim.plunkettProvides a configuration form....
Delete these lines
These are usually split over multiple lines.
Closing } goes on a new line.
Missing a blank line after the method before the end of the class.
__construct should be the first method in the class.
Missing the description line
Missing @return
I realize this is probably moved code, but it should be
I believe you need
array('absolute' => TRUE)
passed for the options to url(). Does this have test coverage?Comment #24
Alan Evans CreditAttribution: Alan Evans commentedThanks for the thorough review, Tim, and sorry for the careless style errors.
btw - the manual test run that I was planning turned out fine.
Looks like you're right btw about the absolute url for redirects: while Chrome does something sensible with the "relative" url, the Location header is not strictly correct/ backward compatible.
In general, test coverage for action seems reasonable, but my initial patches were passing tests where manual testing revealed issues, so possibly not sufficient. The discrepancy was caused by existing tests relying on hardcoded paths (rather than a user behaviour), meaning 1) They don't uncover issues that occur at an equivalent path to the hardcoded one and 2) They are anchored to those paths and blow up if the path has to change.
Should have corrections shortly ...
Comment #25
Alan Evans CreditAttribution: Alan Evans commentedComment #26
mtiftI'm looking at http://drupal.org/node/1800686 and #1945564: Convert confirm_form() in shortcut to the new form interface and convert route and wondering if the namespace (and directory structure) here should be Drupal\action\Form?
Comment #27
mtiftI also did not find any information about Forms on this page (under development) "PSR-0 path naming conventions": http://drupal.org/node/1929784, and it seems like that would be the page for it.
Comment #28
Crell CreditAttribution: Crell commentedI don't think we have a formal standard yet. I've been encouraging Drupal\$module\Form\SomethingForm and Drupal\$module\Controller\ThingieController, but that's not a hard rule at present.
I guess we should probably switch to that, and then I'll let Tim have final word on this one.
Comment #29
tim.plunkettYes please, to both Form\SomethingForm and Controller\SomethingController
Comment #30
Alan Evans CreditAttribution: Alan Evans commentedMakes sense ... on it.
Comment #31
Alan Evans CreditAttribution: Alan Evans commentedNote the interdiff only shows the text modifications, not the file move.
Comment #32
Alan Evans CreditAttribution: Alan Evans commentedComment #34
Alan Evans CreditAttribution: Alan Evans commented#31: drupal-action-manage-1939024-31.patch queued for re-testing.
Comment #35
mtiftI want to try and document a discussion with @msonnabaum in the WSCCI IRC meeting yesterday regarding this patch in particular, but also conversion patches generally. @Alan Evans, sorry to pile on in your issue, but I think the suggestions below might have much broader implications and I wasn't sure if there was a better place to post this information.
@msonnabaum was advocating that PHPUnit tests be part of the conversion issues. His feeling was that we could encourage it, but not require it. He said that "if a new patch comes in adding a class, and it either a) doesn't have tests or b) has tests, but uses UnitTestBase, we should encourage using PHPUnit." He said that the tests in core/tests could serve as examples.
Further, with reference to this particular patch, he thought that adding a procedural function, such as action_synchronize(), in a new OOP class will make testing more difficult.
Comment #36
Crell CreditAttribution: Crell commentedWhile I agree with mark on PHPUnit++ and avoiding function calls in classes, for controller conversion I don't know that it's the appropriate place to really drive that. action_synchronize() is an existing function. It really ought to turn into an action management service, a la BookManager in #1938296: Convert book_admin_overview and book_render to a new-style Controller, but I don't know that we can make that a requirement for the conversion issues themselves as that increases the barrier to entry for these patches. I'd almost prefer to mostly not do that for now (with some exceptions), and then come back in a second pass to make more module services by eliminating functions. That way more people will have had their hands in the pie, and gotten experience with OO and why dependencies are nice.
I'd rather not throw 3 new things at people at once (controllers, PHPUnit, service conversion), when we finally after 2 years have something in WSCCI we can crowdsource. If someone wants to I certainly won't stop them, but I don't think we can make that a requirement.
Comment #37
mtiftSo it sounds like everyone basically agrees and that 31 is ready to go. I'd mark this RTBC, but I don't quite feel qualified to do that, yet. :)
Comment #38
msonnabaum CreditAttribution: msonnabaum commentedLooked at this patch a bit closer. The only thing worth unit testing is ActionController::adminManage. It's already too long as it is, so it would benefit from being decomposed a bit so the smaller methods could be tested, but it's using procedural functions throughout, so it's probably not worth it here.
Comment #39
Crell CreditAttribution: Crell commentedThen let's move forward and do further refactoring later. Thanks, Mark.
Comment #40
webchickCommitted and pushed to 8.x. Thanks!
Comment #41
tim.plunkettQuick follow-up, a hook_menu() entry is not needed for MENU_CALLBACK once converted, and route_name is redundant with MENU_DEFAULT_LOCAL_TASK. You'll notice the removed route is identical to the one above it.
Comment #43
tim.plunkettAh, didn't notice that other code was incorrectly directly addressing the default path.
Comment #44
Crell CreditAttribution: Crell commentedYou are correct sir!
Comment #45
andypost+1 to commit
Comment #46
webchickCommitted and pushed to 8.x. Thanks!
Comment #48
kim.pepperI think was something missed in the conversion. We still have this in action.admin.inc that no longer gets called:
Comment #49
Alan Evans CreditAttribution: Alan Evans commentedI've tried quickly rewinding my local checkout to ef63cffdf3dc2a873 and seeing what might have previously called this and I still see no mention of either action_admin_delete_orphans_post or even just action_admin_delete_orphans (assuming that the _post may have been dynamically added). It appears that it was also not directly mentioned in code prior to this patch (or more likely I haven't found it yet).
Have you checked manually already whether this was called previously called and no longer is, or just grepped? Do you know where it was previously called from?
Comment #50
andypostActions have bad test coverage so needs manual testing #1412964: Add additional test coverage for actions and probably follow-up
Comment #51
tim.plunkettThis was fixed, reclosing.