plugins->moduleInfo(basename(dirname('../' . __DIR__)), 'version'); $current = dcCore::app()->getVersion(basename(dirname('../' . __DIR__))); if ($current && version_compare($current, '2022.12.10', '<')) { self::preUpgrade20221210(); } } public static function postUpgrade() { } protected static function preUpgrade20221210() { // Rename settings $setting_ids = [ 'zoneclearFeedServer_active' => 'active', 'zoneclearFeedServer_pub_active' => 'pub_active', 'zoneclearFeedServer_post_status_new' => 'psot_new_status', 'zoneclearFeedServer_bhv_pub_upd' => 'bhv_pub_upd', 'zoneclearFeedServer_update_limit' => 'update_limit', 'zoneclearFeedServer_keep_empty_feed' => 'keep_empty_feed', 'zoneclearFeedServer_tag_case' => 'tag_case', 'zoneclearFeedServer_user' => 'user', 'zoneclearFeedServer_post_full_tpl' => 'post_full_tpl', 'zoneclearFeedServer_post_title_redir' => 'post_title_redir', ]; foreach ($setting_ids as $old => $new) { $cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME); $cur->setting_id = $new; $cur->update("WHERE setting_id = '" . $old . "' and setting_ns = 'zoneclearFeedServer' "); } // use json rather than serialise $setting_values = [ 'post_full_tpl' => ['post', 'category', 'tag', 'archive'], 'post_title_redir' => ['feed'] ]; $record = dcCore::app()->con->select( 'SELECT * FROM ' . dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME . ' ' . "WHERE setting_ns = '" . dcCore::app()->con->escape(basename(dirname('../' . __DIR__))) . "' " ); while($record->fetch()) { foreach($setting_values as $key => $default) { try { $value = @unserialize($record->__get($key)); } catch(Exception) { $value = $default; } $cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME); $cur->setting_value = json_encode(!is_array($value) ? $default : $value); $cur->update( "WHERE setting_id = '" . $key . "' and setting_ns = '" . $record->setting_ns . "' " . 'AND blog_id ' . (null === $record->blog_id ? 'IS NULL ' : ("= '" . dcCore::app()->con->escape($record->blog_id) . "' ")) ); } } } }