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

[v4] Plugin assets no longer publicly available #5620

Closed
SebastianEberlein-JUNO opened this issue Sep 12, 2023 · 5 comments · Fixed by #5630
Closed

[v4] Plugin assets no longer publicly available #5620

SebastianEberlein-JUNO opened this issue Sep 12, 2023 · 5 comments · Fixed by #5630
Assignees
Milestone

Comments

@SebastianEberlein-JUNO
Copy link

SebastianEberlein-JUNO commented Sep 12, 2023

Description

My test plugin has the following files:

site/plugins/test/index.php

<?php Kirby::plugin('junohamburg/test', []); ?>

site/plugins/test/assets/style.css

html {
  font-family: sans-serif;
}

I load the style.css in the <head> like this:

<?php $mediaUrl = Kirby::plugin('junohamburg/test')->mediaUrl(); ?>
<link rel="stylesheet" href="<?= $mediaUrl ?>/style.css">

In Kirby 3 and Kirby 4 alpha the style.css was copied / linked to the media folder.
In the Kirby 4 beta the file is no longer copied / linked. The browser shows a 404 error for http://localhost:8888/media/plugins/junohamburg/test/style.css

To reproduce

  1. Download plainkit
  2. Add test plugin
  3. Update to Kirby 4 beta, delete media folder
  4. See error

Setup

Kirby Version
Kirby v4-beta.1

System

  • OS: macOS 13.5.2
  • PHP: 8.2.10
  • Tested in Valet and PHP's built-in server
@afbora
Copy link
Member

afbora commented Sep 12, 2023

I can reproduce the issue and @distantnative I've reverted your Plugin assets extension PR and works great: #5557

@afbora afbora added this to the 4.0.0 milestone Sep 12, 2023
@afbora afbora changed the title [v4-beta.1] Plugin assets no longer publicly available [v4] Plugin assets no longer publicly available Sep 12, 2023
@rasteiner
Copy link
Contributor

I kinda feel responsible for the issue. The PR introduces the possibility to serve files from anywhere in the plugin, "assets" being just a naming convention. So the asset path is now relative to the plugin root, this means that the "assets" part of the path has to be included:

http://localhost:8888/media/plugins/junohamburg/test/style.css 
becomes:
http://localhost:8888/media/plugins/junohamburg/test/assets/style.css 

I'm not sure if this is a planned breaking change, or if the default "assets handler" should have mirrored exactly the old behaviour.

@distantnative
Copy link
Member

@rasteiner I think that's an oversight from us, we should try to mimic the old behavior to not have such a breaking change

@distantnative
Copy link
Member

@rasteiner @SebastianEberlein-JUNO Could you check if the following change fixes it for you:

in kirby/src/Cms/Plugin.php change the line https://github.com/getkirby/kirby/blob/v4/develop/src/Cms/Plugin.php#L109 to

$assets[$asset] = $path;

@SebastianEberlein-JUNO
Copy link
Author

@distantnative Yes, changing the line fixes the problem.

distantnative added a commit that referenced this issue Sep 14, 2023
distantnative added a commit that referenced this issue Sep 14, 2023
@distantnative distantnative linked a pull request Sep 14, 2023 that will close this issue
@distantnative distantnative modified the milestones: 4.0.0, 4.0.0-beta.2 Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

5 participants