Title: Fatal Error mit Litespeed Cache
Last modified: May 6, 2025

---

# Fatal Error mit Litespeed Cache

 *  [networka](https://wordpress.org/support/users/networka/)
 * (@networka)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/fatal-error-mit-litespeed-cache/)
 * Moin.
 * Fatal error:
 * `PHP Fatal error: Cannot redeclare update() (previously declared in /wp-content/
   plugins/dr-flex/dr-flex.php:641) in /wp-content/plugins/dr-flex/dr-flex.php on
   line 641\n`
 * Ich habe den Plugin Code folgendermaßen geändert:
 * update() -> drflex_inner_update()
 * Um den Fehler zu beheben, darf dazu drflex_inner_update() nur einmal definiert
   sein. Unabhängig davon, wie oft drflex_update_resources() aufgerufen wird.Somit
   habe ich drflex_inner_update() mit einer Bedingung versehen, die prüft, ob die
   Funktion bereits existiert.
 *     ```wp-block-code
       function drflex_update_resources()
       {
           if (drflex_plugin_database_needs_update()) {
               drflex_debug("Database needs update. Updating...");
               if (drflex_cache_upgrade()) {
                   drflex_debug("Update successful.");
               } else {
                   drflex_error("Error occurred updating database");
               }
           }
   
           // Bedingte Definition der inneren Funktion
           if (!function_exists('drflex_inner_update')) {
               function drflex_inner_update()
               {
                   // Hier steht der ursprüngliche Code von drflex_inner_update()
                   function has_hash($im_cache, $hash)
                   {
                       foreach ($im_cache as $item) {
                           if ($hash === $item['resource_hash_md5']) {
                               return true;
                           }
                       }
                       return false;
                   }
   
                   function get_data($im_cache, $uri)
                   {
                       foreach ($im_cache as $item) {
                           if ($uri === $item['resource_uri']) {
                               return $item['resource_data'];
                           }
                       }
                       return array();
                   }
   
                   function clean_up_deprecated($im_cache, $config_files)
                   {
                       $items_to_remove = array();
                       foreach ($im_cache as $cached_item) {
                           if (
                               $cached_item['resource_uri'] !== "generatedEmbedScript" &&
                               $cached_item['resource_uri'] !== "buttonConfigurations" &&
                               $cached_item['permanent'] != true
                           ) {
                               $items_to_remove[] = $cached_item;
                               $position = count($items_to_remove) - 1;
                               foreach ($config_files as $config_item) {
                                   if ($cached_item['resource_uri'] === $config_item['drflex_url']) {
                                       array_splice($items_to_remove, $position, 1);
                                   }
                               }
                           }
                       }
                       $delete_ids = array_map(function ($a) {
                           return $a['id'];
                       }, $items_to_remove);
                       drflex_cache_delete_resources($delete_ids);
                   }
   
                   $cache = drflex_cache_get_cache();
                   $im_cache = array();
                   foreach ($cache as $item) {
                       $cachable_item = get_object_vars($item);
                       $im_cache[] = $cachable_item;
                   }
   
                   $drflex_config_file_url = $GLOBALS['drflex_host'] . $GLOBALS['drflex_cofig_relpath'];
                   $response = drflex_utils_fetch_from_url($drflex_config_file_url);
   
                   if ($response != false && count($response) > 1 && $response['status'] == 200) {
                       $configObject = json_decode($response['content']);
                       $config = get_object_vars($configObject);
   
                       // Fetch embed script
                       $embed_script_data = $config['generated_embed_script'];
                       $es_vars = get_object_vars($embed_script_data);
   
                       if (!has_hash($im_cache, $es_vars['md5_hash'])) {
                           if (!drflex_cache_insert_or_update_resource('generatedEmbedScript', drflex_utils_json_unescape($es_vars['data']), null, null)) {
                               drflex_error("An error occurred while writing the generated embed script to the database.");
                           }
                       }
   
                       $config_files = array();
                       // Fetch files
                       foreach ($config['files'] as $fileObject) {
                           $file = get_object_vars($fileObject);
                           $config_files[] = $file;
                           $resource_uri = $file['drflex_url'];
                           if (!has_hash($im_cache, $file['md5_hash'])) {
                               if ($file['md5_hash'] !== null) {
                                   drflex_fetch_and_insert_latest_resource_version($resource_uri);
                               } else {
                                   drflex_cache_insert_or_update_resource($resource_uri, null, null, null, true);
                               }
                           }
                       }
   
                       // DB cleanup
                       clean_up_deprecated($im_cache, $config_files);
   
                       // Fetch configs
                       if (array_key_exists('button_configurations', $config)) {
                           $btn_cnf = json_encode($config['button_configurations']);
                           drflex_cache_insert_or_update_resource('buttonConfigurations', $btn_cnf, null, null);
                       } else {
                           drflex_error("Button configuration missing in config json.");
                       }
   
                       // Update fetch timestamp
                       drflex_cache_insert_config_item("last_update_timestamp", null);
                   } else {
                       if ($response['status'] === 401){
                           drflex_cache_clear_cache();
                           drflex_error($response['content']);
                       } else {
                           drflex_error("Error trying to fetch config.json.");
                       }
                   }
               }
           }
   
           $last_update = drflex_cache_get_config_item("last_update_timestamp");
   
           if (count($last_update) > 0) {
               $last_update = get_object_vars($last_update[0]);
               if (array_key_exists("created_at", $last_update)) {
                   $created_date_time = date_create_from_format("Y-m-d H:i:s", $last_update["created_at"]);
                   $last_timestamp = $created_date_time->getTimestamp();
                   $drflex_update_interval_secs = $GLOBALS['drflex_update_interval_secs'];
                   if (time() - $drflex_update_interval_secs > $last_timestamp) {
                       drflex_inner_update();
                   }
               } else {
                   drflex_inner_update();
               }
           } else {
               drflex_inner_update();
           }
       }
   
       add_action('wp', 'drflex_update_resources');
       ```
   

The topic ‘Fatal Error mit Litespeed Cache’ is closed to new replies.

 * ![](https://ps.w.org/dr-flex/assets/icon.svg?rev=2640173)
 * [Dr. Flex](https://wordpress.org/plugins/dr-flex/)
 * [Support Threads](https://wordpress.org/support/plugin/dr-flex/)
 * [Active Topics](https://wordpress.org/support/plugin/dr-flex/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/dr-flex/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/dr-flex/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [networka](https://wordpress.org/support/users/networka/)
 * Last activity: [1 year, 1 month ago](https://wordpress.org/support/topic/fatal-error-mit-litespeed-cache/)
 * Status: not resolved