Plugins' Master stylesheets deleted on core upgrade
#1
For a while now I've noticed that often after upgrading MyBB to the latest version, some of my plugins lose their styling.

After digging around in the code, I think I've identified why, although I haven't done any testing to confirm this.

It looks as though Master stylesheets are unconditionally deleted on line 222 of admin/inc/functions_themes.php, in the function import_theme_xml():

$db->delete_query("themestylesheets", "tid='{$options['tid']}'");

...as called on line 487 of install/upgrade.php, in the function upgradethemes():

import_theme_xml($contents, array("tid" => 1, "no_templates" => 1, "version_compat" => 1));

By "unconditionally" deleted I mean that all Master stylesheets, including those of plugins and not just those of core, are deleted. If the admin hasn't modified any of these stylesheets for any theme such that inheritance is overridden and the theme has its own copy, then the stylesheet is lost.

Assuming that I've diagnosed this issue correctly, what do other plugin developers do to work around it?

To work around it myself, I've started to add (re)creation of (Master) stylesheets in my plugins' _activate() function rather than in their _install() function, so that an admin can simply deactivate and then reactivate the plugins to get styling back after a core upgrade.

Is there a better way?

Is this even intended behaviour, or is it a bug, and if it is a bug, then could the fix be to add a method of marking stylesheets as either belonging to core or a plugin, and for import_theme_xml() to only conditionally delete core stylesheets, and leave plugin stylesheets alone?
Reply


Messages In This Thread
Plugins' Master stylesheets deleted on core upgrade - by Laird - 2020-10-03, 05:59 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)