Skip to content
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

Use relative paths for function js() #93

Merged
merged 2 commits into from
Aug 19, 2024

Conversation

h-e-l-l-o-w-o-r-l-d
Copy link
Contributor

@h-e-l-l-o-w-o-r-l-d h-e-l-l-o-w-o-r-l-d commented Aug 19, 2024

All Submissions:

  • Have you updated the ChangeLog with your proposed changes?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • pr update to master branch
    • Have you updated the getPluginVersion() in Plugin.php and Makefile version appropriately?

New Feature Submissions:

  • Have you added an explanation of what your changes do and why you'd like us to include them?

Description

We have a composer based installation of kanboard and your plugin Wiki. The plugins are stored inside vendor folder (because composer does it) and symlinked in /vendor/kanboard/kanboard/plugins/.

The class WikiHelper.php tries to generate an absolute path which doesn't work in such environments, because the plugin is stored in /var/www/app_kanboard/vendor/funktechno/kanboard-plugin-wiki and not /var/www/app_kanboard/vendor/funktechno/Wiki. See warning:

Warning: filemtime(): stat failed for /var/www/app_kanboard/vendor/funktechno//Wiki/Asset/vendor/jquery-sortable/jquery-sortable.js in /var/www/app_kanboard/vendor/funktechno/kanboard-plugin-wiki/Helper/WikiHelper.php on line 42

Warning: filemtime(): stat failed for /var/www/app_kanboard/vendor/funktechno//Wiki/Asset/Javascript/wiki.js in /var/www/app_kanboard/vendor/funktechno/kanboard-plugin-wiki/Helper/WikiHelper.php on line 42

You can fix this by adding another symlink from "Wiki" to "kanboard-plugin-wiki", but there is a better solution:

First, your code in

$filepath = $dir.'/'.$filename;
generates double slashes "funktechno//Wiki" -> bad.

Second and most important: Absolute paths don't work in composer based installations. To fix this, relative paths should be used for including files. The same approach is used in the file /Plugin.php for example.

This pull request fixes this. It works in composer-based and non-composer-based installations.

Note 1: The problematic code was added lateley. There were no warnings in version 0.3.2.

Note 2: There already might be helpers in kanboard to include scripts. If so, they should be used instead.

@lastlink
Copy link
Contributor

tested

@lastlink lastlink merged commit 453bef3 into funktechno:dev Aug 19, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants