Closed (fixed)
Project:
PhotoSwipe - Responsive JavaScript Modal Image Gallery
Version:
5.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
12 Dec 2022 at 11:14 UTC
Updated:
13 Oct 2023 at 10:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
anybodyVery unsure if the proposed resolution is correct.
Is
/tmp/site/app/really your Drupal installation path?Does
photoswipe/photoswipe.jsonexist in your drupal libraries folder?Comment #3
abhijityadav commentedPatch created by replacing file_get_contents(DRUPAL_ROOT . '/libraries/photoswipe/photoswipe.json')
With '/' . libraries_get_path('photoswipe') . '/photoswipe.json'
Comment #4
liam morlandComment #5
anybodyComment #6
anybodyI guess this might be fixed by: #3330747: Replace libraries_get_path with the new Core API
Still, I think the patch is not a really good and clean solution here.
Comment #7
anybody3.x is now 4.x - could someone please check, if the issue still exists with PHP >=8.0?
@abhijityadav?
Comment #8
anybodyComment #9
adamevertsson commentedI just started using Photoswipe and yes, the error is there, filling the log.
Warning: file_get_contents(/Applications/XAMPP/xamppfiles/htdocs/web/libraries/photoswipe/photoswipe.json): Failed to open stream: No such file or directory in photoswipe_library_info_alter() (line 120 of /Applications/XAMPP/xamppfiles/htdocs/web/modules/contrib/photoswipe/photoswipe.module)PHP: 8.1.17
Drupal: 10.1.4
Note: I do not have a photoswipe.json file in my libraries folder. I followed the instructions for manual installation:
- Download the "PhotoSwipe-5.3.8" zip file
- Unzip and place the contents of the unzipped "PhotoSwipe-5.3.8" folder into "library/photoswipe" folder so that the folder structure is: library/photoswipe/dist/photoswipe.esm.js
- (Optional) See how to manually require the photoswipe dynamic caption plugin here
- Check the status report for errors
Comment #10
weres commentedYes, I see the same as #9. Same error, same conditions
Comment #11
anybodyComment #12
anybody@AdamEvertsson and @Weres what's the correct folder structure in your case, if
/Applications/XAMPP/xamppfiles/htdocs/web/libraries/photoswipe/photoswipe.jsonis wrong?Where can we find the photoswipe.json in your case?
Let's first fix this in 5.x and afterwards in 4.x
Comment #13
grevil commented@AdamEvertsson and @Weres please take a closer look at the versions on the site! My guess is, your composer.json doesn't contain
minimum-stability": "beta"and therefore, composer will automatically require photoswipe v4 (because photoswipe v5 is still in beta), but you are following the installation instructions for photoswipe 5, which causes the issue:That's why Photoswipe 5 doesn't have a photoswipe.json.
Comment #14
grevil commentedThough I understand your troubles, as you wouldn't expect the first installation instruction on the module page to be a beta release (although photoswipe 5 is pretty much stable).
But thanks to you guys I found a message issue!
Comment #15
grevil commentedComment #17
grevil commentedAdjusted the status report message for 5.x. Please review.
For everyone else running into this issue, either enable
minimum-stability": "beta"in your composer.json and require the photoswipe 5 module OR follow the "Photoswipe 4 library installation" on the module page.I'll update the page text, so it will be more obvious.
Comment #18
anybodyNice one @Grevil! Left some final comments. Afterwards we should merge this into dev and ask the others here, if the message appears for them and (indirectly) solves the issue.
Comment #19
grevil commentedNo, this won't fix their issue, as the changes were not done in 4.x. 4.x is minimally maintained, and I don't see, that such an issue would be important enough. If you disagree, I can create another branch and make a different implementation for 4.x.
Resolved your comments. Please ignore the failing pipeline in https://git.drupalcode.org/project/photoswipe/-/pipelines/24170. Since the switch to Gitlab CI, @dinazaur's custom "drupalci.yml" doesn't apply anymore.
Comment #20
anybodyAs sorry I didn't see that!
So let's merge this one and for the reporters here, back to #13. So this is then fixed by documentation for 5.x and "won't fix" (user error) for 4.x, if #13 is the issue.
Anyway I hope for 5.x to become rc or even stable soon.
Comment #22
anybodyComment #23
agoradesign commentedAfter updating from beta1 to rc1 I see errors on the status report page:
"Photoswipe v5 currently only supports photoswipe library version minimum: 5.2.1
You need to install a compatible version!"
Indeed I've the latest Photoswipe 5.4.1 (and $library_version is indeed "5.4.1")
On looking at the latest commit (https://git.drupalcode.org/project/photoswipe/-/commit/99ea723a66fc90e10...), I see that the version_compare() was changed, from:
if (version_compare($library_version, $min_req_version, '<')) {to
if (version_compare($library_version, $min_req_version) >= 0) {And this checks the opposite of what we want. see example 1 here: https://www.php.net/manual/en/function.version-compare.php
Proposed resolution
Revert the concerning line to
if (version_compare($library_version, $min_req_version, '<')) {Comment #24
anybodyThanks @agoradesign we had a discussion about that line before :D We'll take a look soon and fix it! Thanks!
(But it's unrelated to this issue)
Comment #25
agoradesign commentedyou're welcome... yeah, I know - but I felt it's ok to leave a comment here about this tiny problem. at least it was caused by this issue's commit :D
Comment #26
anybodySorry YES my fault! I thought it was a different issue where it happened! Then it's right here!
@Grevil: Please resolve by reverting that line.
Comment #28
grevil commentedThanks, @agoradesign! Indeed, an unwise change, my apologies.
Comment #29
agoradesign commentedSuch things may happen... version_compare() can be quite confusing to read