Code Monkey home page Code Monkey logo

Comments (11)

Ocramius avatar Ocramius commented on June 15, 2024 1

@Lokilein are you able to provide a failing test, perhaps? 🤔

from laminas-cache-storage-adapter-filesystem.

Ocramius avatar Ocramius commented on June 15, 2024

@Lokilein does this not affect 2.2.x?

from laminas-cache-storage-adapter-filesystem.

froschdesign avatar froschdesign commented on June 15, 2024

@Lokilein

However, since the new version, the FileSystemOptions always calls the setCacheDir with the parameter null: $this->setCacheDir(null); (FileSystemOptions.php:115)

After that, your configuration is passed down a few layers:

$this->setCacheDir(null);
parent::__construct($options);

https://github.com/laminas/laminas-stdlib/blob/9c92afc89381d9f251aff6edf7bbd5db42c82071/src/AbstractOptions.php#L38-L43

https://github.com/laminas/laminas-stdlib/blob/9c92afc89381d9f251aff6edf7bbd5db42c82071/src/AbstractOptions.php#L52-L75

https://github.com/laminas/laminas-stdlib/blob/9c92afc89381d9f251aff6edf7bbd5db42c82071/src/AbstractOptions.php#L113-L131

And if something is wrong then the adapter will throw an exception:

private function normalizeCacheDirectory(string $cacheDir): string
{
if (! is_dir($cacheDir)) {
throw new Exception\InvalidArgumentException(
"Cache directory '{$cacheDir}' not found or not a directory"
);
} elseif (! is_writable($cacheDir)) {
throw new Exception\InvalidArgumentException(
"Cache directory '{$cacheDir}' not writable"
);
} elseif (! is_readable($cacheDir)) {
throw new Exception\InvalidArgumentException(
"Cache directory '{$cacheDir}' not readable"
);
}
return rtrim(realpath($cacheDir), DIRECTORY_SEPARATOR);
}

from laminas-cache-storage-adapter-filesystem.

Lokilein avatar Lokilein commented on June 15, 2024

@Lokilein does this not affect 2.2.x?

Might be so, I just updated and it occured to me with this version. We've updated from 1.2 though.

from laminas-cache-storage-adapter-filesystem.

Ocramius avatar Ocramius commented on June 15, 2024

If you've updated from 1.x, then BC breaks are expected anyway: re-labeling as bug

from laminas-cache-storage-adapter-filesystem.

Lokilein avatar Lokilein commented on June 15, 2024

@froschdesign Correctly. At the end, it works like it should, but as it checks the "null" aka sys_tmp_dir as well now, even though it will be overwritten soon after, it breaks where it should not break.

@Ocramius Agree!

from laminas-cache-storage-adapter-filesystem.

Lokilein avatar Lokilein commented on June 15, 2024

@Ocramius Hmm, not sure what you mean?

I think you just need to configure a valid Filesystem Cache with a valid cache_dir (like my example above). And if you now configure your php.ini to set your sys_tmp_dir=/does/not/exist or similar, the error should already occure.

I cannot provide my/our code as example, as we have a quite big monolith and an own Factory for the caches. That would be a overhead and not easy to extract...

from laminas-cache-storage-adapter-filesystem.

froschdesign avatar froschdesign commented on June 15, 2024

@Lokilein
Write a test that illustrates the problem and send it as a pull request. Compare with the existing tests:

final class FilesystemOptionsTest extends AbstractAdapterOptionsTest

from laminas-cache-storage-adapter-filesystem.

Lokilein avatar Lokilein commented on June 15, 2024

@froschdesign
hmm... I am currently working on Windows, which makes the tests difficult, but even though - I am not sure how to make sure that the sys_temp_dir is not writeable, as it is also not changable by ini_set or something and I will not change the rights of the default folder (and I hope that this would not work :D)

But, when I run the tests with an invalid php.ini setting (C:\doesnotexist), my tests are already failing with an error, while they all pass when the sys_tmp_dir is valid.

With the invalid setting, I receive:
[ErrorException] tempnam(): file created in the system's temporary directory

I think that this fails because createAdapterOptions calls the constructor and this is enough to reproduce - depending on the configured path.

from laminas-cache-storage-adapter-filesystem.

Ocramius avatar Ocramius commented on June 15, 2024

docker run --rm -ti -v $(pwd):/app -w /app php:7 bash and work from there? 🤔

from laminas-cache-storage-adapter-filesystem.

tck avatar tck commented on June 15, 2024

Pull request to fix this issue #73

from laminas-cache-storage-adapter-filesystem.

Related Issues (18)

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.