Commit 32dee83f authored by Chris Graham's avatar Chris Graham
Browse files

Fixed MANTIS-4713 (Inefficiency with log_it calls)

parent c932cf94
Loading
Loading
Loading
Loading
+43 −23
Original line number Diff line number Diff line
@@ -115,39 +115,59 @@ class lang_misc_test_set extends cms_test_case
    {
        $matches = array();

        if ((empty($_GET['only'])) || ($_GET['only'] == 'do_lang_tempcode')) {
            $num_matches = preg_match_all('#do\_lang\_tempcode\(\'([^\']*)\'[\),]#', $c, $matches);
            for ($i = 0; $i < $num_matches; $i++) {
                $str = $matches[1][$i];
                $this->process_str_reference($str, 'do_lang_tempcode', $file);
                $this->check_includes($c, $str, $file);
            }
        }

        if ((empty($_GET['only'])) || ($_GET['only'] == 'do_lang')) {
            $num_matches = preg_match_all('#do\_lang\(\'([^\']*)\'[\),]#', $c, $matches);
            for ($i = 0; $i < $num_matches; $i++) {
                $str = $matches[1][$i];
                $this->process_str_reference($str, 'do_lang', $file);
                $this->check_includes($c, $str, $file);
            }
        }

        if ((empty($_GET['only'])) || ($_GET['only'] == 'log_it')) {
            $num_matches = preg_match_all('#log\_it\(\'([^\']*)\'[\),]#', $c, $matches);
            for ($i = 0; $i < $num_matches; $i++) {
                $str = $matches[1][$i];
                $this->process_str_reference($str, 'log_it', $file);
                $this->check_includes($c, $str, $file);
            }
        }

        if ((empty($_GET['only'])) || ($_GET['only'] == 'do_notification_lang')) {
            $num_matches = preg_match_all('#do\_notification\_lang\(\'([^\']*)\'[\),]#', $c, $matches);
            for ($i = 0; $i < $num_matches; $i++) {
                $str = $matches[1][$i];
            $this->process_str_reference($str, 'do_lang', $file);
                $this->process_str_reference($str, 'do_notification_lang', $file);
                $this->check_includes($c, $str, $file);
            }
        }

        if ((empty($_GET['only'])) || ($_GET['only'] == 'get_screen_title')) {
            $num_matches = preg_match_all('#get_screen_title\(\'([^\']*)\'\)#', $c, $matches);
            for ($i = 0; $i < $num_matches; $i++) {
                $str = $matches[1][$i];
                $this->process_str_reference($str, 'get_screen_title', $file);
                $this->check_includes($c, $str, $file);
            }
        }

        if ((empty($_GET['only'])) || ($_GET['only'] == 'Tempcode')) {
            $num_matches = preg_match_all('#[^\\\\]\{\!([\w:]+)[^\}]*\}#', $c, $matches);
            for ($i = 0; $i < $num_matches; $i++) {
                $str = $matches[1][$i];
                $this->process_str_reference($str, 'Tempcode', $file);
            }
        }
    }

    private function check_includes($c, $str, $file)
    {
+2 −0
Original line number Diff line number Diff line
@@ -776,6 +776,7 @@ function install_addon($file, $files = null, $do_files = true, $do_db = true)

    tar_close($tar);

    require_lang('addons');
    log_it('INSTALL_ADDON', $addon);
}

@@ -901,6 +902,7 @@ function uninstall_addon($addon, $clear_caches = true)
        }
    }

    require_lang('addons');
    log_it('UNINSTALL_ADDON', $addon_info['name']);
}

+3 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ function add_award_type($title, $description, $points, $content_type, $hide_awar
    $map += insert_lang_comcode('a_description', $description, 2);
    $id = $GLOBALS['SITE_DB']->query_insert('award_types', $map, true);

    require_lang('awards');
    log_it('ADD_AWARD_TYPE', strval($id), $title);

    if ((addon_installed('commandr')) && (!running_script('install')) && (!get_mass_import_mode())) {
@@ -82,6 +83,7 @@ function edit_award_type($id, $title, $description, $points, $content_type, $hid
    $map += lang_remap_comcode('a_description', $_description, $description);
    $GLOBALS['SITE_DB']->query_update('award_types', $map, array('id' => $id));

    require_lang('awards');
    log_it('EDIT_AWARD_TYPE', strval($id), $title);

    if ((addon_installed('commandr')) && (!running_script('install')) && (!get_mass_import_mode())) {
@@ -102,6 +104,7 @@ function delete_award_type($id)
        warn_exit(do_lang_tempcode('MISSING_RESOURCE', 'award_type'));
    }
    $_description = $GLOBALS['SITE_DB']->query_select_value('award_types', 'a_description', array('id' => $id));
    require_lang('awards');
    log_it('DELETE_AWARD_TYPE', strval($id), get_translated_text($_title));
    $GLOBALS['SITE_DB']->query_delete('award_types', array('id' => $id), '', 1);
    $GLOBALS['SITE_DB']->query_delete('award_archive', array('a_type_id' => $id), '', 1);
+2 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ function cns_make_post_template($title, $text, $forum_multi_code, $use_default_f
        't_use_default_forums' => $use_default_forums
    ), true);

    require_lang('cns_post_templates');
    log_it('ADD_POST_TEMPLATE', strval($id), $title);

    if ((addon_installed('commandr')) && (!running_script('install')) && (!get_mass_import_mode())) {
@@ -123,6 +124,7 @@ function cns_make_welcome_email($name, $subject, $text, $send_time, $newsletter
        generate_resource_fs_moniker('welcome_email', strval($id), null, null, true);
    }

    require_lang('cns_welcome_emails');
    log_it('ADD_WELCOME_EMAIL', strval($id), $subject);

    return $id;
+4 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ function cns_edit_post_template($id, $title, $text, $forum_multi_code, $use_defa
        't_use_default_forums' => $use_default_forums
    ), array('id' => $id), '', 1);

    require_lang('cns_post_templates');
    log_it('EDIT_POST_TEMPLATE', strval($id), $title);

    if ((addon_installed('commandr')) && (!running_script('install')) && (!get_mass_import_mode())) {
@@ -53,6 +54,7 @@ function cns_delete_post_template($id)
{
    $GLOBALS['FORUM_DB']->query_delete('f_post_templates', array('id' => $id), '', 1);

    require_lang('cns_post_templates');
    log_it('DELETE_POST_TEMPLATE', strval($id));

    if ((addon_installed('commandr')) && (!running_script('install')) && (!get_mass_import_mode())) {
@@ -210,6 +212,7 @@ function cns_edit_welcome_email($id, $name, $subject, $text, $send_time, $newsle
        generate_resource_fs_moniker('welcome_email', strval($id));
    }

    require_lang('cns_welcome_emails');
    log_it('EDIT_WELCOME_EMAIL', strval($id), get_translated_text($_subject));
}

@@ -235,6 +238,7 @@ function cns_delete_welcome_email($id)
        expunge_resource_fs_moniker('welcome_email', strval($id));
    }

    require_lang('cns_welcome_emails');
    log_it('DELETE_WELCOME_EMAIL', strval($id), get_translated_text($_subject));
}

Loading