To reproduce:
1. Set up your filesystem so the webserver owns the files (easiest way to test this).
2. Download the contrib theme release from https://www.drupal.org/node/2398343 and install it on a Drupal 8 site (use the patch from #2042447: Install a module user interface does not install modules (or themes) if you want to install it with the Update Manager).
2. Go to admin/theme/update. It correctly tells you there's a newer version and lets you download the files.
3. But nothing happens after that. It essentially makes it look like you're finished and has a success message on the screen, but never takes you to the next screen (as Drupal 7 does) to actually replace your existing copy of the theme with the downloaded new copy.
Part of this is fixed by #2042447: Install a module user interface does not install modules (or themes) but the fundamental problem here can be seen from comparing update_manager_download_batch_finished(), which is a batch "finished" callback, between Drupal 7 and Drupal 8:
https://api.drupal.org/api/drupal/modules!update!update.manager.inc/function/update_manager_download_batch_finished/7 (Drupal 7)
https://api.drupal.org/api/drupal/core!modules!update!update.manager.inc/function/update_manager_download_batch_finished/8 (Drupal 8)
The code in Drupal 7 does a drupal_goto() which works to send the user to the next step; the blind replacement of that with a RedirectResponse in Drupal 8 does nothing since there's no mechanism for batch finished callbacks to return a response object and have it used.
This may require changes to the batch API to fix, to give batch finished callbacks some way to (conditionally) set a redirect.
This is a critical bug since updating existing modules and themes is one of the main purposes of the Update Manager module, and especially because people use this to perform security updates (which makes it even worse to have this fail but not be clear in the administrative interface about the fact that it failed).
Comment | File | Size | Author |
---|---|---|---|
#13 | update-manager-batch-fix-2426969-13.patch | 7.41 KB | David_Rothstein |
#13 | update-manager-batch-fix-2426969-13-TESTS-ONLY.patch | 4.34 KB | David_Rothstein |
#10 | updating_existing-2426969-10.patch | 9.66 KB | joelpittet |
#5 | 2426969-5.patch | 9.66 KB | dawehner |
#3 | update-manager-batch-fix-2426969-3.patch | 3.07 KB | David_Rothstein |
Comments
Comment #1
catchDemoting to major due to #2352637: Remove the UI for installing/updating modules from update module if it is not fixed in time for release.
Comment #2
David_Rothstein CreditAttribution: David_Rothstein commentedDemoting doesn't really make sense to me; this is critical for at least one (and possibly two) reasons at https://www.drupal.org/node/45111 - what does the other issue have to do with issue priorities?
If this functionality were moved to contrib, it would be an equally critical bug there. In the meantime, demoting it just means developers will be less likely to work on fixing it (though I don't think that will be a problem in practice here).
Anyway, let's see if we can fix it...
Comment #3
David_Rothstein CreditAttribution: David_Rothstein commentedHere is how I would fix it (entirely within the batch API)... It seems like the ability to control the redirect from a batch 'finished' callback is a useful feature that worked in Drupal 7 but has gone missing in Drupal 8?
This patch works for me when applied on top of the one from #2042447: Install a module user interface does not install modules (or themes). (The code added in that issue should in theory allow tests to be written for this one too.)
Comment #4
tjaoht CreditAttribution: tjaoht commentedI'm using Drupal 8.0.0-beta7
I had to apply both patches from #3 and then add this:
underneath
in /core/lib/Drupal/Core/FileTransfer/Local.php (around line 8)
Otherwise I get errors when installing a module due to the use of RecursiveIteratorIterator and RecursiveDirectoryIterator being used inside the Drupal\Core\FileTransfer namespace.
Comment #5
dawehnerTried to write a test, but its failing for some reason in some odd way at the moment, more later.
I agree making the return statement a redirect, is a great way to add this API back.
Comment #7
webchickWe spoke about this on our branch maintainer call today. While there's no way to know when we're going to hit the "~5 critical issue" threshold, the DA is in the process of planning a D8 Accelerate sprint from July 2 - 8. So July 1 is a logical date to revisit this and any other "fix it or nix it" issues. (If we still have a ridiculous number of criticals at that point, we'll move the evaluation date.)
Comment #10
joelpittetre-roll of #5
Comment #12
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedI'll take a look and see if I can figure out the failing tests.
In the meantime, moving this to the batch API queue since the code to fix this is entirely in the batch API - it needs fixing and review there regardless of the Update Manager. (We should still write an Update Manager test for this once #2042447: Install a module user interface does not install modules (or themes) is committed, though.)
Comment #13
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedThis should do it, I think. Expecting two failures from the tests-only patch.
No interdiff from #10 because I also moved the new test to its own method, and cleaned up the commented-out code, etc. But here are the two essential changes:
This was just asserting the wrong thing. We are trying to force a redirect to the custom "test page" in this case, so we need to assert the text that appears on that page.
This I don't entirely understand why it's necessary, but absolute URLs seem to be the way to go here to make the tests pass. (And interestingly, the Update Manager itself is already using an absolute URL in its batch finished callback - that's how I got the idea to try it here.)
Comment #15
joelpittetRead through the code, tests and comments and everything seems to be in order.
This resolves dynamic redirects from the Batch API as the title suggests with RedirectResponse objects being returned from the finished callback.
Of course it would be nice to have an OOP batch api, but this fixes the bug;)
Comment #16
alexpottThe tests and the docs look good and this is fixing a regression from Drupal 7. I think this is worth fixing regardless of what happens to the update UI.
This issue addresses a major bug and is allowed per https://www.drupal.org/core/beta-changes. Committed e59a45f and pushed to 8.0.x. Thanks!
Comment #18
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedSince this was committed before #2042447: Install a module user interface does not install modules (or themes) it went in without tests for the Update Manager. I created a new issue with a patch for the tests at #2548511: Write tests for the Update Manager downloading and applying updates for a module now (seems pretty important to get that in so this problem can't regress).