Closed (fixed)
Project:
Libraries API
Version:
7.x-2.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 Oct 2016 at 16:43 UTC
Updated:
9 Aug 2021 at 13:58 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
plachComment #3
plachComment #4
plachThis is a custom theme I used to replicate the issue locally.
Comment #5
plachComment #6
tstoecklerWow, nice catch!
I think we should build up a properly sorted list of themes outside of the foreach () in libraries_info(). That would (hopefully) make the code a bit more readable, IMO.
Comment #7
plachThis implements the approach suggested in #6.
Comment #8
tstoecklerThanks again. I moved a bit of code around to make it PHP 5.2 compatible, but (hopefully) kept the logic the same. One question: you used
strcmp()if neither theme is a base theme of the other. Is there any reason for that? I think in that case we should just punt and return 0. Attached patch does that.Comment #9
tstoecklerSuperfluous semi-colon. Can be fixed on commit.
Comment #10
manav commentedComment #11
manav commentedComment #12
manav commentedComment #13
tstoecklerThanks for the patch @Manav, did the patch work for you? Did you try it out?
Comment #14
manav commentedHi @Tobias
Sorry for late comment. Yes i have tested this patch on my local and apply the changes commented in #9. But after followed above steps (mentioned in Issue description) i got the following errors.
Attching screen-shot for the same.
Thanks
Manav
Comment #15
manav commentedHi @Tobias
Please ignore above comment. #14
Sorry its my mistake. I have tested it again and find that everything is working fine without any error.
Thanks
Manav
Comment #16
tstoecklerOK, awesome. Counting that as an RTBC ;-)
Thank you!
Comment #17
manav commentedComment #18
plachSorry, lost track of this. I tested #11 and it still seems to fix the issue.
RTBC +1
Comment #19
proteo commentedHi, I'm facing this very same issue with some admin screens (/admin/reports/status and /admin/reports/libraries). From what I gather the patch should fix the problem, yet it isn't. I have three themes enabled; in
libraries_get_enabled_themes(), the $themes array come up fromlist_themes()in this order:a21
adminimal
bootstrap
a21 (my custom theme) uses bootstrap as base theme. As such, I expected that after doing:
the
$themesarray should be sorted like this or something similar, putting boostrap before a21:adminimal
bootstrap
a21
However, the
$themesarray is returned in the same, unchanged order, which of course causes the WSOD because the function tries to load a2's1template.phpfile beforebootstrap_include()is declared.Not sure why the
libraries_compare_themes()function is failing to perform properly, but I did some debugging and strangely it looks like the function is evaluating only consecutive pairs: first a21/adminimal and then adminimal/bootstrap, but it never gets to evaluate the a21/bootstrap pair.Comment #20
proteo commentedOK, after taking some time to understand how
uasort()works I realized that it will never be a good fit for the task, and a more robust approach is required. My case is just the tip of the iceberg, other cases may arise with more complex setups (for example, when a theme is both parent and subtheme at the same time). I'm attaching a patch that uses a recursive function to sort the array in such a way that subthemes always will be located after its base theme, no matter how complex or deep is the hierarchy.Giving the fact that this bug breaks a very important part of the site (the Status Report page) I'm changing this to Major.
Comment #21
proteo commentedI've been using this patch for a while in several production sites, and it seems to work fine. After upgrading to the 2.4 release I reminded this still needs to be commited.
Comment #23
joseph.olstadPushed and creditted, thank you everyone!
Comment #25
joseph.olstadignore the 7.x-3.x branch, use 7.x-2.x
Comment #27
steven jones commentedThanks everyone, this change almost worked! There's a little bug that's resolved in #3178266: libraries_sort_themes will not allow libraries_load to work if the custom theme's base theme is not enabled.