-
Notifications
You must be signed in to change notification settings - Fork 444
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
Hooks aren't being called from block plugins #5892
Comments
Starting from OJS 3.2.0 initialization of block plugins has moved from |
To make a behavior similar to OJS 3.1.2 (register block plugins earlier), it's possible to change this line:
to something like:
with correspondent changes in |
Before making a PR I need additional confirmation that changes in 3.2 weren't made deliberately to limit the functionality of block plugins. |
I think I'd want to know what the use-case is for hooking into (This is a common issue we've encountered with plugin categories. They were designed to support loading plugins only when required. Loading them on every request defeats the purpose but we continually find cases where people want to act outside of the category's limitations.) |
According to the forum post, the use-case is to add styling to the block. |
Ah, so to load a CSS stylesheet. That seems sensible. Someone might also want to load a JS file. The problem with the following solution:
Is that it will lead to the block plugins getting loaded twice, which can lead to situations where hooks are registered and fired twice as well. We'll need to also make sure that this "double load" situation doesn't happen on the reader-facing frontend, but also in the appearance settings where blocks are listed. As part of work on #5865, I've separated out the code needed to load backend pages, and asked |
Debugging shows that in this case if accessing front-end plugins are loaded once as TemplateManager is initialized only once. |
Or you mean this call inside the hook: https://github.com/Vitaliy-1/pkp-lib/blob/32621e78650deb20b9ccc698784d6c1911402be8/classes/template/PKPTemplateManager.inc.php#L1013 ? |
I'm talking about |
@NateWr, what about initiating block plugins in the |
I don't want to determine it from the template path. The I think the best approach for now is to determine the best time to load the block plugins before the display hook, load them there, and refactor other places where they are loaded which cause problems. This may be in the An additional check could be added to only do so if the handler is a |
You are right! All plugin categories are loaded twice when using Firefox. Google Chrome caches more data that's why I've missed it. Is it expected that TemplateManager initializes twice on the reader-facing front-end? |
Ah, now I understand, all plugin categories are also loaded on every component request. Sorry, haven't explored this part of the code before. |
Hmm, does anyone knows why plugin categories are loaded several times, e.g., I found that While debugging @NateWr, I see you already asked that question before: #1735. Did you find the reason? |
The first thing to check is that you're only identifying duplicate loads in the same request. Because a single request to the backend will often fire off five more ajax requests to components, the error log can make it seem like plugins are getting loaded several times. But it's actually only being loaded once per request. To test this, you can add a In practice, I found that this accounted for most duplicate load issues. But if you find more, it's a good idea to locate and remove them if possible. This is a challenge with the given plugin setup. We are moving towards eliminating the pluign categories and going all generic. But to do this we also need to find a way to minimize what actually gets loaded when a plugin is loaded (to minimize performance issues). Alec and I have discussed this but haven't prioritized a solution for the moment. |
Closing this as outdated. If you feel this is still important, please consider making a proposal in the feature request category of our community forum. |
Related to: https://forum.pkp.sfu.ca/t/add-a-css-to-block-plugin-in-3-2-0-1/59518/6
It seems impossible to hook in
TemplateManager:: display
with a Block Plugin, e.g., to add styling.Steps to reproduce the behavior:
Originally tested with OJS 3.2.0-1. I've reproduced with 3.2.0-3.
It's possible that other hooks are affected too.
The text was updated successfully, but these errors were encountered: