Assembla home | Assembla project page
 

Changeset 206

Show
Ignore:
Timestamp:
04/04/08 18:03:53 (8 months ago)
Author:
Slynderdale
Message:

Some more bug fixes. Added a temp fix to Base.php to make onPhpError work again, added a fix to logging to hopefully keep it working. Also added a toggle to URL to display URL errors in messages or not, default to fault.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Plugin/Abstract/Base.php

    r205 r206  
    9494    final public function __construct(Phergie_Driver_Abstract $client) 
    9595    { 
    96         set_error_handler(array($this, 'onBaseError')); 
     96        // Temp fix till a better one is added 
     97        @set_error_handler(array(__CLASS__, 'onBaseError')); 
    9798        $this->client = $client; 
    9899 
     
    124125            return false; 
    125126        } 
     127 
    126128        return call_user_func_array(array($this, 'onPhpError'), array($errno, $errstr, $errfile, $errline)); 
    127129    } 
  • trunk/Phergie/Plugin/Logging.php

    r204 r206  
    9797    * @var PDO 
    9898    */ 
    99     protected static $db = null; 
     99    protected $db = null; 
    100100 
    101101    /** 
     
    105105    */ 
    106106    protected $insert; 
     107 
     108    /** 
     109    * Static PDO instance for the database 
     110    * 
     111    * @var PDO 
     112    */ 
     113    protected static $staticDB; 
    107114 
    108115    /** 
     
    115122        try { 
    116123            // Initialize the database connection 
    117             self::$db = new PDO('sqlite:' . $this->dir . 'logging.db'); 
    118             if (!self::$db) { 
     124            $this->db = new PDO('sqlite:' . $this->dir . 'logging.db'); 
     125            if (!is_object($this->db)) { 
    119126                return; 
    120127            } 
    121128 
    122129            // Check to see if the table exists 
    123             $table = self::$db 
    124                 ->query('SELECT COUNT(*) FROM sqlite_master WHERE name = ' . self::$db->quote('logs')) 
     130            $table = $this->db 
     131                ->query('SELECT COUNT(*) FROM sqlite_master WHERE name = ' . $this->db->quote('logs')) 
    125132                ->fetchColumn(); 
    126133 
     
    128135            if (!$table) { 
    129136                $this->debug('Creating the database schema'); 
    130                 $result = self::$db->exec(' 
     137                $result = $this->db->exec(' 
    131138                    CREATE TABLE logs ( 
    132139                        tstamp VARCHAR(19), 
     
    141148            } 
    142149 
    143             $this->insert = self::$db->prepare(' 
    144                 INSERT INTO logs ( 
    145                     tstamp, 
    146                     type, 
    147                     chan, 
    148                     nick, 
    149                     message 
    150                 ) 
    151                 VALUES ( 
    152                     :tstamp, 
    153                     :type, 
    154                     :chan, 
    155                     :nick, 
    156                     :message 
    157                 ) 
     150            $this->insert = $this->db->prepare(' 
     151                INSERT INTO logs (tstamp,type,chan,nick,message) VALUES (:tstamp,:type,:chan,:nick,:message) 
    158152            '); 
    159153        } catch (PDOException $e) { } 
     154        self::$staticDB = $this->db; 
    160155    } 
    161156 
     
    195190    protected function insertEvent($type, $chan, $nick, $message = null) 
    196191    { 
    197         if (!self::$db) { 
     192        if (!is_object($this->db)) { 
    198193            return; 
    199194        } 
     
    358353 
    359354    public static function databaseExists() { 
    360         return (is_object(self::$db) ? true : false); 
     355        return (is_object(self::$staticDB) ? true : false); 
    361356    } 
    362357 
    363358    public static function prepare($query) { 
    364         if (!self::$db) { 
     359        if (!is_object(self::$staticDB)) { 
    365360            return false; 
    366361        } 
    367362 
    368         return self::$db->prepare($query); 
     363        return self::$staticDB->prepare($query); 
    369364    } 
    370365} 
  • trunk/Phergie/Plugin/Seen.php

    r205 r206  
    1414    */ 
    1515    protected $search; 
    16     protected $searchAll; 
    1716 
    1817    /** 
  • trunk/Phergie/Plugin/Url.php

    r205 r206  
    5858     */ 
    5959    protected $errorStatus = false; 
     60 
     61    /** 
     62     * Whether or not to display error messages as the title if a link posted 
     63     *  encounters an error. 
     64     * 
     65     * @var boolean 
     66     */ 
     67    protected $showErrors = false; 
    6068 
    6169    /** 
     
    223231 
    224232                if (empty($title)) { 
    225                     if ($tinyUrl === $url) { 
    226                         unset($tinyUrl, $url); 
    227                         return; 
    228                     } 
    229233                    if ($this->errorStatus) { 
    230                         $title = '[ Error '.$this->errorStatus.' ]'; 
     234                        if (!$this->showErrors) { 
     235                            continue; 
     236                        } 
     237                        $title = 'Error: '.$this->errorStatus; 
    231238                        $this->errorStatus = false; 
    232239                    } else { 
    233                         $title = '[ No Title ]'; 
     240                        $title = 'No Title'; 
    234241                    } 
    235242                } 
     
    369376                       stripos($errstr, 'SSL operation failed with code') !== false || 
    370377                       stripos($errstr, 'unable to connect to') !== false) { 
     378                        $this->errorStatus = 'Request Failed'; 
    371379                return true; 
    372380            }