1.4.6.beta issue with cacheManager?

vincent3569 Member, Translator
I don't know if it's realy an issue or not, so I post on the forum before create a ticket.

in my themes, I use extensionEnabled('plugin_name') rather class_exists('class_name') or function_exists('function_name').

with that, I have an issue with cacheManager after a new install.

in my themeoption.php file, I have these lines to support cacheManager plugin :

`
if (extensionEnabled('cacheManager')) {
$me = basename(dirname(__FILE__));
cacheManager::deleteThemeCacheSizes($me);
cacheManager::addThemeCacheSize($me, getThemeOption('thumb_size'), NULL, NULL, getThemeOption('thumb_crop_width'), getThemeOption('thumb_crop_height'), NULL, NULL, true);
if (getOption('use_galleriffic')) {
cacheManager::addThemeCacheSize($me, 85, NULL, NULL, 85, 85, NULL, NULL, true);
cacheManager::addThemeCacheSize($me, 525, NULL, NULL, NULL, NULL, NULL, NULL, false);
}
cacheManager::addThemeCacheSize($me, getThemeOption('image_size'), NULL, NULL, NULL, NULL, NULL, NULL, false);
}
`
after a new install, when I go first to options/theme, I have this fatal error :

`Fatal error: Class 'cacheManager' not found in /home2/avbo7291/public_html/zenphoto_test/themes/zpArdoise/themeoptions.php on line 57`
(line 57 is the line 3 of the code above)

If I go firt on plugins tabs and apply without any other actinos, I have no issue.

so, despite cacheManager plugin is loaded, cacheManager class is not loaded.
is there a way to avoid this behaviour?
is it an issue of cacheManager or extensionEnabled?

Comments

  • Please change your theme to use the `class_exists()` function as used in the standard themes. Understand that there is a difference between a plugin being enabled and being loaded.

    For instance, the cacheManager plugin may be enabled but will never get loaded on the front end.
  • vincent3569 Member, Translator
    Could you explain how and when plugin classes are loaded?
    In my example above, if I use `class_exists()`, the test will be KO and cache values will not be generated.

    Don't you think that all classes of enabled admin plugins should be loaded when we are in admin?
  • If the problem was corrected by re-saving the plugins tab then the cause was an improper value stored in the option. At any case, the answer of how your theme should be coded does not change.
  • vincent3569 Member, Translator
    please, is there a coding rule which explain how and when I have to use `extensionEnabled('plugin_name')` or `class_exists('class_name')` or `function_exists('function_name')` in case of theme plugin or admin plugin?

    it is not clear for me.
  • acrylian Administrator, Developer
    I cannot answer for `extensionEnabled()` specifically. But the point when classes are loaded may be later than the point the plugin itself is or vice versa.

    For the other two it depends what you use. Some plugins just consists of procedural functions you should check first. Others may be based on a class. If you use a method of their class somewhere you have to check if the class exists as there is no function to check.

    So the most secure is to check for function or class actually.
  • vincent3569 Member, Translator
    In my themes, the only issue is with cacheManager and I don't have any trouble when I use `extensionEnabled('plugin_name')` with all suported plugin (colorbox, comment_form, contact_form, dynamic-locale, favoritesHandler, federated_logon, flag_thumbnail, GoogleMap, image_album_statistics, print_album_menu, rating, register_user, RSS, slideshow, user_login-out, zenpage).

    So, I wish to understand:
    -how and when plugin classes are loaded, for admin and theme plugins?
    -why classes of enabled admin plugins are not loaded when we are in admin tabs?
  • `extensionEnabled()` means only that the extension might be loaded. Not when and where it is loaded.

    class_exists() means that, well, the class does exist, whether or not `extensionEnabled()` is true. Extensions may be loaded even if not enabled. For instance the colorbox plugin may be loaded by the user_login-out plugin even if not enabled.

    So if you want to use functionality of a plugin you check if the functionality exists (`class_exists()` or `function_exists(`)) If you want to know if the use has selected the plugin you use `extensionEnabled()`.

    You should be using `class_exists()` for the cacheManager settings because that is the convention for themes. These settings should be made even if the cacheManager plugin is not enabled, that is the convention as demonstrated by the Zenphoto provided themes.
Sign In or Register to comment.