• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
some hooks request page twice

#1
good day! when i use post_controller_constructor, post_controller or display_override hooks, pages requested twice, so all of requests to db also requested twice, and because of the code below which increments post views there is an illusion that views are incremented by 2

PHP Code:
public function update_views($news_id)
{
    return 
$this->db
        
->set('`news_views`''`news_views` + 1'FALSE)
        ->
where('news_id'$news_id)
        ->
update('news');


or maybe the problem is in my hook function, but where? i am not able to find, my hook contains only this function:
PHP Code:
if ( ! function_exists('minify_html'))
{
    
/**
     * Minify HTML
     */
    
function minify_html()
    {
        
$CI     =& get_instance();
        
$output =& $CI->output;
        
$config =& $CI->config;

        
$notAsset get_class($CI) !== 'Assets';
        
$notMedia get_class($CI) !== 'Media';

        
$output->parse_exec_vars FALSE;

        if ( ! 
$CI->input->is_ajax_request() && $notAsset && $notMedia)
        {
            
$title $config->item('title');

            
$output->set_output(
                
$CI->load->view(
                    
get_class($CI) === 'Admin' 'admin/body' 'body',
                    array(
                        
'title' => ($title $title.'  |  ' '').'NEWS.LOC',
                        
'body'  => $output->get_output()
                ), 
TRUE)
            );
        }

        if (
$notAsset && $notMedia)
        {
            
$output
                
->set_output(
                    
preg_replace(
                        array(
                            
'/ {2,}+/',
                            
'/<!--.*?-->|\t|(?:\r?\n[\t]*)+/s',
                            
'/> {2,}+</'
                        
),
                        array(
' ''''><'),
                        
$output->get_output()
                    )
                );
        }

        
$output->_display();
    }


p.s: pls dont advice me to use minify libraries if there is no problem in preg_replace part Smile just help me find the real probem Smile
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.