Coder Social home page Coder Social logo

Comments (28)

PeterDKC avatar PeterDKC commented on September 28, 2024 2

The existence of this is so absolutely mind bogglingly absurd. We have a zoom call of 8 people trying to figure out how to get past this right now, it took us 3 days to figure out what was even happening. Because WHY, IN THE NAME OF ALL THE CHILDREN IN THE WORLD, would anyone do something so completely asinine as writing to /tmp/ from the web user out of a f@#$ing vendor/ package????????

If you don't understand why this is not a reasonable thing to do, I have a pamphlet for a high flying career in food service right here for you to peruse.

from shopify-api-php.

electricsheep avatar electricsheep commented on September 28, 2024 1

Answering my own question with a workaround I found:

  1. Add the following to composer.json
    "autoload": {
        "psr-4": {
            "Shopify\\Clients\\": "app/Overrides/"
        },
        "exclude-from-classmap": ["vendor/shopify/shopify-api/src/Clients/Http.php"]
    },
  1. Copy the Shopify implementation of the Http class to app/Overrides/ folder.
  2. Remove the deprecation file writing code (below) from the logApiDeprecation function of the copied class (or modify in the way you prefer)
       $warningFilePath = $this->getApiDeprecationTimestampFilePath();

        $lastWarning = null;
        if (file_exists($warningFilePath)) {
            $lastWarning = (int)(file_get_contents($warningFilePath));
        }

        if (time() - $lastWarning < self::DEPRECATION_ALERT_SECONDS) {
            return;
        }

        file_put_contents($warningFilePath, time());
  1. Fix the $version line in the request() function, since it relies on the class directory location
        $version = require dirname(__FILE__) . '/../../vendor/shopify/shopify-api/src/version.php';

You may need to run composer dump-autoload after fixing.

from shopify-api-php.

jordansavant avatar jordansavant commented on September 28, 2024

^ This
No composer library should be attempting to write to filesystem, especially a local directory. A simple deprecation warning now produces a fatal error for the entire application.

from shopify-api-php.

wensonsmith avatar wensonsmith commented on September 28, 2024

Same problem here. I don't understand why write a file in /vendor folder. 🤯

from shopify-api-php.

electricsheep avatar electricsheep commented on September 28, 2024

Is there any workaround for this besides forking the library?

This causes a fatal crash and means I can't fetch orders using Order::find() - despite using the most recent API and not requesting any deprecated fields/endpoints, I still get the deprecation warning.

from shopify-api-php.

github-actions avatar github-actions commented on September 28, 2024

This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.

from shopify-api-php.

fredden avatar fredden commented on September 28, 2024

The problem still exists in the latest version of this package, and the most recent commit to the default branch.
https://github.com/Shopify/shopify-api-php/blob/v5.0.0/src/Clients/Http.php#L288

file_put_contents($warningFilePath, time());

from shopify-api-php.

omolto avatar omolto commented on September 28, 2024

+1

from shopify-api-php.

mariusrusu avatar mariusrusu commented on September 28, 2024

+1

from shopify-api-php.

nick-dnc avatar nick-dnc commented on September 28, 2024

+1

from shopify-api-php.

chrisnetonline avatar chrisnetonline commented on September 28, 2024

+1

from shopify-api-php.

appinlet avatar appinlet commented on September 28, 2024

+1

from shopify-api-php.

appinlet avatar appinlet commented on September 28, 2024

+1

from shopify-api-php.

nick-dnc avatar nick-dnc commented on September 28, 2024

+1

from shopify-api-php.

zchermit avatar zchermit commented on September 28, 2024

+1

from shopify-api-php.

appinlet avatar appinlet commented on September 28, 2024

+1

from shopify-api-php.

appinlet avatar appinlet commented on September 28, 2024

+1

from shopify-api-php.

mkbodanu4 avatar mkbodanu4 commented on September 28, 2024

Same issue since Oct 02. All the payments stopped working, so I had to comment out code in the library (file src/Clients/Http.php line 208-213) to get the app working

from shopify-api-php.

appinlet avatar appinlet commented on September 28, 2024

+1

from shopify-api-php.

fredden avatar fredden commented on September 28, 2024

From what I can tell, this was fixed in #263 (3ae0ed4) by moving the temporary file into sys_get_temp_dir() instead of writing to a path within vendor/. This was released as part of version 5.0.0 of this library. (My previous comment was wrong.)

@paulomarg, I think this issue can be closed now.

from shopify-api-php.

vicdelfant avatar vicdelfant commented on September 28, 2024

@paulomarg, I think this issue can be closed now.

It's up to the maintainers of course, but in all honesty I still don't get why a library has to write deprecations to a file. Even though it's just to the temp directory, there's still a file somewhere that can potentially grow to unknown sizes and can't be routed elsewhere.

from shopify-api-php.

fredden avatar fredden commented on September 28, 2024

there's still a file somewhere that can potentially grow to unknown sizes and can't be routed elsewhere.

The file contains only a unix timestamp.

from shopify-api-php.

vicdelfant avatar vicdelfant commented on September 28, 2024

… which then makes me wonder why we need it at all, or at least from a userland perspective.

It's now turning into a discussion of principles and I know that I am on the annoying end of the spectrum, but the cleaner and less surprises in code (especially code provided by a company such as Shopify), the better :)

from shopify-api-php.

ba-tech-gh avatar ba-tech-gh commented on September 28, 2024

It seems like an option to disable this is required, perhaps when doing Context::initialize.

The file .last_api_deprecation_warning makes it impossible to run 2 instances on the same server under different users (something we often do for prod and staging for small apps) because if one of the users creates the file, the other one will be unable to edit it due to lacking ownership.

from shopify-api-php.

appinlet avatar appinlet commented on September 28, 2024

+1

from shopify-api-php.

sercanvirlan avatar sercanvirlan commented on September 28, 2024

+1

from shopify-api-php.

appinlet avatar appinlet commented on September 28, 2024

+1

from shopify-api-php.

Tango459 avatar Tango459 commented on September 28, 2024

+1

from shopify-api-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.