When the module is enabled, and the cache is cleared, the next page that is loaded does not use the defined Admin theme. It uses the site's default theme instead. Refreshing the page from that point fixes it immediately and the Admin theme is once again visible.

This is an odd bug, and I'm not sure what could be causing it. Perhaps it's a combination of this module and another, but it definitely seems to be caused by the Term Fields module on my site so I'll report it for future reference (turning the module on/off causes it to happen/not).

I'll keep my eyes peeled because I definitely want to use this module on my d6 site.

Comments

b-prod’s picture

Version: 6.x-1.16 » 6.x-1.x-dev
Status: Active » Postponed (maintainer needs more info)

Never heard about that, very surprising.
Term fields module does not interfere with themes and does not implements hook_init(), so your issue seems to be specific to your site.
I keep this issue opened for some time in case of anybody would have some more information.

m.stenta’s picture

Thanks, yea I took a look at the module code and didn't see anything that would suggest that it is directly causing the bug. Very strange indeed, though, because it only happens when I have term_fields enabled. It could be an interaction with another module, perhaps. I'll see if I can isolate what's happening and report back.

m.stenta’s picture

Ok, after a little more digging I traced the bug to line 398 of term_fields.module (in the term_fields_get_fids() funciton):

$result = db_query("SELECT fid FROM {term_fields}");

I noticed that in addition to happening when the cache is cleared, it also happens every time I save a View. I started by commenting out term_fields_views_api() to disable the Views integration, and that solved the problem. So I selectively commented out things in term_fields.views.inc code, saving my View after each test, and wound up with that line.

I searched all the module files for 'term_fields_get_fids(' and found two places that used term_fields_get_fids() without an argument (which is what triggers line 398 to execute): line 537 of term_fields.module in the fid_load() function, and line 8 of views/term_fields.views.inc in the term_field_views_data() function.

It seems that the fid_load() function is not used anywhere else in the module, and term_field_views_data() is executed when Views are loaded from the cache (or rebuilt for the cache), which corresponds to the behaviors I've been experiencing.

I'm not really sure why the query at line 398 of term_fields.module is causing my site to lose the admin theme. Maybe it's an overload of some kind. The site is pretty loaded as it is, so maybe this was just the straw that broke the camel's back, so to speak. term_field_views_data() performs a couple of queries itself (one for each field), in addition to the SELECT that takes place in term_fields_get_fids()... might have pushed it over the edge.

Hmm...

b-prod’s picture

Interesting. Could you try to increase the following settings one after the other:
- memory_limit in php.ini
- max_allowed_packet in my.ini (that will probably change nothing)

At the very end of your admin theme page template, could you print the following value :
print format_size(memory_get_peak_usage());

Not sure this will be really helpful, but it can give some pieces of information.

m.stenta’s picture

My php.ini memory_limit is already set to 256M (testing site), so I don't think increasing it will change anything. I think I would get an error message if the packet size was bigger than allowed.

I added the following to both of my themes (I'm using a custom frontend theme based on Acquia Prosper, and Rubik is my administration theme):

<?php print format_size(memory_get_peak_usage()); ?>

When I refresh an admin page and it loads Rubik properly, the peak usage is around 60M.

When I save a View, and thus end up looking at the admin section in my frontend theme, the peak usage is around 75M.

In either case, it's not maxing out my memory limit. Something is happening, though..

Thanks for the advice, I'll keep digging.

m.stenta’s picture

Another thing worth noting is that my friend and I experienced this same problem on another site we were working on that used Ubercart, but it happened randomly when viewing or saving orders... I don't really remember the specifics, but it's worth mentioning.

This is sounding more and more like a bug that is outside the scope of term_fields, but we might as well keep it here until we figure out for sure what commonality it has with other modules. It could be the same symptom from two different causes, as well, so honing in on the cause in this case is the best bet.

m.stenta’s picture

OK! I narrowed in on a better clue...

Lines 120-122 of term_fields/views/term_fields.views.inc in term_fields_views_data():

      // All fields get this.
      $data['term_fields_term'][$fid]['title'] = t('@title (@fid)', array('@title' => $record->title, '@fid' => $fid));
      $data['term_fields_term'][$fid]['help'] = t('The value of %fid for this particular term.', array('%fid' => $fid));

Line 122 in particular... if I comment that out, then it doesn't happen anymore.

So then I tried changing the %s to @s in that line, and bam! It started working perfectly! ie:

      $data['term_fields_term'][$fid]['help'] = t('The value of @fid for this particular term.', array('@fid' => $fid));

I'm not sure why yet... perhaps hook_views_data() doesn't like HTML in the ['help'] field? Using % puts <em> tags around the text. Using @ does not add any HTML.

But... if I'm the only one that's experiencing this issue, then perhaps it's more specific to the themes that I'm using. I'm not sure how these things interact... but I'm glad to have the issue fixed, even if it means patching term_fields in my installation.

b-prod’s picture

Category: bug » task
Status: Postponed (maintainer needs more info) » Postponed

Thank for your comment, I will have a look on that when possible.
I also think it is probably specific to your installation, but I will dig up a little around that.

b-prod’s picture

Status: Postponed » Closed (works as designed)