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

Add the Request object to the constructor for Components #2444

Closed
ctgraham opened this issue Apr 14, 2017 · 24 comments · May be fixed by #2546
Closed

Add the Request object to the constructor for Components #2444

ctgraham opened this issue Apr 14, 2017 · 24 comments · May be fixed by #2546
Assignees
Labels
Housekeeping:1:Todo Any dependency management or refactor that would be nice to have some day.

Comments

@ctgraham
Copy link
Collaborator

From #1923 (comment):

[W]e should be providing the $request object more consistently to the controller classes, including GridCellProviders etc., perhaps by passing them in right when those classes are instantiated and having them save a reference. Right now access by those objects to the instantiated $request is spotty.

This is a blocker for #1923.

@ctgraham ctgraham self-assigned this Apr 14, 2017
ctgraham added a commit to ulsdevteam/pkp-lib that referenced this issue Apr 14, 2017
…l PKPRequest object, then use this request object for other methods rather than passing it as a parameter
ctgraham added a commit to ulsdevteam/ojs that referenced this issue Apr 14, 2017
…n initial PKPRequest object, then use this request object for other methods rather than passing it as a parameter. ##ulsdevteam/refactor-gridcell-constructor##
@crism
Copy link
Contributor

crism commented Apr 14, 2017

Visiting .../ojs_dev/index/admin/index:

Call to undefined method Request::getId() in .../ojs_dev/lib/pkp/classes/controllers/grid/GridCellProvider.inc.php on line 50

@crism
Copy link
Contributor

crism commented Apr 14, 2017

Looks like GridCellProvider::render() expects $row as the first argument (and getId() is called on it), but we’re now passing a request.

@ctgraham
Copy link
Collaborator Author

Good catch. That will be a missing change in the calling function. $request should be in the constructor now, and not in the render() arguments.

@crism
Copy link
Contributor

crism commented Apr 14, 2017

Ah-hah… you rewrote GridCellProvider::render(), but there’s a call somewhere that didn’t catch up. I don’t have a stack trace, though… to the grepmobile!

@crism
Copy link
Contributor

crism commented Apr 14, 2017

GridCategoryRowCellProvider::render() and GridHandler::_renderCellInternally() are culprits… shall I fix them, or will you?

@ctgraham
Copy link
Collaborator Author

You're welcome to fix and PR into ulsdevteam's refactor-gridcell-constructor branch, if you've already got them. Otherwise, I'm almost done resetting my dev environment to be ready to start into fixes myself.

@crism
Copy link
Contributor

crism commented Apr 14, 2017

Let me finish tracking this further upstream and see where you stand…

ctgraham added a commit to ulsdevteam/pkp-lib that referenced this issue Apr 14, 2017
…:_renderCellInternally() with GridCellProvider::render() syntax
@crism
Copy link
Contributor

crism commented Apr 14, 2017

Ugh… it’s a little more global than just the calls to render(). GridCategoryCellProvider has subclasses, many of which are explicitly passed a request.

@crism
Copy link
Contributor

crism commented Apr 14, 2017

Progress, though; with the latest commit, at .../ojs_dev/index/admin/index:

Call to undefined method GridRow::getCellActions() in .../ojs_dev/lib/pkp/classes/controllers/grid/GridCellProvider.inc.php on line 101

@ctgraham
Copy link
Collaborator Author

Where is GridCategoryCellProvider defined? I'm not seeing it.

@crism
Copy link
Contributor

crism commented Apr 14, 2017

It’s GridCategoryRowCellProvider, in classes/controllers/grid. Sorry for the typo. But I meant GridCellProvider, anyway, that has subclasses.

ctgraham added a commit to ulsdevteam/pkp-lib that referenced this issue Apr 14, 2017
…in children with GridCellProvider::getCellActions() syntax
ctgraham added a commit to ulsdevteam/pkp-lib that referenced this issue Apr 14, 2017
@ctgraham
Copy link
Collaborator Author

ctgraham commented Apr 14, 2017

I think the next step (for next week) is to identify whether GridRows and GridColumns should all be constructed with a $request passed in, per errors like:

PHP Warning:  Missing argument 1 for GridCellProvider::__construct(), called in ./lib/pkp/classes/controllers/grid/GridCategoryRow.inc.php on line 31

@crism
Copy link
Contributor

crism commented Apr 14, 2017

Yeah, I think the refactoring needs to be more thorough. It’s yak-shaving time! I may work on this this afternoon, if you’re done for the week.

@crism
Copy link
Contributor

crism commented Apr 15, 2017

Found a few lacunae to check in.

Also dependencies in other repos:

  • pkp/staticPages
    • StaticPageGridCellProvider
    • StaticPageGridHandler
  • pkp/translator
    • LocaleFileListbuilderGridCellProvider
    • LocaleFileListbuilderHandler
    • LocaleGridHandler

crism added a commit to UIUCLibrary/pkp-lib that referenced this issue Apr 15, 2017
crism added a commit to UIUCLibrary/ojs that referenced this issue Apr 15, 2017
ctgraham added a commit to ulsdevteam/pkp-lib that referenced this issue Apr 17, 2017
ctgraham added a commit to ulsdevteam/ojs that referenced this issue Apr 17, 2017
…KPApplication::getRequest(), for later cleanup
@ctgraham
Copy link
Collaborator Author

@crism, with your commits, I'm no longer seeing failures in the error log. Do you see any additional?

@asmecher, I'm particularly curious about cases like:
https://github.com/ulsdevteam/pkp-lib/blob/015c38da97d2b90778a7de73237ab13e306aacbe/classes/controllers/grid/CategoryGridHandler.inc.php#L41-L45
Here we now require an instantiated request object in the constructor, when it clearly appears that there is a two-step ::construct() then ::initialize() process. It makes me think we should be deferring the assignment of the members like GridBodyElements to the initialize() method instead. Is that legitimate? Do you have any sense of how disruptive that will be?

@crism
Copy link
Contributor

crism commented Apr 17, 2017

Looked through a few grids, including plugins and their settings, submissions in various states, and saw nothing in the error logs. Looks clean to me.

@crism
Copy link
Contributor

crism commented Apr 17, 2017

I’ve also attempted to audit all the uses of GridCellProvider and its subclasses, and they all seem to be clean now.

@asmecher
Copy link
Member

@ctgraham, I'm not particularly concerned about where the $request object gets passed in -- perhaps it's more useful to consider where it's typically used. The __construct/initialize split doesn't exist through most of the stack (just e.g. in Handlers) and I wouldn't want to replicate that all the way down the stack into e.g. GridBodyElements without a good reason for it. I'd recommend passing it in early, e.g. in constructors.

@asmecher
Copy link
Member

@ctgraham, this is going to need a dust-off and port to OMP. Are you willing & able to tackle either/both of those? I can commit to getting it merged ASAP. (I don't think it interferes with the other big merges in a major way.)

@ctgraham
Copy link
Collaborator Author

@asmecher, rebasing shouldn't be a problem; porting to OMP will take some extra time. I presume you prefer I wait to rebase until the OMP work is done?

@asmecher
Copy link
Member

I'd like to merge for OJS and OMP at the same time, in order to avoid breaking the master branch of either app. I don't really have a preference for the order.

ctgraham added a commit to ulsdevteam/pkp-lib that referenced this issue Jun 26, 2017
…t parameter

Conflicts:
	controllers/grid/settings/user/UserGridHandler.inc.php
ctgraham added a commit to ulsdevteam/ojs that referenced this issue Jun 26, 2017
…n initial PKPRequest object, then use this request object for other methods rather than passing it as a parameter. ##ulsdevteam/refactor-gridcell-provider-constructor##
ctgraham added a commit to ulsdevteam/ojs that referenced this issue Jun 26, 2017
…n initial PKPRequest object, then use this request object for other methods rather than passing it as a parameter. ##ulsdevteam/refactor-gridcell-provider-constructor##
ctgraham added a commit to ulsdevteam/ojs that referenced this issue Jun 26, 2017
…n initial PKPRequest object, then use this request object for other methods rather than passing it as a parameter. ##ulsdevteam/refactor-gridcell-provider-constructor##
@asmecher
Copy link
Member

@ctgraham, I'm sorry if I lost sight of this! Was it ready for review/merge when you last worked with it?

@asmecher asmecher modified the milestones: OJS 3.1, OJS/OMP 3.1.1 Sep 25, 2017
@ctgraham ctgraham modified the milestones: OJS/OMP 3.1.1, OJS/OMP 3.2 Jan 23, 2018
@NateWr NateWr added the Housekeeping:1:Todo Any dependency management or refactor that would be nice to have some day. label Nov 27, 2020
@NateWr NateWr removed this from the OJS/OMP/OPS 3.3 milestone Nov 27, 2020
@NateWr
Copy link
Contributor

NateWr commented Nov 17, 2021

@ctgraham is this work still in progress or abandoned? I'm happy to keep this open if you think it's still going to see work. On the other hand, we will eventually move away from grids and similar components, so the cost v benefit may be waning.

@ctgraham
Copy link
Collaborator Author

This was mired in some strange Travis testing behavior and is now to stale for me to readily pick it back up. It should be considered abandoned.

@NateWr NateWr closed this as completed Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Housekeeping:1:Todo Any dependency management or refactor that would be nice to have some day.
Projects
None yet
4 participants