Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Plugins

YAML file locking and reading in Windows vs *nix

Started by Aaron Dalton 8 years ago · 2 replies · 661 views
8 years ago

My plugin Count Views works fine in *nix environments, but it doesn't work in Windows.

The problem is these lines here:

PHP
        // Open data file
        $datafh = File::instance($path);
        $datafh->lock();
        $data = Yaml::parse($datafh->content());
        if ($data === null) {
            $data = array();
        }

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. So what do I have to do to read the file now? Why is it different on Windows?

And I can confirm that if I remove the lock() line, everything works as expected.

Any help appreciated. Thanks!

last edited 08/20/18 by Aaron Dalton
8 years ago

I can confirm the issue on Windows using Xampp.
It doesn't occur when using Windows Subsystem for Linux

This doesn't seem to be an issue in your plugin, but rather at a lower level. Perhaps logging an issue at RocketTheme would be the right way to go.

👍 1

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Rene, 1 week ago
2 46 1 week ago
Plugins · by Xavier, 4 weeks ago
2 55 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1181 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 49 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 73 2 months ago