Bug #452

Upgraded forums issue with themestylesheets cachefile column

Added by Jesse Labrocca 7 months ago. Updated 4 months ago.

Status:Closed Start:09/02/2009
Priority:Normal Due date:
Assigned to:Ryan Gordon % Done:

100%

Category:Other
Target version:1.4.10
Reproducibility:Rarely Browser:
Reported In MyBB Version:1.4.8 Database Type:
PHP Version: Database Version:

Description

I hope I can explain this well. Today I noticed that my HF site css files were using css.php? instead of the cache/themes folder. I wasn't sure why. Upon lengthy investigation (hours). I came to realize the problem. It appears that during an upgrade probably from 1.2x -> 1.4x the column "cachefile" in table themestylesheets showed the cachefile as css.php?stylesheet=XX (xx being style number of course).

So obviously that's not a cached file.

Inside the admin/inc/functions_themes.php the function update_theme_stylesheet_list() will not properly rebuild the cachefile column because it can't find it. This code prevents it.

@ foreach($parent_list as $theme_id) {
if(file_exists(MYBB_ROOT."cache/themes/theme{$theme_id}/{$stylesheet['cachefile']}") && filemtime(MYBB_ROOT."cache/themes/theme{$theme_id}/{$stylesheet['cachefile']}") >= $stylesheet['lastmodified']) {
$css_url = "cache/themes/theme{$theme_id}/{$stylesheet['cachefile']}";
break;
}
}@

As you can see /cache/themes/themeX/css.php?stylesheet=XX will never be found. I had to manually change the columns in phpmyadmin to regular titles like usercp.css and then resaving the theme css saved them all correctly and my forum now displays the cached file. I viewed a few other sites that I know were 1.2x upgrades and they seem to have the same problem. I do not have this problem on any of my 1.4x fresh installs. This was an issue at both HF and Mybb Central.

btw..this also might be why star_rating.css wasn't built properly early in the 1.4x branch and so many had a problem. Few upgrade now but many may not be aware their site is displaying their CSS dynamically.

I hope I was clear.

Associated revisions

Revision 4532
Added by Ryan Gordon 4 months ago

Fixes Upgraded forums issue with themestylesheets cachefile column (fixes:452)

Revision 4553
Added by Ryan Gordon 4 months ago

Fixes Upgraded forums issue with themestylesheets cachefile column (fixes:452)

History

Updated by Ryan Gordon 7 months ago

Interesting. I will look into this further.

Updated by Matt Rogowski 7 months ago

Well, that explains why I could never find the setting to make it use css.php, never knew how people did it...

Updated by Jesse Labrocca 7 months ago

So did you make the changes I suggested in phpmyadmin and then save the theme css again? I want to make sure that works for you as it did for me. Also make sure you actually see the css file in the themes directory.

Updated by Tom Moore 6 months ago

I've been having a look at this too. I've noticed on Resources and a few other forums it uses css.php. I haven't upgraded these from 1.2, these have been 1.4 installs.

I think it revolves around a plugin of some sort as well as being an upgrade issue. I've noticed that with MyTracker and MyNetwork, the theme changes aren't cached properly when they're installed. This causes MyBB to revert to css.php.

To fix Resources, I didn't manually change the database values - I added a little bit of code onto the end of global.php that included the functions_themes.php file from the admin directory and ran the cache_stylesheet, resync_stylesheet and update_theme_stylesheet_list functions once (from a loop of the stylesheets from the database). This successfully cached the files onto the server and updated the themes with the right stylesheets. From what I can tell, it hasn't caused any adverse affects.

An idea could be to provide a function in the ACP that resync's them.

Updated by Ryan Gordon 4 months ago

  • Category set to Other
  • Status changed from New to Assigned
  • Assigned to set to Ryan Gordon
  • Target version set to 1.4.10

Updated by Ryan Gordon 4 months ago

  • Status changed from Assigned to Rejected

So basically, this doesn't look like an actual bug. The upgrade process doesn't care whether or not it is flat-file or dynamic, so long as it calls a working link. The cache_stylesheet (with resync_stylesheet) attempts to make it flat-file then it runs through the update_theme_stylesheet_list function. The cache_stylesheet function is only called when you try to edit/update that particular theme or visit a page within the themes module. Given you have proper permissions, all you have to do is go through and update the themes, and they will become a flat-file.

Updated by Ryan Gordon 4 months ago

  • Status changed from Rejected to Assigned

Actually nevermind, I see what you are talking about now. It will make it flat-file, but when it goes to the update_theme_stylesheet_list function to update the stylesheet cache, the row in the stylesheets database will still point towards the dynamic file. Right after we call the cache_stylesheet function with success, then we should update the database column with the flat file filename. We're also using cachefile when we should be using 'name' since that will always the the "abc.css" format. That way we can check if someone uploads a file there even if MyBB is currently using the dynamic css.php.

Labrocca, Please apply the changes from my commit to your forum and if possible check them to work. I'm only committing them to the trunk until I receive an all clear from you and SQA.

Updated by Ryan Gordon 4 months ago

  • Status changed from Assigned to Resolved
  • % Done changed from 0 to 100

Applied in changeset r4532.

Updated by Jesse Labrocca 4 months ago

Thank you sir for looking into this and resolving.

Updated by Michael Schlechtinger 4 months ago

  • Status changed from Resolved to Feedback

Seems to be working fine. You can add this fix to the branch.

Updated by Ryan Gordon 4 months ago

  • Status changed from Feedback to Resolved

Applied in changeset r4553.

Updated by Michael Schlechtinger 4 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF