Ticket #745: 745c.diff

File 745c.diff, 4.0 kB (added by mdawaffe, 1 year ago)
  • bb-includes/classes.php

    old new  
    286286                        $fields .= ", MIN(p.post_id) as post_id"; 
    287287 
    288288                        // GROUP_CONCAT requires MySQL >= 4.1 
    289                         if ( version_compare('4.1', mysql_get_client_info(), '<=') ) 
     289                        if ( version_compare('4.1', $bbdb->db_version(), '<=') ) 
    290290                                $fields .= ", GROUP_CONCAT(p.post_text SEPARATOR ' ') AS post_text"; 
    291291                        else 
    292292                                $fields .= ", p.post_text"; 
  • bb-includes/db-mysqli.php

    old new  
    11<?php 
    22 
     3define('BB_MYSQLI', true); 
     4 
    35define('OBJECT', 'OBJECT', true); 
    46define('ARRAY_A', 'ARRAY_A', false); 
    57define('ARRAY_N', 'ARRAY_N', false); 
     
    7779                 
    7880                $this->$dbhname = @mysqli_connect( $server->host, $server->user, $server->pass, null, $server->port ); 
    7981 
    80                 if ( !empty($this->charset) && version_compare(mysql_get_server_info(), '4.1.0', '>=') ) 
     82                if ( !empty($this->charset) && version_compare(mysqli_get_server_info($this->$dbhname), '4.1.0', '>=') ) 
    8183                        $this->query("SET NAMES '$this->charset'"); 
    8284 
    8385                $this->select( $server->database, $this->$dbhname ); 
     
    8789                return $this->$dbhname;  
    8890        } 
    8991 
     92        function db_version( $dbh = false ) { // table name or mysql resource 
     93                if ( !$dbh ) 
     94                        $dbh = $this->forums; 
     95 
     96                if ( !is_resource( $dbh ) ) 
     97                        $dbh = $this->db_connect( "DESCRIBE $dbh" ); 
     98 
     99                return mysqli_get_server_info( $dbh ); 
     100        } 
     101 
    90102        function get_table_from_query ( $q ) { 
    91103                If( substr( $q, -1 ) == ';' ) 
    92104                        $q = substr( $q, 0, -1 ); 
  • bb-includes/db.php

    old new  
    11<?php 
    22 
     3define('BB_MYSQLI', false); 
     4 
    35define('OBJECT', 'OBJECT', true); 
    46define('ARRAY_A', 'ARRAY_A', false); 
    57define('ARRAY_N', 'ARRAY_N', false); 
     
    8082                return $this->$dbhname;  
    8183        } 
    8284 
     85        function db_version( $dbh = false ) { // table name or mysql resource 
     86                if ( !$dbh ) 
     87                        $dbh = $this->forums; 
     88 
     89                if ( !is_resource( $dbh ) ) 
     90                        $dbh = $this->db_connect( "DESCRIBE $dbh" ); 
     91 
     92                return mysql_get_server_info( $dbh ); 
     93        } 
     94 
    8395        function get_table_from_query ( $q ) { 
    8496                If( substr( $q, -1 ) == ';' ) 
    8597                        $q = substr( $q, 0, -1 ); 
  • bb-admin/upgrade-schema.php

    old new  
    22global $bb_queries, $bbdb; 
    33 
    44$charset_collate = ''; 
     5$user_charset_collate = ''; 
    56 
    6 if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) { 
     7if ( !defined( 'BB_MYSQLI' ) ) 
     8        die( __('Database class not loaded.') ); 
     9 
     10if ( version_compare($bbdb->db_version(), '4.1.0', '>=') ) { 
    711        if ( ! empty($bbdb->charset) ) 
    812                $charset_collate = "DEFAULT CHARACTER SET $bbdb->charset"; 
    913        if ( ! empty($bbdb->collate) ) 
    1014                $charset_collate .= " COLLATE $bbdb->collate"; 
    1115} 
    1216 
     17if ( version_compare($bbdb->db_version( $bbdb->users ), '4.1.0', '>=') ) { 
     18        if ( ! empty($bbdb->charset) ) 
     19                $user_charset_collate = "DEFAULT CHARACTER SET $bbdb->charset"; 
     20        if ( ! empty($bbdb->collate) ) 
     21                $user_charset_collate .= " COLLATE $bbdb->collate"; 
     22} 
     23 
    1324$bb_queries = "CREATE TABLE $bbdb->forums ( 
    1425  forum_id int(10) NOT NULL auto_increment, 
    1526  forum_name varchar(150)  NOT NULL default '', 
     
    7990  display_name varchar(250) NOT NULL default '', 
    8091  PRIMARY KEY  (ID), 
    8192  UNIQUE KEY user_login (user_login) 
    82 ) $charset_collate; 
     93) $user_charset_collate; 
    8394CREATE TABLE $bbdb->usermeta ( 
    8495  umeta_id bigint(20) NOT NULL auto_increment, 
    8596  user_id bigint(20) NOT NULL default '0', 
     
    8899  PRIMARY KEY  (umeta_id), 
    89100  KEY user_id (user_id), 
    90101  KEY meta_key (meta_key) 
    91 ) $charset_collate; 
     102) $user_charset_collate; 
    92103CREATE TABLE $bbdb->tags ( 
    93104  tag_id bigint(20) unsigned NOT NULL auto_increment, 
    94105  tag varchar(200) NOT NULL default '',