1

I have installed an ecommerce website with Commerce Kickstart, not in demo mode. Everything was OK and I began to add products and then my problem started; when I click on 'products category' I receive this error message:

Fatal error: Cannot redeclare commerce_kickstart_preprocess_html() (previously declared in /homepages/44/d576739206/htdocs/profiles/commerce_kickstart/themes/commerce_kickstart_theme/template.php:41) in /homepages/44/d576739206/htdocs/profiles/commerce_kickstart/themes/commerce_kickstart_theme/template.php on line 41

This is what that line 41 (as in the error message) looks like.

function commerce_kickstart_preprocess_html(&$variables) {
  drupal_add_css('http://fonts.googleapis.com/css?family=Lobster+Two:400,700', array('type' => 'external'));
}    

What could the problem be? How can I solve it?

Update (as in one of the comments): I tried to change as you said it and I have this message:

Fatal error: Cannot redeclare commerce_kickstart_theme_preprocess_html() (previously declared in /homepages/..../htdocs/profiles/commerce_kickstart/themes/commerce_kickstart_the‌​me/template.php:9) in /homepages/..../htdocs/profiles/commerce_kickstart/themes/commerce_kickstart_the‌​me/template.php on line 41 code

Update 2 : So if I use another theme, the problem is solved. And there are 2 (minor) differences in the new error message : Now it is in that line "9" (no longer "41") :

function commerce_kickstart_theme_preprocess_html(&$variables) { // Add conditional stylesheets for IE drupal_add_css(path_to_theme() . '/css/commerce-kickstart-theme-ie-lte-8.css', array('group' => CSS_THEME, 'weight' => 23, 'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE), 'preprocess' => FALSE)); drupal_add_css(path_to_theme() . '/css/commerce-kickstart-theme-ie-lte-7.css', array('group' => CSS_THEME, 'weight' => 24, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));

Update 3 : Here is template.php :

<?php
/**
 * Preprocess variables for html.tpl.php
 *
 * @see system_elements()
 * @see html.tpl.php
 */
function commerce_kickstart_theme_preprocess_html(&$variables) {
  // Add conditional stylesheets for IE
  drupal_add_css(path_to_theme() . '/css/commerce-kickstart-theme-ie-lte-8.css', array('group' => CSS_THEME, 'weight' => 23, 'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE), 'preprocess' => FALSE));
  drupal_add_css(path_to_theme() . '/css/commerce-kickstart-theme-ie-lte-7.css', array('group' => CSS_THEME, 'weight' => 24, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));

  // Add external libraries.
  drupal_add_library('commerce_kickstart_theme', 'selectnav');
}

/**
 * Implements hook_library().
 */
function commerce_kickstart_theme_library() {
  $libraries['selectnav'] = array(
    'title' => 'Selectnav',
    'version' => '',
    'js' => array(
      libraries_get_path('selectnav.js') . '/selectnav.min.js' => array(),
    ),
  );
  return $libraries;
}

/**
 * Override the submitted variable.
 */
function commerce_kickstart_theme_preprocess_node(&$variables) {
  $variables['submitted'] = $variables['date'] . ' - ' . $variables['name'];
  if ($variables['type'] == 'blog_post') {
    $variables['submitted'] = t('By') . ' ' . $variables['name'] . ', ' . $variables['date'];
  }

function commerce_kickstart_theme_preprocess_html(&$variables) {
drupal_add_css('http://fonts.googleapis.com/css?family=Lobster+Two:400,700', array('type' => 'external'));
 }
}
1
  • Please try to further enhance your question (by re-editing it). And include things you tried (and probably didn't help yet), or any kind of docu, links etc you verified already. The more you add such kinds of extra info, the more you'll give other people inspiration for trying to answer your question ... Try it! Commented Jun 18, 2015 at 9:21

2 Answers 2

1

Because the two file paths are the same file, it suggests a possible problem with your op-code caching.

Check if you have any PHP op-code cache enabled; you should only have one op-code cache utility and may need to disable one.

You may also need to tweak your APC settings (if enabled).

apc.include_once_override = 0

Check also https://stackoverflow.com/questions/4575341/php-with-apc-fatal-errors-cannot-redeclare-class.

1
  • Oh my god ! I don't even know what is "op-code caching". Where can I find that ? And I don't even know what is APC settings... I'm not a newbie but I'm totally lost ! Commented Jun 17, 2015 at 12:15
0

This problem might be a variation of what is described in Fatal error: Cannot redeclare bartik_preprocess_html().

Here is something that may help you resolve your problem (inspired by some of the things I read in that link): edit the "template.php" in the theme you're using, within line 41 replace the function commerce_kickstart_preprocess_html with something like function mytheme_preprocess_html. Make sure that the 'mytheme' in it is identical to the folder name of your theme. Make sure to refresh the cache (!!!) and then try again to see what happens. If it solves your problem, then it's probably because sub-theme functions should start with the name of the sub-theme (not the parent theme).

So consider reviewing the content of that link, it might give you some ideas to either find a work around, or to refine your question (by editing it), and add some more details like:

  • What is the theme you're using (and what is the folder name of it)?
  • What happens if you (temporary) change to another theme?

While trying to better document your question (add detials), you might even find the actual reason for your problem, and maybe even a solution (which we would then want to learn about also!).

Note: a completely different approach is to review the content of Fatal error: Cannot redeclare MYTHEME_preprocess_page() ...

4
  • I tried to change as you said it and I have this message : code Fatal error: Cannot redeclare commerce_kickstart_theme_preprocess_html() (previously declared in /homepages/..../htdocs/profiles/commerce_kickstart/themes/commerce_kickstart_theme/template.php:9) in /homepages/..../htdocs/profiles/commerce_kickstart/themes/commerce_kickstart_theme/template.php on line 41 code Commented Jun 18, 2015 at 19:08
  • And there is no pb with another theme... Commented Jun 18, 2015 at 19:20
  • Please EDIT your question each time, as I suggested before also. Refer to my edit of your question I just did. That makes it easier to discuss it, at least for me. Good news, 2 times: (a) if you use another theme, the problem is solved, right? That somehow confirms what I wrote in my answer already, no? and (b) Did you note the 2 (minor) differences in the new error message? There is progress there also: the first problem is resolved, no you have a new but similar one. Now it is in that line "9" (no longer "41"), in that function with the extra "_theme" in it. Can you try a similar edit there? Commented Jun 18, 2015 at 19:27
  • I had just added the template.php, perhaps, someone could find where is the trouble... Thanxs ! Commented Jun 24, 2015 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.