There are 2 different issues connected to advagg operations with Drush:
1. advagg-clear-all-files, advagg-force-new-aggregates, advagg-enable, advagg-disable commands throw Exception:
Call to undefined method Drush\Config\DrushConfig::save()
Reason: protected \Drupal\Core\Config\Config $config variable defined in the AdvaggCommands class, but DrushCommands class implemets ConfigAwareInterface , and it defines getConfig() getter to get Drush config. So \Drush\Config\DrushConfig is set as $config variable.
The issue is reproducible only for Drush 9.x
2. Lot of errors
The file public://css/optimized//FILE_NAME.css was not deleted because it does not exist.
are thrown when advagg-clear-all-files and advagg-force-new-aggregates commands are called. The same issue exists when execution clear from UI.
Reason: file_unmanaged_delete_recursive() is called with path that contains backslash (it shouldnt)
The issue is reproducible for external file_systems like Amazon S3 and internal file systems that dont process double slashes as one slash both for Drush 8.x and 9.x
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | advagg-broken-drush-9-commands-2949100-9.patch | 4.29 KB | jmagunia |
| #5 | advagg-broken-drush-9-commands-2949100-5.patch | 4.25 KB | joelstein |
Comments
Comment #2
Ser_Mir commentedTry my patch in attachment please. It resolves both problems.
Comment #3
Ser_Mir commentedComment #4
idebr commented@Ser_Mir Thanks for the patch! It works great, however the change has a Drupal coding standard violation:
Class property $advagg_config should use lowerCamel naming without underscores
Comment #5
joelstein commentedRemoving the back slashes didn't prevent the "was not deleted because it does not exist" notice for me.
I updated the patch to simply check if the path exists before attempting to delete it, because that's what file_unmanaged_delete() does before attempting to delete it (and that's where the "was not deleted because it does not exist" error is logged).
I also updated the patch to replace "advagg_config" with "advaggConfig".
Comment #6
norman.lolNice patches! Thanks for the contributions. It absolutely solved my problem when I needed to force new aggregates after Drupal setup in a Docker container before making screenshots with Selenium. Without it the assets weren't loading correctly.
In the end it turned out it wasn't the re-aggregation that fixed my issue. I simply had to chmod/chown the files folder correctly... Thanks for everything anyway. :)
Comment #7
thallesThanks guys!
But this patch needs re-roll:
Comment #8
thallesComment #9
jmaguniaReroll patch attached. There was a conflict which I had to sort through and I had to modify the original patch slightly: there was a call to
$this->configinstead of$this->advaggConfig. I hope its correct.Comment #10
thallesWe need someone to test.
Comment #11
jmaguniaAdding tag so it can be more easily found.
Comment #12
andrey.troeglazov commentedYou have 'public://js/optimized', 'public://css/optimized' paths hardcoded in several places, its not good.
Its better to move it to some constants and use where is necessary.
Comment #13
thallesI suggest creating an interface for this constants in another issues.
@andrey.troeglazov, after the modifications made by @pmagunia does the module work normally?
Thanks @andrey.troeglazov!
Comment #15
thallesComment #16
thallesFixed! Thank's @all for the hard work!