|
25 | 25 | /* Development setting: test experimental features and/or feature requests that never worked before? */ |
26 | 26 | $TEST_EXPERIMENTAL = 1 == getenv("MYSQL_TEST_EXPERIMENTAL"); |
27 | 27 |
|
28 | | - if (!function_exists('my_mysqli_connect')) { |
29 | | - |
30 | | - /** |
31 | | - * Whenever possible, please use this wrapper to make testing of MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible |
32 | | - * |
33 | | - * @param bool $enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)? |
34 | | - */ |
35 | | - function my_mysqli_connect($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) { |
36 | | - global $connect_flags; |
37 | | - |
38 | | - $flags = $enable_env_flags? $connect_flags:0; |
39 | | - if ($flags !== 0) { |
40 | | - $link = mysqli_init(); |
41 | | - if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags)) |
42 | | - $link = false; |
43 | | - } else { |
44 | | - $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket); |
45 | | - } |
46 | | - |
47 | | - return $link; |
| 28 | + /** |
| 29 | + * Whenever possible, please use this wrapper to make testing of MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible |
| 30 | + * |
| 31 | + * @param bool $enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)? |
| 32 | + */ |
| 33 | + function my_mysqli_connect($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) { |
| 34 | + global $connect_flags; |
| 35 | + |
| 36 | + $flags = $enable_env_flags? $connect_flags:0; |
| 37 | + if ($flags !== 0) { |
| 38 | + $link = mysqli_init(); |
| 39 | + if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags)) |
| 40 | + $link = false; |
| 41 | + } else { |
| 42 | + $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket); |
48 | 43 | } |
49 | 44 |
|
50 | | - /** |
51 | | - * Whenever possible, please use this wrapper to make testing of MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible |
52 | | - * |
53 | | - * @param bool $enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS) |
54 | | - */ |
55 | | - function my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags = 0, $enable_env_flags = true) { |
56 | | - global $connect_flags; |
| 45 | + return $link; |
| 46 | + } |
57 | 47 |
|
58 | | - if ($enable_env_flags) |
59 | | - $flags = $flags | $connect_flags; |
| 48 | + /** |
| 49 | + * Whenever possible, please use this wrapper to make testing of MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible |
| 50 | + * |
| 51 | + * @param bool $enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS) |
| 52 | + */ |
| 53 | + function my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags = 0, $enable_env_flags = true) { |
| 54 | + global $connect_flags; |
60 | 55 |
|
61 | | - return mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags); |
62 | | - } |
| 56 | + if ($enable_env_flags) |
| 57 | + $flags = $flags | $connect_flags; |
63 | 58 |
|
64 | | - class my_mysqli extends mysqli { |
65 | | - public function __construct($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) { |
66 | | - global $connect_flags; |
| 59 | + return mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags); |
| 60 | + } |
67 | 61 |
|
68 | | - $flags = ($enable_env_flags) ? $connect_flags : 0; |
| 62 | + class my_mysqli extends mysqli { |
| 63 | + public function __construct($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) { |
| 64 | + global $connect_flags; |
69 | 65 |
|
70 | | - if ($flags !== 0) { |
71 | | - parent::__construct(); |
72 | | - $this->real_connect($host, $user, $passwd, $db, $port, $socket, $flags); |
73 | | - } else { |
74 | | - parent::__construct($host, $user, $passwd, $db, $port, $socket); |
75 | | - } |
| 66 | + $flags = ($enable_env_flags) ? $connect_flags : 0; |
| 67 | + |
| 68 | + if ($flags !== 0) { |
| 69 | + parent::__construct(); |
| 70 | + $this->real_connect($host, $user, $passwd, $db, $port, $socket, $flags); |
| 71 | + } else { |
| 72 | + parent::__construct($host, $user, $passwd, $db, $port, $socket); |
76 | 73 | } |
77 | 74 | } |
| 75 | + } |
78 | 76 |
|
79 | | - function have_innodb($link) { |
80 | | - if (($res = $link->query("SHOW VARIABLES LIKE 'have_innodb'")) |
81 | | - && ($row = $res->fetch_row()) |
82 | | - && !empty($row) |
83 | | - ) { |
84 | | - return !($row[1] == 'DISABLED' || $row[1] == 'NO'); |
85 | | - } |
86 | | - // MySQL 5.6.1+ |
87 | | - if ($res = $link->query('SHOW ENGINES')) { |
88 | | - while ($row = $res->fetch_assoc()) { |
89 | | - if (!isset($row['Engine']) || !isset($row['Support'])) { |
90 | | - return false; |
91 | | - } |
92 | | - |
93 | | - if (($row['Engine'] == 'InnoDB') |
94 | | - && (($row['Support'] == 'YES') || ($row['Support'] == 'DEFAULT')) |
95 | | - ) { |
96 | | - return true; |
97 | | - } |
| 77 | + function have_innodb($link) { |
| 78 | + if (($res = $link->query("SHOW VARIABLES LIKE 'have_innodb'")) |
| 79 | + && ($row = $res->fetch_row()) |
| 80 | + && !empty($row) |
| 81 | + ) { |
| 82 | + return !($row[1] == 'DISABLED' || $row[1] == 'NO'); |
| 83 | + } |
| 84 | + // MySQL 5.6.1+ |
| 85 | + if ($res = $link->query('SHOW ENGINES')) { |
| 86 | + while ($row = $res->fetch_assoc()) { |
| 87 | + if (!isset($row['Engine']) || !isset($row['Support'])) { |
| 88 | + return false; |
| 89 | + } |
| 90 | + |
| 91 | + if (($row['Engine'] == 'InnoDB') |
| 92 | + && (($row['Support'] == 'YES') || ($row['Support'] == 'DEFAULT')) |
| 93 | + ) { |
| 94 | + return true; |
98 | 95 | } |
99 | 96 | } |
100 | | - return false; |
101 | 97 | } |
102 | | - |
103 | | - } else { |
104 | | - printf("skip Eeeek/BUG/FIXME - connect.inc included twice! skipif bug?\n"); |
| 98 | + return false; |
105 | 99 | } |
106 | 100 |
|
107 | 101 | function handle_catchable_fatal($errno, $error, $file, $line) { |
|
0 commit comments