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

Command icon 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

grevil created an issue. See original summary.

anybody’s picture

sapnil_biswas made their first commit to this issue’s fork.

sapnil_biswas’s picture

Assigned: Unassigned » sapnil_biswas

Starting to work on this, assigning it to myself

sapnil_biswas’s picture

Assigned: sapnil_biswas » Unassigned
Status: Active » Needs review

Marking this for review. Please let me know if anything seems out of scope or needs some rectification.

anybody’s picture

Hi @sapnil_biswas very nice, thank you! Did you also test this manually already?

anybody’s picture

Issue tags: +Needs tests

PS: 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)...

sapnil_biswas’s picture

Hello @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

anybody’s picture

I 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.

sapnil_biswas’s picture

@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

grevil’s picture

Status: Needs review » Needs work
Issue tags: -Novice, -Needs tests

Hey @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:

The specified file '/tmp/photoswipe_extract_6a42465875e943.44853368/PhotoSwipe-5.4.4' could not be moved to '/var/w
ww/html/web/libraries/photoswipe'.

Maybe you find the time and could take a look? I need to cut it here unfortunately.

grevil changed the visibility of the branch 3605632-replace-photoswipe.drush.inc-with to hidden.

sapnil_biswas’s picture

Status: Needs work » Needs review

Hey @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

anybody’s picture

@sapnil_biswas did you test this manually?

sapnil_biswas’s picture

Yes, I have manually tested photoswipe:install-plugin command locally on a clean Drupal 11 environment

anybody’s picture

Status: Needs review » Needs work

Test fail now with the stricter handling, I think we should keep the code and check the deeper reason.

sapnil_biswas’s picture

So 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?

grevil’s picture

@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 :)

sapnil_biswas’s picture

Status: Needs work » Needs review