-
-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check whether opcache is restricted before attempting to invalidate #351
Conversation
I couldn't think of a way to make a test work for this. I think we would need to just restrict the opcache api by default in the test environments |
Could we not utilise ini_set? |
Can you produce a test where it is failing with this based on the ini_get method, and we can go from there? Thanks. |
@alexbowers I mention above that I cannot get a test working since this would require setting the ini value before running tests. We'd need to have a specific travis runtime for that if we want to test it. As far as ini_set, what would you set? Obviously PHP isn't going to let you remove a restriction yourself during runtime, is there something else we can set? |
@KorvinSzanto For now, please can you just provide a code example that fails for you, without requiring ini_set (based on the actual .ini file). And please can you show me what the ini value is for all the opcache settings? Just so I can replicate and try to figure out a way to test it on my end too. |
@alexbowers set opcache.restrict_api to a directory other than where your stash code is located. A good example is to restrict it to a directory that doesn't exist: opcache.restrict_api=/some/diectory/that/doesnt/exist Then run the tests. You'll see they fail with a bunch of errors without this pull request and complete happily with it. |
Here's an example output without this pull request:
|
Great. I am now able to replicate. Thank you. |
Okay, I can't find a way to test it, but one thing that we can do I is improve the travis test matrix to have the opcache settings setup by default for some builds to prove that it works with and without opcache. |
@alexbowers That's what I suggested in my original reply:
However, I don't think testing this thoroughly is as pressing as implementing a fix. |
Without a test covering it, I'll have to delegate this to @tedivm since he understands the system far better than I. |
I have restarted the build, because it appeared to fail based on env. issues. |
So the issue is, if I understand it, that when people have the opcache enabled but have restricted the api are getting errors? If this request is pulled it means the data will not get invalidated when the files change. That means that stale data would be returned, which would cause some serious issues that are going to be difficult for people to pinpoint. I think throwing a more specific error about this issue and pushing users on systems with this limitation to the SQLite bases filesystem driver may be a better alternative. |
So perhaps the fix is to throw a descriptive exception? Also, @tedivm Are you able to figure out why these tests are failing currently? |
It looks like travis has removed sudo ability and it's required for the hhvm test. It's probably fixable if someone has the time. |
Was this resolved elsewhere? |
It was not, but the solution here would result in data corruption. I would happily accept a PR that throws an error if opcache is enabled but the API is restricted, like @alexbowers mentioned. I've also updated the test suite and set it up with Github Actions, so we're in a much better place to pull PRs in now. |
This resolves issue #350
When using the FileSystem driver on a system where
opcache.restrict_api
is defined in php.ini, stash throws a fatal error on save. With this change, we check that ini setting before attempting to clear cache.