Changeset 630


Ignore:
Timestamp:
Jun 8, 2018 3:41:16 AM (6 years ago)
Author:
anonymous
Message:

Disable App::sslOn(). Better logging on Email::send() unreplaced variables. Fix the elusive 'Database table session_tbl has invalid columns' error.

Location:
trunk/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/App.inc.php

    r629 r630  
    16011601
    16021602    /**
    1603      * Force the user to connect via https (port 443) by redirecting them to
    1604      * the same page but with https.
     1603     * This function has changed to do nothing. SSL redirection should happen at the server layer, doing so here may result in a redirect loop.
    16051604     */
    16061605    public function sslOn()
    16071606    {
    1608         if (function_exists('apache_get_modules')) {
    1609             $modules = apache_get_modules();
    1610         } else {
    1611             // It's safe to assume we have mod_ssl if we can't determine otherwise.
    1612             $modules = array('mod_ssl');
    1613         }
    1614 
    1615         if (!getenv('HTTPS') && $this->getParam('ssl_enabled') && in_array('mod_ssl', $modules)) {
    1616             $this->raiseMsg(sprintf(_("Secure SSL connection made to %s"), $this->getParam('ssl_domain')), MSG_NOTICE, __FILE__, __LINE__);
    1617             // Always append session because some browsers do not send cookie when crossing to SSL URL.
    1618             $this->dieURL('https://' . $this->getParam('ssl_domain') . getenv('REQUEST_URI'), null, true);
    1619         }
     1607        $app =& App::getInstance();
     1608        $app->logMsg(sprintf('sslOn was called and ignored.', null), LOG_DEBUG, __FILE__, __LINE__);
    16201609    }
    16211610
     
    16261615    {
    16271616        $app =& App::getInstance();
    1628         $app->logMsg(sprintf('sslOff was called and ignored.', null), LOG_INFO, __FILE__, __LINE__);
     1617        $app->logMsg(sprintf('sslOff was called and ignored.', null), LOG_DEBUG, __FILE__, __LINE__);
    16291618    }
    16301619
  • trunk/lib/DB.inc.php

    r627 r630  
    7878
    7979    // Caches.
    80     protected $existing_tables;
    81     protected $table_columns;
     80    protected static $existing_tables = null;
     81    protected static $table_columns = null;
    8282
    8383    /**
     
    377377        }
    378378
    379         if (!isset($this->existing_tables) || !$use_cached_results) {
    380             $this->existing_tables = array();
     379        if (is_null(self::$existing_tables) || !$use_cached_results) {
     380            self::$existing_tables = array();
    381381            $qid = $this->query("SHOW TABLES");
    382382            while (list($row) = mysql_fetch_row($qid)) {
    383                 $this->existing_tables[] = $row;
     383                self::$existing_tables[] = $row;
    384384            }
    385385        }
    386         if (in_array($table, $this->existing_tables)) {
     386
     387        if (in_array($table, self::$existing_tables)) {
    387388            return true;
    388389        } else {
     
    421422        }
    422423
    423         if (!isset($this->table_columns[$table]) || !$use_cached_results) {
     424        if (!isset(self::$table_columns[$table]) || !$use_cached_results) {
    424425            // Populate and cache array of current columns for this table.
    425             $this->table_columns[$table] = array();
     426            self::$table_columns[$table] = array();
    426427            $qid = $this->query("DESCRIBE $table");
    427428            while ($row = mysql_fetch_row($qid)) {
    428                 $this->table_columns[$table][] = $row[0];
     429                self::$table_columns[$table][] = $row[0];
    429430            }
    430431        }
     
    433434            // Do an exact comparison of table schemas.
    434435            sort($columns);
    435             sort($this->table_columns[$table]);
    436             return $this->table_columns[$table] == $columns;
     436            sort(self::$table_columns[$table]);
     437            return self::$table_columns[$table] == $columns;
    437438        } else {
    438439            // Only check that the specified columns are available in the table.
    439             $match_columns = array_intersect($this->table_columns[$table], $columns);
     440            $match_columns = array_intersect(self::$table_columns[$table], $columns);
    440441            sort($columns);
    441442            sort($match_columns);
     
    467468    public function resetCache()
    468469    {
    469         $this->existing_tables = null;
    470         $this->table_columns = null;
     470        self::$existing_tables = null;
     471        self::$table_columns = null;
    471472    }
    472473
  • trunk/lib/DBSessionHandler.inc.php

    r583 r630  
    114114            )");
    115115
    116             if (!$this->db->columnExists($this->_params['db_table'], array('session_id', 'session_data', 'last_access'))) {
     116            if (!$this->db->columnExists($this->_params['db_table'], array(
     117                'session_id',
     118                'session_data',
     119                'last_access'
     120            ), false, false)) {
    117121                $app->logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), LOG_ALERT, __FILE__, __LINE__);
    118122                trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), E_USER_ERROR);
  • trunk/lib/Email.inc.php

    r628 r630  
    7878    );
    7979
     80    // String that contains filename of the template used (for logging).
     81    protected $_template_filename;
     82
    8083    // String that contains the email body.
    8184    protected $_template;
     
    198201        // This could be a new template, so reset the _template_replaced.
    199202        $this->_template_replaced = null;
     203
     204        $this->_template_filename = $template;
     205
    200206        return true;
    201207    }
     
    221227            // This could be a new template, so reset the _template_replaced.
    222228            $this->_template_replaced = null;
     229
     230            $this->_template_filename = '(using Email::setString)';
     231
    223232            return true;
    224233        }
     
    281290        if (preg_match('/({[^}]+})/', $final_body, $unreplaced_match)) {
    282291            unset($unreplaced_match[0]);
    283             $app->logMsg(sprintf('Cannot get email body. Unreplaced variables in template: %s', getDump($unreplaced_match)), LOG_ERR, __FILE__, __LINE__);
     292            $app->logMsg(sprintf('Cannot get email body. Unreplaced variable %s in template %s', getDump($unreplaced_match)), LOG_ERR, __FILE__, __LINE__);
    284293            return false;
    285294        }
     
    339348        if (preg_match('/({[^}]+})/', $final_body, $unreplaced_match)) {
    340349            unset($unreplaced_match[0]);
    341             $app->logMsg(sprintf('Cannot send email. Unreplaced variables in template: %s', getDump($unreplaced_match)), LOG_ERR, __FILE__, __LINE__);
    342             return false;
     350            $app->logMsg(sprintf('Unreplaced variable "%s" in template "%s"', getDump($unreplaced_match), $this->_template_filename), LOG_ERR, __FILE__, __LINE__);
    343351        }
    344352
Note: See TracChangeset for help on using the changeset viewer.