0

I read that WP 3.9+ supports symlink (Article here).

So, my plugin resides in C:\Github\my-plugin. while my project is at C:\Project\my-site.

I successfully symlink it by using this command (run as admin):

mklink /d C:\Project\my-site\wp-content\plugins\my-plugin C:\Github\my-plugin

The symlinked plugin WORKS but I got this debug message on ALL pages:

Warning: fopen(C:/Project/my-site/wp-content/plugins/my-plugin/C:/Github/my-plugin/index.php):
failed to open stream: Invalid argument in
C:\Project\my-site\wp-includes\functions.php on line 4568

Warning: fread() expects parameter 1 to be resource, boolean given in
C:\Project\my-site\wp-includes\functions.php on line 4571

As you can see the path detected by WordPress is a merge of my-site and my-plugin and thus it can't read the file. But weirdly, the plugin runs fine.

Anyone successfully symlinked a plugin in Windows 10?

Thanks

[EDIT]

Found the issue. I hosted my plugin on Github and has a snippet I found online to enable update via admin panel.

The snippet has hardcoded directory so it doesn't detect symlinked url.

4
  • if the plugin works, were does the error come from? May 16 '16 at 4:22
  • I tried symlinking another plugin and this one works without debug error. I'll check if there's issue with the first one.
    – hrsetyono
    May 16 '16 at 4:26
  • Mind updating the question with the relevant info? May 16 '16 at 4:29
  • @MarkKaplun Sorry, found the issue. I have specified it above.
    – hrsetyono
    May 16 '16 at 4:40
1

Not sure about the root cause, but you should avoid using relative paths to files. Because they are relative you never sure where exactly a file is being looked after. It might even become a security risk as PHP might look for the file in the default directories.

The proper way is to use the plugin_dir_path, something like

require_once plugin_dir_path(__FILE__).'github-updater.php';
1
  • Thanks for the tips. I'll change all my requires to this. Also, I found that the issue lies in the code snippet I used has hardcoded directory like $dir . '/' . $slug. That can be fixed with the snippet above.
    – hrsetyono
    May 16 '16 at 4:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.