For some reason I suddenly have two favicons in the upper left corner. The first links to /node/ without any dropdown and if I click on it I come to the Drupal welcome page... The next one has the usual dropdown with cron and the rest and links to node/1. My defaul frontpage is set to be node/1....

Is this a bug? How do I remove the additional icon?

Thanks

Comments

cdale’s picture

I too experienced this exact same problem.

It seems that if you change what site_frontpage is, then the previous site_frontpage value is not removed. If you were to change your frontpage to be node/2 after setting it to be node/1, you'll end up with a third icon up there.

I think that a patch for this should use form_alter on the system_site_information_settings form to add an extra submit handler, which would then check if the frontpage has been changed, if it has, delete the old value, and flag the admin_menu for a rebuild.

If I get a chance, I might write a patch for this a bit later today. Assuming no one else beats me too it. :)

cdale’s picture

I forgot to mention, to remove the extra value that you don't want, I believe something like this might work:

WARNING: UNTESTED CODE, USE AT YOUR OWN PERIL!

db_query('DELETE FROM {menu_links} WHERE module = 'admin_menu' AND menu_name = 'admin_menu' AND link_path = 'node');

cdale’s picture

Status: Active » Needs review
StatusFileSize
new1.59 KB

Ok. I think I've solved the issue. At least for myself this works. I've attached a patch against the latest dev version. (I think :)) I've included the code here just in case that doesn't quite work.

Just paste this at the end of admin_menu.module.

/**
 * Implementation of hook_form_-form-id_alter() for system_site_information_settings.
 */
function admin_menu_form_system_site_information_settings_alter(&$form, $form_state) {
  $form['#submit'][] = 'admin_menu_system_site_information_settings_submit';
}

/**
 * Extra submit handler for system_site_information_settings_submit
 */
function admin_menu_system_site_information_settings_submit($form, &$form_state) {
  // Only need to take action if the site_frontpage has changed.
  if ($form['site_frontpage']['#default_value'] != $form_state['values']['site_frontpage']) {
    // Flag the admin menu to be rebuilt.
    variable_set('admin_menu_rebuild_links', TRUE);

    // Delete the old menu item from the database. Is there a better way to do this? Does this still work woth pathauto paths?
    db_query('DELETE FROM {menu_links} WHERE `module` = "admin_menu" AND `menu_name` = "admin_menu" AND `link_path` = "%s"', $form['site_frontpage']['#default_value']);
  }
}
cdale’s picture

StatusFileSize
new1.7 KB

Here is a new patch that will work when path aliases are used. Again, I've attached the patch, and added the code here.


/**
 * Implementation of hook_form_-form-id_alter() for system_site_information_settings.
 */
function admin_menu_form_system_site_information_settings_alter(&$form, $form_state) {
  $form['#submit'][] = 'admin_menu_system_site_information_settings_submit';
}

/**
 * Extra submit handler for system_site_information_settings_submit
 */
function admin_menu_system_site_information_settings_submit($form, &$form_state) {
  // Get the correct old path.
  $old_path = drupal_lookup_path('source', $form['site_frontpage']['#default_value']);
  if ($old_path === FALSE) {
    $old_path = $form['site_frontpage']['#default_value'];
  }

  // Only need to take action if the site_frontpage has changed.
  if ($form['site_frontpage']['#default_value'] != $form_state['values']['site_frontpage']) {
    // Flag the admin menu to be rebuilt.
    variable_set('admin_menu_rebuild_links', TRUE);

    // Delete the old menu item from the database. Is there a better way to do this?
    db_query('DELETE FROM {menu_links} WHERE `module` = "admin_menu" AND `menu_name` = "admin_menu" AND `link_path` = "%s"', $old_path);
  }
}

NeoID’s picture

After having deactivated and completely removed the module from the DB I added it once again. Now everything seems to work.

todd nienkerk’s picture

Subscribed. I've witnessed this problem on a few other sites as well. Changing the site's frontpage creates a new icon/favicon in the upper left; the old icon still links to the old frontpage. A new icon is added each time the frontpage is changed -- one of my sites has three! :)

Excellent module, by the way. Incredibly useful and easy to use.

sun’s picture

Just to let all of you know that this issue is already on my list. However, I think the overall issue has a greater extend, because all of this is technically also related to #280869: Displays lots of items duplicated, flattened on drupal.hu.

pwolanin’s picture

Status: Needs review » Fixed

I think this was resolved by: #295476: admin_menu conflicts with pathauto and in the 6.x-1.1 release

xcorex’s picture

Thank you.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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