using this modul I got 404 error on calls to mysite.com/favicon.ico

I found that the used theme_get_setting('favicon_path') returns public://favicon.ico which results in an empty realpath($favicon).

In _favicon_get_favicon_file() I have changed

  $favicon = theme_get_setting('favicon_path');

to

  $favicon = theme_get_setting('favicon_path');
  $files_dir = variable_get('file_public_path', conf_path() . '/files');
  $favicon = str_replace('public:/',$files_dir,$favicon);

in order to get the favicon correctly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

johnennew’s picture

Wording on the Drupal core settings page for the shortcut icon is terrible.

I think it means you to enter a file path which is relative to the site root, not the public files directory.

kingandy’s picture

FileSize
382 bytes

Maybe this is one of the rare cases when drupal_realpath() is appropriate?

... you know that the stream wrapper in the URI uses the local file system, and you need to pass an absolute path to a function that is incompatible with stream URIs.

I've tested on my local system (which was likewise using a 'public://' URI), and it seems to work fine. It also works with the default 'misc/favicon.ico' path, so I guess it would work with theme-default paths, but I haven't tested that.

Find attached a patch, though it's really a very simple change...

kingandy’s picture

Status: Active » Needs review
cmseasy’s picture

#2 worked for me in a multisite drupal environment. Thanks!

oushen’s picture

Patch for fix 404 error

Status: Needs review » Needs work

The last submitted patch, 5: favicon-404-not-found-fix-2217827-5-D7.patch, failed testing.

oushen’s picture

Fixed patch file after test failed

oushen’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 7: favicon-404-not-found-fix-2217827-7-D7.patch, failed testing.

oushen’s picture

Status: Needs work » Needs review
Dave Reid’s picture

Status: Needs review » Fixed

This should be resolved with the most recent release, 7.x-2.0. It is safe for everyone to upgrade to since there's no data that actually needs upgrading.

Status: Fixed » Closed (fixed)

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