Failed to open stream: No such file or directory photoswipe_library_info_alter

Created on 12 December 2022, almost 2 years ago
Updated 29 September 2023, about 1 year ago

Problem/Motivation

Exception: Warning: file_get_contents(/tmp/site/app/libraries/photoswipe/photoswipe.json): Failed to open stream: No such file or directory photoswipe_library_info_alter()()

Steps to reproduce

Once you upgrade to PHP 8.0, Issue starts appearing

Proposed resolution

Reaplce file_get_contents(DRUPAL_ROOT . '/libraries/photoswipe/photoswipe.json')
With '/' . libraries_get_path('photoswipe') . '/photoswipe.json'

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

5.0

Component

Code

Created by

🇮🇳India abhijityadav

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany Anybody Porta Westfalica

    3.x is now 4.x - could someone please check, if the issue still exists with PHP >=8.0?

    @abhijityadav?

  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇸🇪Sweden adamevertsson

    I just started using Photoswipe and yes, the error is there, filling the log.

    Warning: file_get_contents(/Applications/XAMPP/xamppfiles/htdocs/web/adamevertsson.se/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/adamevertsson.se/web/modules/contrib/photoswipe/photoswipe.module)

    PHP: 8.1.17
    Drupal: 10.1.4

  • Yes, I see the same as #9. Same error, same conditions

  • Assigned to Grevil
  • Status changed to Active about 1 year ago
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica

    @AdamEvertsson and @Weres what's the correct folder structure in your case, if
    /Applications/XAMPP/xamppfiles/htdocs/web/libraries/photoswipe/photoswipe.json is wrong?
    Where can we find the photoswipe.json in your case?

    Let's first fix this in 5.x and afterwards in 4.x

  • 🇩🇪Germany Grevil

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

    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

    That's why Photoswipe 5 doesn't have a photoswipe.json.

  • 🇩🇪Germany Grevil

    Though 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!

  • Assigned to Anybody
  • Status changed to Needs review about 1 year ago
  • @grevil opened merge request.
  • 🇩🇪Germany Grevil

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

  • Assigned to Grevil
  • Status changed to Needs work about 1 year ago
  • 🇩🇪Germany Anybody Porta Westfalica

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

  • Status changed to Needs review about 1 year ago
  • 🇩🇪Germany Grevil

    Afterwards we should merge this into dev and ask the others here, if the message appears for them and (indirectly) solves the issue.

    No, 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.

  • 🇩🇪Germany Anybody Porta Westfalica

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

  • Issue was unassigned.
  • Status changed to Postponed: needs info about 1 year ago
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇦🇹Austria agoradesign

    After 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, '<')) {

  • 🇩🇪Germany Anybody Porta Westfalica

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

  • 🇦🇹Austria agoradesign

    you'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

  • Assigned to Grevil
  • Status changed to Needs work about 1 year ago
  • 🇩🇪Germany Anybody Porta Westfalica

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

    • Grevil committed 0a22095e on 5.x
      Follow up quick fix to Issue #3326509: Failed to open stream: No such...
  • Issue was unassigned.
  • Status changed to Fixed about 1 year ago
  • 🇩🇪Germany Grevil

    Thanks, @agoradesign! Indeed, an unwise change, my apologies.

  • 🇦🇹Austria agoradesign

    Such things may happen... version_compare() can be quite confusing to read

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024