use json rather than serialise for settings
This commit is contained in:
parent
16682dc400
commit
f7ce7fae0b
@ -68,8 +68,8 @@ try {
|
||||
$s->put('keep_empty_feed', false, 'boolean', 'Keep active empty feeds', false, true);
|
||||
$s->put('tag_case', 0, 'integer', 'How to transform imported tags', false, true);
|
||||
$s->put('user', '', 'string', 'User id that has right on post', false, true);
|
||||
$s->put('post_full_tpl', serialize(['post', 'category', 'tag', 'archive']), 'string', 'List of templates types for full feed', false, true);
|
||||
$s->put('post_title_redir', serialize(['feed']), 'string', 'List of templates types for redirection to original post', false, true);
|
||||
$s->put('post_full_tpl', json_encode(['post', 'category', 'tag', 'archive']), 'string', 'List of templates types for full feed', false, true);
|
||||
$s->put('post_title_redir', json_encode(['feed']), 'string', 'List of templates types for redirection to original post', false, true);
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
|
@ -106,7 +106,7 @@ class zcfsRsExtPosts extends rsExtPost
|
||||
public static function getURL(dcRecord $rs): string
|
||||
{
|
||||
$url = $rs->zcFeed('url');
|
||||
$types = @unserialize(dcCore::app()->blog->settings->__get(basename(dirname('../' . __DIR__)))->post_title_redir);
|
||||
$types = json_decode(dcCore::app()->blog->settings->__get(basename(dirname('../' . __DIR__)))->post_title_redir);
|
||||
$full = is_array($types) && in_array(dcCore::app()->url->type, $types);
|
||||
|
||||
return $url && $full ?
|
||||
@ -127,7 +127,7 @@ class zcfsRsExtPosts extends rsExtPost
|
||||
$content = self::zcFeedBrother('getContent', [&$rs, $absolute_urls]);
|
||||
|
||||
if ($url && $sitename && $rs->post_type == 'post') {
|
||||
$types = @unserialize(dcCore::app()->blog->settings->__get(basename(dirname('../' . __DIR__)))->post_full_tpl);
|
||||
$types = json_decode(dcCore::app()->blog->settings->__get(basename(dirname('../' . __DIR__)))->post_full_tpl);
|
||||
|
||||
if (is_array($types) && in_array(dcCore::app()->url->type, $types)) {
|
||||
return $content . sprintf(
|
||||
|
@ -29,10 +29,10 @@ class zcfsUpgrade
|
||||
{
|
||||
}
|
||||
|
||||
// Rename settings
|
||||
protected static function preUpgrade20221210()
|
||||
{
|
||||
$settings_ids = [
|
||||
// Rename settings
|
||||
$setting_ids = [
|
||||
'zoneclearFeedServer_active' => 'active',
|
||||
'zoneclearFeedServer_pub_active' => 'pub_active',
|
||||
'zoneclearFeedServer_post_status_new' => 'psot_new_status',
|
||||
@ -45,10 +45,38 @@ class zcfsUpgrade
|
||||
'zoneclearFeedServer_post_title_redir' => 'post_title_redir',
|
||||
];
|
||||
|
||||
foreach ($settings_ids as $old => $new) {
|
||||
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) . "' "))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user