Problem/Motivation
Follow-up from #3578585: Fix tests and code style (phpcs. phpstan, styleint, cspell, eslint, ...)
Currently the "photoswipe.drush.inc" file contains old D7 code, to install the photoswipe plugin. This file should be updated and migrated to a native Drupal 11 "DrushCommands" class containing modern D11 drush methods to install the photoswipe plugin.
Afterwards we should also document in the README, that this option exists as an alternative to install the photoswipe plugin.
Steps to reproduce
Proposed resolution
Replace "photoswipe.drush.inc" with a native Drupal 11 "DrushCommands" class and adjust the README accordingly.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork photoswipe-3605632
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
anybodyComment #4
sapnil_biswas commentedStarting to work on this, assigning it to myself
Comment #6
sapnil_biswas commentedMarking this for review. Please let me know if anything seems out of scope or needs some rectification.
Comment #7
anybodyHi @sapnil_biswas very nice, thank you! Did you also test this manually already?
Comment #8
anybodyPS: Is it maybe possible to add a test if this works? (Unsure if that's possible in GitLab CI because it would request external ressources)...
Comment #9
sapnil_biswas commentedHello @anybody, I tested this manually in my local environment and verified that it works correctly. However, I haven't conducted thorough testing of all possible use cases yet as I am in the midst of my university exams and GSoC. I will be able to add the tests if required in this current issue after 2 weeks or so, If anyone wants to take it from here, they are much appreciated to take this on
Comment #10
anybodyI thought about placing a constant for the Photoswipe download URL into the main module, but it's already in the .libraries.yml and in composer, so I think it won't help much.
Thanks @sapnil_biswas let's keep it like this, should be a good enough replacement. Only tests left and I left some final comments.
Comment #11
sapnil_biswas commented@anybody I am done with adding the tests I tried running them without dt_mock.inc, but the CI pipeline failed with a Call to undefined function dt() fatal error because KernelTests don't automatically load Drush. So, the mock is strictly necessary for the tests to run. This is my first time with such tests so let me know if this require any kind of refactor
Comment #13
grevil commentedHey @sapnil_biswas. I extended and adjusted your approach in 3605632-drushcommands-revised. Unfortunately, I don't have the time to finish this. The test fails and I get:
Maybe you find the time and could take a look? I need to cut it here unfortunately.
Comment #16
sapnil_biswas commentedHey @grevil, thanks for the change of tack! I pushed a few fixes to get the pipeline back to green. Reverted cross-partition directory move to Symfony's Filesystem::rename (Drupal's move fails for cross-partition directories in CI). Small bug fix in mock ZIP structure of the test. Let me know if there is anything more to be addressed
Comment #17
anybody@sapnil_biswas did you test this manually?
Comment #18
sapnil_biswas commentedYes, I have manually tested photoswipe:install-plugin command locally on a clean Drupal 11 environment
Comment #19
anybodyTest fail now with the stricter handling, I think we should keep the code and check the deeper reason.
Comment #20
sapnil_biswas commentedSo I dug deeper into this Drupal's FileSystem::move() fails because it falls back to PHP's copy() when moving across partitions (e.g. from /tmp to DRUPAL_ROOT in CI). PHP's copy() crashes as it only works on files and not directories. Cross-partition directories are mirrored recursively by Symfony’s Filesystem::rename(). In Drupal core we have this limitation, so what do you think about reverting back to Symfony's Filesystem only for this move operation?
Comment #21
grevil commented@sapnil_biswas thanks for the investigation! Makes sense to me, go for it, but add a comment along the lines of "We are using symfony's Filesystem::rename() here instead of x, because y".
I'll do a quick manual test on my site and then we should be good to go :)
Comment #22
sapnil_biswas commented