-
Notifications
You must be signed in to change notification settings - Fork 16
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
File locking problem on Windows XAMPP #19
Comments
Just following up. Anyone around? |
Not sure why I have missed your first post, maybe I accidentally marked it as read. Try if using CompiledYamlFile class works better. It handles yaml decoding/encoding for you, so you can just pass the data to it. It also always returns an array, even if the file does not exist. It is also much faster and doesn't seem to be causing any issues. You should also test if the locking succeeded as it can fail and you need to deal with it. Umm, does the locking always fail? |
The lock reports as successful but the data still reads as null. I will try the different class this weekend and report back. Thanks. |
You're referring to the Grav class While that should work fine for loading the file to get the views, it's not sufficient for recording the view in the first place. Perhaps I'm not conceptualizing things correctly, though. When recording the view, I need lock the file for longer than just reading the contents. I need to keep the file locked until I record the view. Otherwise, in a flurry of activity, counts may get clobbered. So I think I still need the explicit |
Sorry, I've been super busy. Yes, I'm referring Grav class And yes, it should work with the locking. |
In my Grav plugin Count Views, I'm using the
RocketTheme\Toolbox\File\File
interface. The plugin works fine in *nix environments, but it doesn't work in Windows. (I've only tested under XAMPP. But I'm told it works under the Windows Subsystem for Linux.)The problem is these lines here:
No matter what,
$datafh->content()
is returning null on Windows, even though it loaded the file fine on lines 63-66. The only difference is the file locking.I added an if/then, and indeed the file is getting locked. And I can confirm that if I remove the
lock()
line, everything works as expected.Any help appreciated. Thanks!
The text was updated successfully, but these errors were encountered: