Changeset 11846

Show
Ignore:
Timestamp:
08/30/07 11:02:09 (1 year ago)
Author:
bergie
Message:

Clean up logs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.core/midcom/services/cache/module/content.php

    r11359 r11846  
    346346    function _check_hit() 
    347347    { 
    348         debug_push_class(__CLASS__, __FUNCTION__); 
    349  
    350348        foreach ($GLOBALS["argv"] as $arg) 
    351349        { 
     
    364362        if (count($_POST) > 0) 
    365363        { 
    366             debug_add("POST variables have been found, setting no_cache and not checking for a hit."); 
     364            debug_push_class(__CLASS__, __FUNCTION__); 
     365            debug_add('POST variables have been found, setting no_cache and not checking for a hit.'); 
    367366            $this->no_cache(); 
    368367            debug_pop(); 
     
    373372        if ($this->_uncached) 
    374373        { 
    375             debug_add("We are in uncached operation, skipping check_hit detection."); 
     374            debug_push_class(__CLASS__, __FUNCTION__); 
     375            debug_add('We are in uncached operation, skipping check_hit detection.'); 
    376376            debug_pop(); 
    377377            return; 
     
    381381        if ($this->_multilang) 
    382382        { 
    383             $i18n = new midcom_services_i18n("en"); 
     383            $i18n = new midcom_services_i18n('en'); 
    384384            $entry_name = 'LANG=' . $i18n->get_current_language() . ";" ; 
    385385        } 
     
    388388            $entry_name = 'LANG=ALL;'; 
    389389        } 
    390         $midgard = mgd_get_midgard(); 
    391         $entry_name .= "USER={$midgard->user};"; 
    392         $entry_name .= "URL=" . $_SERVER["REQUEST_URI"]; 
     390 
     391        $entry_name .= "USER={$_MIDGARD['user']};"; 
     392        $entry_name .= "URL=" . $_SERVER['REQUEST_URI']; 
    393393 
    394394        $this->_meta_cache->open(); 
     
    398398            $data = $this->_meta_cache->get($entry_name); 
    399399 
    400             if (!is_null($data["expires"])) 
    401             { 
    402                 if ($data["expires"] < time()) 
     400            if (!is_null($data['expires'])) 
     401            { 
     402                if ($data['expires'] < time()) 
    403403                { 
     404                    debug_push_class(__CLASS__, __FUNCTION__); 
    404405                    debug_add("Current page is in cache, but has expired.", MIDCOM_LOG_INFO); 
    405406                    debug_pop(); 
     
    408409            } 
    409410 
    410             debug_add("Cache hit for URI " . $entry_name, MIDCOM_LOG_INFO); 
    411  
    412411            // Check If-Modified-Since and If-None-Match, do content output only if 
    413412            // we have a not modified match. 
     
    418417                { 
    419418                    $this->_data_cache->close(); 
    420                     debug_add("Current page is in not in the data cache, (possible ghost read)."); 
     419                    debug_push_class(__CLASS__, __FUNCTION__);                     
     420                    debug_add("Current page is in not in the data cache, (possible ghost read).", MIDCOM_LOG_WARN); 
    421421                    debug_pop(); 
    422422                    return; 
     
    426426                $this->_meta_cache->close(); 
    427427 
    428                 foreach ($data["sent_headers"] as $header) 
     428                foreach ($data['sent_headers'] as $header) 
    429429                { 
    430430                    header($header); 
     
    439439            } 
    440440 
    441             debug_add("Exiting", MIDCOM_LOG_INFO); 
    442441            exit(); 
    443442        } 
    444443 
    445444        $this->_meta_cache->close(); 
    446  
    447         debug_add("Cache miss for URI {$entry_name}", MIDCOM_LOG_INFO); 
    448         debug_pop(); 
    449445    } 
    450446 
     
    455451    function _start_caching() 
    456452    { 
    457         debug_push_class(__CLASS__, __FUNCTION__); 
    458         debug_add('Starting output buffering with disabled implicit flush...'); 
    459453        ob_implicit_flush(false); 
    460454        ob_start(); 
    461455        $this->_obrunning = true; 
    462         debug_pop(); 
    463456    } 
    464457 
     
    485478        } 
    486479 
    487         debug_push_class(__CLASS__, __FUNCTION__); 
    488  
    489480        $this->_no_cache = true; 
    490481 
     
    492483        { 
    493484            // Whatever is wrong here, we return. 
     485            debug_push_class(__CLASS__, __FUNCTION__);             
    494486            debug_add('Warning, we should move to no_cache but headers have already been sent, skipping header transmission.', MIDCOM_LOG_ERROR); 
    495487            debug_pop(); 
     
    497489        } 
    498490 
    499         debug_add('Caching disabled by no_cache() method, sending appropriate headers.', MIDCOM_LOG_INFO); 
    500491        header('Cache-Control: no-store, no-cache, must-revalidate'); 
    501492        header('Cache-Control: post-check=0, pre-check=0', false); 
     
    510501        } 
    511502        // PONDER:, send expires header (set to long time in past) as well ?? 
    512         debug_pop(); 
    513503    } 
    514504 
     
    538528            return; 
    539529        } 
    540         debug_push_class(__CLASS__, __FUNCTION__); 
    541         debug_add("Caching disabled by uncached() method.", MIDCOM_LOG_INFO); 
    542         debug_pop(); 
    543530        $this->_uncached = true; 
    544531    } 
     
    571558            || $this->_expires > $timestamp) 
    572559        { 
    573             debug_push_class(__CLASS__, __FUNCTION__); 
    574             debug_add("Setting expired to {$timestamp}.", MIDCOM_LOG_INFO); 
    575560            $this->_expires = $timestamp; 
    576             debug_pop(); 
    577561        } 
    578562    } 
     
    591575    function content_type($type) 
    592576    { 
    593         debug_push_class(__CLASS__, __FUNCTION__); 
    594         debug_add("Setting Content-Type to {$type}.", MIDCOM_LOG_INFO); 
    595577        $this->_content_type = $type; 
    596578 
     
    599581        $header = "Content-type: " . $this->_content_type; 
    600582        header($header); 
    601         debug_pop(); 
    602583    } 
    603584 
     
    614595    function enable_live_mode() 
    615596    { 
    616         debug_push_class(__CLASS__, __FUNCTION__); 
    617  
    618597        if ($this->_live_mode) 
    619598        { 
     599            debug_push_class(__CLASS__, __FUNCTION__);         
    620600            debug_add('Cannot enter live mode twice, ignoring request.', MIDCOM_LOG_WARN); 
    621601            debug_pop(); 
    622602            return; 
    623603        } 
    624  
    625         debug_add('Disabling output cache, entering live-mode.', MIDCOM_LOG_INFO); 
    626604 
    627605        $this->_live_mode = true; 
     
    648626            $this->_obrunning = false; 
    649627        } 
    650  
    651         debug_pop(); 
    652628    } 
    653629 
     
    662638    function register_sent_header($header) 
    663639    { 
    664         debug_push_class(__CLASS__, __FUNCTION__); 
    665         debug_add("Registering sent header '{$header}'"); 
    666640        $this->_sent_headers[] = $header; 
    667         debug_pop(); 
    668641    } 
    669642 
     
    697670    function _check_not_modified($last_modified, $etag) 
    698671    { 
    699         debug_push_class(__CLASS__, __FUNCTION__); 
    700672        if (headers_sent()) 
    701673        { 
     674            debug_push_class(__CLASS__, __FUNCTION__); 
    702675            debug_add("The headers have already been sent, cannot do a not modified check.", MIDCOM_LOG_INFO); 
    703676            debug_pop(); 
    704677            return false; 
    705678        } 
    706  
    707         debug_print_r('Checking this $_SERVER for 304 if-modified headers:', $_SERVER); 
    708         debug_add("Checking HTTP headers against last modified date {$last_modified} (" . gmdate("D, d M Y H:i:s", $last_modified) . " GMT) and E-Tag {$etag}"); 
    709679 
    710680        // These variables are set to true if the corresponding header indicates a 403 is 
     
    717687            { 
    718688                // The E-Tag is different, so we cannot 304 here. 
     689                debug_push_class(__CLASS__, __FUNCTION__); 
    719690                debug_add("The HTTP supplied E-Tag requirement does not match: {$_SERVER['HTTP_IF_NONE_MATCH']} (!= {$etag})"); 
    720691                debug_pop(); 
    721692                return false; 
    722693            } 
    723             debug_add("If-none-match against {$_SERVER['HTTP_IF_NONE_MATCH']}."); 
    724694            $if_none_match = true; 
    725695        } 
     
    735705            { 
    736706                // Last Modified does not match, so we cannot 304 here. 
     707                debug_push_class(__CLASS__, __FUNCTION__); 
    737708                debug_add("The supplied HTTP Last Modified requirement does not match: {$_SERVER['HTTP_IF_MODIFIED_SINCE']}."); 
    738709                debug_add("If-Modified-Since: ({$modified_since}) " . gmdate("D, d M Y H:i:s", $modified_since) . ' GMT'); 
     
    741712                return false; 
    742713            } 
    743             debug_add("If-modified-since match against {$_SERVER['HTTP_IF_MODIFIED_SINCE']}, parsed time was {$modified_since}."); 
    744714            $if_modified_since = true; 
    745715        } 
     
    747717        if (! $if_modified_since && ! $if_none_match) 
    748718        { 
     719            debug_push_class(__CLASS__, __FUNCTION__);         
    749720            debug_add('No If-Header was detected, we cannot 304 therefore.'); 
    750721            debug_pop(); 
    751722            return false; 
    752723        } 
    753  
    754         debug_add("We have a 304 match, sending the appropriate header and exitting afterwards."); 
    755724 
    756725        if ($this->_obrunning) 
     
    780749    function _finish_caching() 
    781750    { 
    782         debug_push_class(__CLASS__, __FUNCTION__); 
    783  
    784751        if (   $this->_no_cache 
    785752            || $this->_live_mode) 
     
    787754            if ($this->_obrunning) 
    788755            { 
    789                 debug_add("We are on no_cache/live mode, flushing output buffer and exitting"); 
    790756                ob_end_flush(); 
    791757            } 
    792             else 
    793             { 
    794                 debug_add("We don't had an outputbuffer running though the caching system was active, ignoring this as we are in no_cache/live mode!", 
    795                     MIDCOM_LOG_WARN); 
    796             } 
    797             debug_pop(); 
    798758            return; 
    799759        } 
     
    814774        header($etag_header); 
    815775        $this->register_sent_header($etag_header); 
    816         debug_add("Sent Header: {$etag_header}"); 
    817776 
    818777        // Register additional Headers around the current output request 
     
    824783        if ($this->_uncached) 
    825784        { 
    826             debug_add("Not writing cache file, we are in uncached operation mode."); 
     785            debug_push_class(__CLASS__, __FUNCTION__);         
     786            debug_add('Not writing cache file, we are in uncached operation mode.'); 
     787            debug_pop(); 
    827788        } 
    828789        else 
     
    842803            $entry_name .= "URL=" . $_SERVER["REQUEST_URI"]; 
    843804 
    844             debug_add("Creating cache entry for $entry_name", MIDCOM_LOG_INFO); 
    845  
    846             $entry_data["expires"] = $this->_expires; 
    847             $entry_data["etag"] = $etag; 
    848             $entry_data["last_modified"] = $this->_last_modified; 
    849             $entry_data["sent_headers"] = $this->_sent_headers; 
     805            debug_push_class(__CLASS__, __FUNCTION__); 
     806            debug_add("Creating cache entry for {$entry_name}", MIDCOM_LOG_INFO); 
     807            debug_pop(); 
     808 
     809            $entry_data['expires'] = $this->_expires; 
     810            $entry_data['etag'] = $etag; 
     811            $entry_data['last_modified'] = $this->_last_modified; 
     812            $entry_data['sent_headers'] = $this->_sent_headers; 
    850813 
    851814            $this->_meta_cache->open(true); 
     
    862825            $this->_obrunning = false; 
    863826        } 
    864         debug_add("Cache run complete."); 
    865         debug_pop(); 
    866827    } 
    867828 
     
    880841    function _complete_sent_headers(& $cache_data) 
    881842    { 
    882         debug_push_class(__CLASS__, __FUNCTION__); 
    883  
    884843        // Detected headers flags 
    885844        $ranges = false; 
     
    889848        foreach ($this->_sent_headers as $header) 
    890849        { 
    891             if (strncasecmp($header, "Accept-Ranges", 13) == 0) 
     850            if (strncasecmp($header, 'Accept-Ranges', 13) == 0) 
    892851            { 
    893852                $ranges = true; 
    894853            } 
    895             else if (strncasecmp($header, "Content-Length", 14) == 0) 
     854            else if (strncasecmp($header, 'Content-Length', 14) == 0) 
    896855            { 
    897856                $size = true; 
    898857            } 
    899             else if (strncasecmp($header, "Last-Modified", 13) == 0) 
     858            else if (strncasecmp($header, 'Last-Modified', 13) == 0) 
    900859            { 
    901860                $lastmod = true; 
     
    909868                if ($this->_last_modified == -1) 
    910869                { 
     870                    debug_push_class(__CLASS__, __FUNCTION__); 
    911871                    debug_add("Failed to extract the timecode from the last modified header '{$header}', defaulting to the current time.", MIDCOM_LOG_WARN); 
     872                    debug_pop(); 
    912873                    $this->_last_modified = time(); 
    913874                } 
     
    920881            header ($header); 
    921882            $this->_sent_headers[] = $header; 
    922             debug_add("Added Header '$header'"); 
    923883        } 
    924884        if (! $size) 
     
    937897                    header ($header); 
    938898                    $this->_sent_headers[] = $header; 
    939                     debug_add("Added Header '$header'"); 
    940899                    break; 
    941900            } 
     
    947906             */ 
    948907            $time = 0; 
    949             foreach ($GLOBALS["midcom"]->_context as $id => $context) 
     908            foreach ($_MIDCOM->_context as $id => $context) 
    950909            { 
    951910                $meta = $_MIDCOM->get_26_request_metadata($id); 
    952                 debug_add("SCANNING context {$id}, edited time is {$meta['lastmodified']} -- {$context[MIDCOM_CONTEXT_COMPONENT]}"); 
    953911                if ($meta['lastmodified'] > $time) 
    954912                { 
     
    960918                $time = time(); 
    961919            } 
     920             
     921            debug_push_class(__CLASS__, __FUNCTION__); 
    962922            debug_add("Setting last modified to the timestamp {$time} which is: " . gmdate("D, d M Y H:i:s", $time) . ' GMT'); 
     923            debug_pop(); 
     924             
    963925            $header = "Last-Modified: " . gmdate("D, d M Y H:i:s", $time) . ' GMT'; 
    964926            header ($header); 
    965927            $this->_sent_headers[] = $header; 
    966928            $this->_last_modified = $time; 
    967             debug_add("Added Header '$header'"); 
    968929        } 
    969930 
     
    1014975            header ($header); 
    1015976            $this->_sent_headers[] = $header; 
    1016             debug_add("Added Header '$header'"); 
    1017977        } 
    1018978        if ($pragma !== false) 
     
    1021981            header ($header); 
    1022982            $this->_sent_headers[] = $header; 
    1023             debug_add("Added Header '$header'"); 
    1024983        } 
    1025984        if ($expires !== false) 
     
    1028987            header ($header); 
    1029988            $this->_sent_headers[] = $header; 
    1030             debug_add("Added Header '$header'"); 
    1031         } 
    1032  
    1033         debug_pop(); 
     989        } 
    1034990    } 
    1035991