Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
PHP define's do not work they way they do in C++. They are not part of a pre-processor, but instead actually evaluate like a function. Thus, the way the code is structured drupal_get_path() is running on every single page. It's better to put this "constant" in a function, and return it's value.
Also the full path to the include is not necessary. I frequently get PHP errors caused by this when using drush. I'm not sure exactly why this happens. But I know the solution is to not use the full path.
PHP Fatal error: Cannot redeclare template_preprocess_views_view_views_rss() (previously declared in /users/me/Sites/mysite/sites/all/modules/contrib/views_rss/theme/theme.inc:11) in /Users/me/Sites/mysite/sites/all/modules/contrib/views_rss/theme/theme.inc on line 167
Comment | File | Size | Author |
---|---|---|---|
#4 | views_rss-path_fix-1927980-4.patch | 498 bytes | sagannotcarl |
#1 | views_rss-path_fix-1927980-1.patch | 2.44 KB | Snipon |
views_rss.patch | 3.79 KB | douggreen | |
Comments
Comment #1
Snipon CreditAttribution: Snipon commentedThis basically the same patch for the 7.x-2.x-dev branch since the codebase differs.
I also removed absolute paths since they are not really needed.
Comment #2
maciej.zgadzaj CreditAttribution: maciej.zgadzaj commentedReplacing previous define of VIEWS_RSS_PATH with call to module_load_include() will not change anything in terms of efficiency, as module_load_include() uses drupal_get_path() too, so still it will be run on every page.
Also, perhaps the full path to the include was not necessary, but it is necessary in all other cases, as the module doesn't work anymore after removing it.
Comment #3
maciej.zgadzaj CreditAttribution: maciej.zgadzaj commentedClosing after long time of no activity.
Comment #4
sagannotcarl CreditAttribution: sagannotcarl as a volunteer commentedI am experiencing the same problem as the original issue. The existing patch here broke all my 'RSS Feed - Fields' views (missing handler).
Here is another patch that addresses the immediate problem of the php error but without the other items that the maintainer has issues with.