Create AJAX runtime environment setup/cleanup#101
Conversation
|
Hi @felixarntz After setting this up I've been facing errors where the The reason these functions are called is because we need to create the I'm wondering what the best path forward is here? Whether we refactor the Happy to discuss this over a call as I feel this is somewhat related to my other comment - #100 (comment) Thanks |
|
@jjgrainger Good catch! Maybe we can get around this without any notable refactoring, just by executing that logic later? While we have to call the code in Potentially, we can hook the code into the |
|
Thanks @felixarntz I've updated the PR to use the After updating this I came across a different error where the I've put in a small fix to get around this but I'm not sure this is the best approach but we can discuss as part of the code review. |
felixarntz
left a comment
There was a problem hiding this comment.
@jjgrainger Left a few comments, some of them similar to what I mentioned on #100.
| 'plugin' => $plugin, | ||
| 'checks' => $checks, |
There was a problem hiding this comment.
I see you're returning all these values from every AJAX endpoint just to be able to chain the AJAX requests in the JS file. I think that makes for a confusing architecture and requires us to include unnecessary data in the AJAX responses. No need to fix that here since it's already happening in existing code, but I think that will be something we should resolve as part of the architecture review.
There was a problem hiding this comment.
Thanks @felixarntz I agree and let's tackle this as part of the architectural review.
| .then( setupEnvironment ) | ||
| .then( runChecks ) | ||
| .then( cleanupEnvironment ) |
There was a problem hiding this comment.
See my comment below, rather than chaining these and thereby forcing every AJAX response to include its request parameters to pass it on to the next AJAX request, I think we should decouple them.
We can then change the JS functions to accept dedicated parameters for the things that each function needs rather than the generic data object from the previous AJAX response.
But like my comment above, let's handle this refactoring in a separate PR.
felixarntz
left a comment
There was a problem hiding this comment.
@jjgrainger Almost good to go, just one thing that is off in the FormData set, and a few nit-picks.
felixarntz
left a comment
There was a problem hiding this comment.
@jjgrainger One last question :)
| if ( ! defined( 'WP_PLUGIN_CHECK_PLUGIN_DIR_PATH' ) ) { | ||
| $plugins_dir = defined( 'WP_PLUGIN_DIR' ) ? WP_PLUGIN_DIR : WP_CONTENT_DIR . '/plugins'; | ||
| $theme_folder = $plugins_dir . '/plugin-check/test-content/themes'; | ||
| } else { | ||
| $theme_folder = WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . 'test-content/themes'; | ||
| } |
There was a problem hiding this comment.
This logic is inverted compared to https://github.com/10up/plugin-check/pull/101/files#diff-35a6c4633cd89c9ad66535db741d064ff3f730cf69ea87d347d8e250544fff1eR85
|
@jjgrainger Now that #100 was merged, there's a merge conflict here, could you look into that please? |
|
Thanks @felixarntz @spacedmonkey I've addressed the conflicts and will merge now |
Closes #86