Changeset 206
- Timestamp:
- 04/04/08 18:03:53 (8 months ago)
- Files:
-
- trunk/Phergie/Plugin/Abstract/Base.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Logging.php (modified) (7 diffs)
- trunk/Phergie/Plugin/Seen.php (modified) (1 diff)
- trunk/Phergie/Plugin/Url.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Phergie/Plugin/Abstract/Base.php
r205 r206 94 94 final public function __construct(Phergie_Driver_Abstract $client) 95 95 { 96 set_error_handler(array($this, 'onBaseError')); 96 // Temp fix till a better one is added 97 @set_error_handler(array(__CLASS__, 'onBaseError')); 97 98 $this->client = $client; 98 99 … … 124 125 return false; 125 126 } 127 126 128 return call_user_func_array(array($this, 'onPhpError'), array($errno, $errstr, $errfile, $errline)); 127 129 } trunk/Phergie/Plugin/Logging.php
r204 r206 97 97 * @var PDO 98 98 */ 99 protected static$db = null;99 protected $db = null; 100 100 101 101 /** … … 105 105 */ 106 106 protected $insert; 107 108 /** 109 * Static PDO instance for the database 110 * 111 * @var PDO 112 */ 113 protected static $staticDB; 107 114 108 115 /** … … 115 122 try { 116 123 // 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)) { 119 126 return; 120 127 } 121 128 122 129 // Check to see if the table exists 123 $table = self::$db124 ->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')) 125 132 ->fetchColumn(); 126 133 … … 128 135 if (!$table) { 129 136 $this->debug('Creating the database schema'); 130 $result = self::$db->exec('137 $result = $this->db->exec(' 131 138 CREATE TABLE logs ( 132 139 tstamp VARCHAR(19), … … 141 148 } 142 149 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) 158 152 '); 159 153 } catch (PDOException $e) { } 154 self::$staticDB = $this->db; 160 155 } 161 156 … … 195 190 protected function insertEvent($type, $chan, $nick, $message = null) 196 191 { 197 if (! self::$db) {192 if (!is_object($this->db)) { 198 193 return; 199 194 } … … 358 353 359 354 public static function databaseExists() { 360 return (is_object(self::$ db) ? true : false);355 return (is_object(self::$staticDB) ? true : false); 361 356 } 362 357 363 358 public static function prepare($query) { 364 if (! self::$db) {359 if (!is_object(self::$staticDB)) { 365 360 return false; 366 361 } 367 362 368 return self::$ db->prepare($query);363 return self::$staticDB->prepare($query); 369 364 } 370 365 } trunk/Phergie/Plugin/Seen.php
r205 r206 14 14 */ 15 15 protected $search; 16 protected $searchAll;17 16 18 17 /** trunk/Phergie/Plugin/Url.php
r205 r206 58 58 */ 59 59 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; 60 68 61 69 /** … … 223 231 224 232 if (empty($title)) { 225 if ($tinyUrl === $url) {226 unset($tinyUrl, $url);227 return;228 }229 233 if ($this->errorStatus) { 230 $title = '[ Error '.$this->errorStatus.' ]'; 234 if (!$this->showErrors) { 235 continue; 236 } 237 $title = 'Error: '.$this->errorStatus; 231 238 $this->errorStatus = false; 232 239 } else { 233 $title = ' [ No Title ]';240 $title = 'No Title'; 234 241 } 235 242 } … … 369 376 stripos($errstr, 'SSL operation failed with code') !== false || 370 377 stripos($errstr, 'unable to connect to') !== false) { 378 $this->errorStatus = 'Request Failed'; 371 379 return true; 372 380 }