DB lookup was failing to retrieve correct theme info

dman - November 10, 2008 - 13:14
Project:Color.module: Next generation
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

The first time I tried this, it just didn't work (no color options at all on /admin/build/themes/settings/friendselectric & others) so I thought it was unstable.
So I went back to colorizing with core color.module for an hour or two before deciding that I really did need more gradients and more color names.
So I tried again. And it DID work.
And was going well.
Then suddenly (after a themes cache rebuild or something) it inexplicably disappeared again... even on the distro themes.
:-/

Debugging led me to:

<?php
function color_compatible($theme_name) {
  static
$static;

 
$theme_info = unserialize(db_result(db_query("SELECT info FROM {system} WHERE type = '%s'", 'theme')));
 
  if (
$theme_info['color'] == TRUE) {
   
$static[$theme_name] = TRUE;
  }
  else {
   
$static[$theme_name] = FALSE;
  }

  return
$static[$theme_name];
}


?>

That query does NOT retrieve the requested theme info, just any random theme info! Not all of which are color-enabled :-}

Here's a fix. Including a PHP-STRICT-NOTICE avoidance also.

<?php
function color_compatible($theme_name) {
  static
$static;

 
$theme_info = unserialize(db_result(db_query("SELECT info FROM {system} WHERE type = '%s' AND name = '%s' ", 'theme', $theme_name)));
  if (!empty(
$theme_info['color'])) {
   
$static[$theme_name] = TRUE;
  }
  else {
   
$static[$theme_name] = FALSE;
  }

  return
$static[$theme_name];
}
?>

Other than that, so far so good... I'm getting results on a zen-based subtheme.

AttachmentSize
color.misc-20081010.patch835 bytes

#1

skiquel - November 10, 2008 - 23:42
Status:active» fixed

Committed

#2

System Message - November 24, 2008 - 23:52
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.