Commit 89824762 authored by Chris Graham's avatar Chris Graham

Various import fixes and cleanups

parent 3f5a2a7d
......@@ -40,7 +40,7 @@ class mail_test_set extends cms_test_case
case 'NOTIFICATIONS':
require_code('notifications');
set_mass_import_mode(true);
set_mass_import_mode();
$_GET['keep_debug_notifications'] = '1';
dispatch_notification('error_occurred', '', 'test', 'test', array(get_member()), get_member(), 1, false, true, '', '', '', '', '', '', $attachments);
break;
......
......@@ -22,7 +22,7 @@ i_solemnly_declare(I_UNDERSTAND_SQL_INJECTION | I_UNDERSTAND_XSS | I_UNDERSTAND_
$title = get_screen_title('Publish new Composr release', false);
$title->evaluate_echo();
set_mass_import_mode(true);
set_mass_import_mode();
restrictify();
require_code('permissions2');
......
......@@ -359,7 +359,7 @@ class Module_admin_import
$db_name = get_db_site();
$db_user = get_db_site_user();
$db_table_prefix = array_key_exists('prefix', $info) ? $info['prefix'] : $GLOBALS['SITE_DB']->get_table_prefix();
$refresh_time = 0;
$refresh_time = 45;
}
// Build the form
......
......@@ -850,7 +850,7 @@ class Module_admin_setupwizard
// Proceed...
set_mass_import_mode(true);
set_mass_import_mode();
require_code('config2');
require_code('themes2');
......
......@@ -166,7 +166,7 @@ function cns_make_post($topic_id, $title, $post, $skip_sig = 0, $is_starter = fa
$title = $GLOBALS['FORUM_DB']->query_select_value_if_there('f_topics', 't_cache_first_title', array('id' => $topic_id));
}
if (!running_script('install')) {
if ((!running_script('install')) && (!get_mass_import_mode())) {
require_code('antispam');
inject_action_spamcheck($poster_name_if_guest, post_param_string('email', null));
}
......@@ -200,7 +200,7 @@ function cns_make_post($topic_id, $title, $post, $skip_sig = 0, $is_starter = fa
}
}
if ((is_null($forum_id)) || (($topic_title == '') && (!$is_starter))) {
if ((is_null($forum_id)) || (($topic_title == '') && (!$is_starter) && ($check_permissions || $update_caching || $send_notification))) {
$info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_is_open', 't_pt_from', 't_pt_to', 't_forum_id', 't_cache_last_member_id', 't_cache_first_title'), array('id' => $topic_id), '', 1);
if (!array_key_exists(0, $info)) {
warn_exit(do_lang_tempcode('MISSING_RESOURCE', 'topic'));
......@@ -233,7 +233,7 @@ function cns_make_post($topic_id, $title, $post, $skip_sig = 0, $is_starter = fa
}
// Ensure parent post is from the same topic
if (!is_null($parent_id)) {
if ((!is_null($parent_id)) && (!get_mass_import_mode())) {
$test_topic_id = $GLOBALS['FORUM_DB']->query_select_value_if_there('f_posts', 'p_topic_id', array('id' => $parent_id), ' AND ' . cns_get_topic_where($topic_id, $poster));
if (is_null($test_topic_id)) {
$parent_id = null;
......@@ -451,8 +451,10 @@ function cns_make_post($topic_id, $title, $post, $skip_sig = 0, $is_starter = fa
}
// Tidy up auto-save
require_code('autosave');
clear_cms_autosave();
if (!get_mass_import_mode()) {
require_code('autosave');
clear_cms_autosave();
}
if (!get_mass_import_mode()) {
set_value('cns_post_count', strval(intval(get_value('cns_post_count')) + 1));
......
This diff is collapsed.
......@@ -205,6 +205,7 @@ function i_force_refresh()
$url = $I_REFRESH_URL;
foreach ($GLOBALS as $key => $val) {
if (preg_match('#^JUMPSTART_#', $key) != 0) {
$url = preg_replace('#&' . preg_quote($key, '#') . '=\d+#', '', $url);
$url .= '&' . $key . '=' . strval($val);
}
}
......
......@@ -376,33 +376,42 @@ function canonicalise_sitemap_page_link(&$page_link)
*/
function notify_sitemap_node_add($page_link, $add_date, $edit_date, $priority, $refreshfreq, $guest_access)
{
if (running_script('install')) {
// Maybe we're still installing
if (running_script('install') || !$GLOBALS['SITE_DB']->table_exists('sitemap_cache')) {
return;
}
canonicalise_sitemap_page_link($page_link);
// Maybe we're still installing
if (!$GLOBALS['SITE_DB']->table_exists('sitemap_cache') || running_script('install')) {
return;
}
static $fresh = null;
if ($fresh === null) {
$fresh = ($GLOBALS['SITE_DB']->query_select_value('sitemap_cache', 'COUNT(*)') == 0) && (!$GLOBALS['RUNNING_BUILD_SITEMAP_CACHE_TABLE']);
}
// Find set number we will write into
$set_number = $GLOBALS['SITE_DB']->query_select_value_if_there('sitemap_cache', 'set_number', null, 'GROUP BY set_number HAVING COUNT(*)<' . strval(URLS_PER_SITEMAP_SET));
if (is_null($set_number)) {
// Next set number in sequence
$set_number = $GLOBALS['SITE_DB']->query_select_value_if_there('sitemap_cache', 'MAX(set_number)');
if (is_null($set_number)) {
$set_number = 0;
static $set_number = null;
static $number_in_set = 0;
if ($set_number === null) {
$set_details = $GLOBALS['SITE_DB']->query_select('sitemap_cache', array('set_number', 'COUNT(*) AS cnt'), null, 'GROUP BY set_number HAVING COUNT(*)<' . strval(URLS_PER_SITEMAP_SET));
if (array_key_exists(0, $set_details)) {
$set_number = $set_details[0]['set_number'];
$number_in_set = $set_details[0]['cnt'];
} else {
$set_number++;
// Next set number in sequence
$set_number = $GLOBALS['SITE_DB']->query_select_value_if_there('sitemap_cache', 'MAX(set_number)');
if (is_null($set_number)) {
$set_number = 0;
} else {
$set_number++;
}
$number_in_set = 0;
}
} elseif ($number_in_set >= URLS_PER_SITEMAP_SET) {
// Advance
$set_number++;
$number_in_set = 0;
}
$number_in_set++;
// Save into sitemap
$GLOBALS['SITE_DB']->query_delete('sitemap_cache', array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment