Merge lp:~davidstrauss/drupal/195416-per-connection-prefixes into lp:~vcs-imports/drupal/old-cvs
- 195416-per-connection-prefixes
- Merge into old-cvs
Proposed by
David Strauss
Status: | Needs review |
---|---|
Proposed branch: | lp:~davidstrauss/drupal/195416-per-connection-prefixes |
Merge into: | lp:~vcs-imports/drupal/old-cvs |
Diff against target: |
801 lines 11 files modified
.bzrignore (+3/-0) includes/bootstrap.inc (+11/-0) includes/common.inc (+2/-4) includes/database/database.inc (+108/-25) includes/database/mysql/database.inc (+2/-0) includes/database/pgsql/database.inc (+2/-0) includes/database/sqlite/database.inc (+2/-0) install.php (+9/-13) modules/simpletest/drupal_web_test_case.php (+86/-92) modules/simpletest/simpletest.module (+4/-2) sites/default/default.settings.php (+14/-11) |
To merge this branch: | bzr merge lp:~davidstrauss/drupal/195416-per-connection-prefixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
VCS imports | Pending | ||
Review via email: mp+13264@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
- 11226. By David Strauss
-
Fix some duplicated code from the conflict resolution.
- 11227. By David Strauss
-
Almost working...
- 11228. By David Strauss
-
Where I am now
- 11229. By David Strauss
-
Remove junk output
- 11230. By chx <chx@veyron>
-
fixed database init
Unmerged revisions
- 11230. By chx <chx@veyron>
-
fixed database init
- 11229. By David Strauss
-
Remove junk output
- 11228. By David Strauss
-
Where I am now
- 11227. By David Strauss
-
Almost working...
- 11226. By David Strauss
-
Fix some duplicated code from the conflict resolution.
- 11225. By David Strauss
-
Current progress.
- 11224. By David Strauss
-
Ignore
- 11223. By David Strauss
-
Failed patch.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file '.bzrignore' | |||
2 | --- .bzrignore 1970-01-01 00:00:00 +0000 | |||
3 | +++ .bzrignore 2009-10-13 23:58:10 +0000 | |||
4 | @@ -0,0 +1,3 @@ | |||
5 | 1 | ./sites/default/files | ||
6 | 2 | ./sites/default/private | ||
7 | 3 | ./sites/default/settings.php | ||
8 | 0 | 4 | ||
9 | === modified file 'includes/bootstrap.inc' | |||
10 | --- includes/bootstrap.inc 2009-10-09 16:33:13 +0000 | |||
11 | +++ includes/bootstrap.inc 2009-10-13 23:58:10 +0000 | |||
12 | @@ -572,6 +572,17 @@ | |||
13 | 572 | } | 572 | } |
14 | 573 | 573 | ||
15 | 574 | /** | 574 | /** |
16 | 575 | * Retrieve (and optionally set) information about the current test being run. | ||
17 | 576 | */ | ||
18 | 577 | function drupal_test_info($value = FALSE) { | ||
19 | 578 | static $cache; | ||
20 | 579 | if ($value !== FALSE) { | ||
21 | 580 | $cache = $value; | ||
22 | 581 | } | ||
23 | 582 | return $cache; | ||
24 | 583 | } | ||
25 | 584 | |||
26 | 585 | /** | ||
27 | 575 | * Returns and optionally sets the filename for a system item (module, | 586 | * Returns and optionally sets the filename for a system item (module, |
28 | 576 | * theme, etc.). The filename, whether provided, cached, or retrieved | 587 | * theme, etc.). The filename, whether provided, cached, or retrieved |
29 | 577 | * from the database, is only returned if the file exists. | 588 | * from the database, is only returned if the file exists. |
30 | 578 | 589 | ||
31 | === modified file 'includes/common.inc' | |||
32 | --- includes/common.inc 2009-10-13 21:16:42 +0000 | |||
33 | +++ includes/common.inc 2009-10-13 23:58:11 +0000 | |||
34 | @@ -782,8 +782,6 @@ | |||
35 | 782 | * A string containing the response body that was received. | 782 | * A string containing the response body that was received. |
36 | 783 | */ | 783 | */ |
37 | 784 | function drupal_http_request($url, array $options = array()) { | 784 | function drupal_http_request($url, array $options = array()) { |
38 | 785 | global $db_prefix; | ||
39 | 786 | |||
40 | 787 | $result = new stdClass(); | 785 | $result = new stdClass(); |
41 | 788 | 786 | ||
42 | 789 | // Parse the URL and make sure we can handle the schema. | 787 | // Parse the URL and make sure we can handle the schema. |
43 | @@ -882,8 +880,8 @@ | |||
44 | 882 | // user-agent is used to ensure that multiple testing sessions running at the | 880 | // user-agent is used to ensure that multiple testing sessions running at the |
45 | 883 | // same time won't interfere with each other as they would if the database | 881 | // same time won't interfere with each other as they would if the database |
46 | 884 | // prefix were stored statically in a file or database variable. | 882 | // prefix were stored statically in a file or database variable. |
49 | 885 | if (is_string($db_prefix) && preg_match("/simpletest\d+/", $db_prefix, $matches)) { | 883 | if ($test_info = drupal_test_info()) { |
50 | 886 | $options['headers']['User-Agent'] = drupal_generate_test_ua($matches[0]); | 884 | $options['headers']['User-Agent'] = $test_info['test_run_id']; |
51 | 887 | } | 885 | } |
52 | 888 | 886 | ||
53 | 889 | $request = $options['method'] . ' ' . $path . " HTTP/1.0\r\n"; | 887 | $request = $options['method'] . ' ' . $path . " HTTP/1.0\r\n"; |
54 | 890 | 888 | ||
55 | === modified file 'includes/database/database.inc' | |||
56 | --- includes/database/database.inc 2009-10-12 02:00:04 +0000 | |||
57 | +++ includes/database/database.inc 2009-10-13 23:58:11 +0000 | |||
58 | @@ -317,6 +317,22 @@ | |||
59 | 317 | */ | 317 | */ |
60 | 318 | protected $schema = NULL; | 318 | protected $schema = NULL; |
61 | 319 | 319 | ||
62 | 320 | /** | ||
63 | 321 | * The default prefix used by this database connection. | ||
64 | 322 | * | ||
65 | 323 | * Separated from the other prefixes for performance reasons. | ||
66 | 324 | * | ||
67 | 325 | * @var string | ||
68 | 326 | */ | ||
69 | 327 | protected $defaultPrefix = ''; | ||
70 | 328 | |||
71 | 329 | /** | ||
72 | 330 | * The non-default prefixes used by this database connection. | ||
73 | 331 | * | ||
74 | 332 | * @var array | ||
75 | 333 | */ | ||
76 | 334 | protected $prefixes = array(); | ||
77 | 335 | |||
78 | 320 | function __construct($dsn, $username, $password, $driver_options = array()) { | 336 | function __construct($dsn, $username, $password, $driver_options = array()) { |
79 | 321 | // Because the other methods don't seem to work right. | 337 | // Because the other methods don't seem to work right. |
80 | 322 | $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; | 338 | $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; |
81 | @@ -390,6 +406,24 @@ | |||
82 | 390 | } | 406 | } |
83 | 391 | 407 | ||
84 | 392 | /** | 408 | /** |
85 | 409 | * Preprocess the prefix used by this database connection. | ||
86 | 410 | * | ||
87 | 411 | * @param $prefix | ||
88 | 412 | * The prefix, in any of the multiple forms documented in default.settings.php. | ||
89 | 413 | */ | ||
90 | 414 | protected function setPrefix($prefix) { | ||
91 | 415 | if (is_array($prefix)) { | ||
92 | 416 | $this->defaultPrefix = isset($prefix['default']) ? $prefix['default'] : ''; | ||
93 | 417 | unset($prefix['default']); | ||
94 | 418 | $this->prefixes = $prefix; | ||
95 | 419 | } | ||
96 | 420 | else { | ||
97 | 421 | $this->defaultPrefix = $prefix; | ||
98 | 422 | $this->prefixes = array(); | ||
99 | 423 | } | ||
100 | 424 | } | ||
101 | 425 | |||
102 | 426 | /** | ||
103 | 393 | * Append a database prefix to all tables in a query. | 427 | * Append a database prefix to all tables in a query. |
104 | 394 | * | 428 | * |
105 | 395 | * Queries sent to Drupal should wrap all table names in curly brackets. This | 429 | * Queries sent to Drupal should wrap all table names in curly brackets. This |
106 | @@ -403,27 +437,12 @@ | |||
107 | 403 | * The properly-prefixed string. | 437 | * The properly-prefixed string. |
108 | 404 | */ | 438 | */ |
109 | 405 | public function prefixTables($sql) { | 439 | public function prefixTables($sql) { |
131 | 406 | global $db_prefix; | 440 | // Replace specific table prefixes first. |
132 | 407 | 441 | foreach ($this->prefixes as $key => $val) { | |
133 | 408 | if (is_array($db_prefix)) { | 442 | $sql = strtr($sql, array('{' . $key . '}' => $val . $key)); |
134 | 409 | if (array_key_exists('default', $db_prefix)) { | 443 | } |
135 | 410 | $tmp = $db_prefix; | 444 | // Then replace remaining tables with the default prefix. |
136 | 411 | unset($tmp['default']); | 445 | return strtr($sql, array('{' => $this->defaultPrefix , '}' => '')); |
116 | 412 | foreach ($tmp as $key => $val) { | ||
117 | 413 | $sql = strtr($sql, array('{' . $key . '}' => $val . $key)); | ||
118 | 414 | } | ||
119 | 415 | return strtr($sql, array('{' => $db_prefix['default'] , '}' => '')); | ||
120 | 416 | } | ||
121 | 417 | else { | ||
122 | 418 | foreach ($db_prefix as $key => $val) { | ||
123 | 419 | $sql = strtr($sql, array('{' . $key . '}' => $val . $key)); | ||
124 | 420 | } | ||
125 | 421 | return strtr($sql, array('{' => '' , '}' => '')); | ||
126 | 422 | } | ||
127 | 423 | } | ||
128 | 424 | else { | ||
129 | 425 | return strtr($sql, array('{' => $db_prefix , '}' => '')); | ||
130 | 426 | } | ||
137 | 427 | } | 446 | } |
138 | 428 | 447 | ||
139 | 429 | /** | 448 | /** |
140 | @@ -1260,6 +1279,20 @@ | |||
141 | 1260 | if (empty($value['driver'])) { | 1279 | if (empty($value['driver'])) { |
142 | 1261 | $databaseInfo[$index][$target] = $databaseInfo[$index][$target][mt_rand(0, count($databaseInfo[$index][$target]) - 1)]; | 1280 | $databaseInfo[$index][$target] = $databaseInfo[$index][$target][mt_rand(0, count($databaseInfo[$index][$target]) - 1)]; |
143 | 1262 | } | 1281 | } |
144 | 1282 | |||
145 | 1283 | // Parse the prefix information. | ||
146 | 1284 | if (!isset($databaseInfo[$index][$target]['prefix'])) { | ||
147 | 1285 | // Default to an empty prefix. | ||
148 | 1286 | $databaseInfo[$index][$target]['prefix'] = array( | ||
149 | 1287 | 'default' => '', | ||
150 | 1288 | ); | ||
151 | 1289 | } | ||
152 | 1290 | else if (!is_array($databaseInfo[$index][$target]['prefix'])) { | ||
153 | 1291 | // Transform the flat form into an array form. | ||
154 | 1292 | $databaseInfo[$index][$target]['prefix'] = array( | ||
155 | 1293 | 'default' => $databaseInfo[$index][$target]['prefix'], | ||
156 | 1294 | ); | ||
157 | 1295 | } | ||
158 | 1263 | } | 1296 | } |
159 | 1264 | } | 1297 | } |
160 | 1265 | 1298 | ||
161 | @@ -1319,7 +1352,40 @@ | |||
162 | 1319 | if (!empty(self::$databaseInfo[$key])) { | 1352 | if (!empty(self::$databaseInfo[$key])) { |
163 | 1320 | return self::$databaseInfo[$key]; | 1353 | return self::$databaseInfo[$key]; |
164 | 1321 | } | 1354 | } |
166 | 1322 | 1355 | } | |
167 | 1356 | |||
168 | 1357 | /** | ||
169 | 1358 | * Rename a connection and its corresponding connection information. | ||
170 | 1359 | * | ||
171 | 1360 | * @param $old_key | ||
172 | 1361 | * The old connection key. | ||
173 | 1362 | * @param $new_key | ||
174 | 1363 | * The new connection key. | ||
175 | 1364 | */ | ||
176 | 1365 | final public static function renameConnection($old_key, $new_key) { | ||
177 | 1366 | if (empty(self::$databaseInfo)) { | ||
178 | 1367 | self::parseConnectionInfo(); | ||
179 | 1368 | } | ||
180 | 1369 | |||
181 | 1370 | if (!empty(self::$databaseInfo[$old_key]) && empty(self::$databaseInfo[$new_key])) { | ||
182 | 1371 | self::$databaseInfo[$new_key] = self::$databaseInfo[$old_key]; | ||
183 | 1372 | unset(self::$databaseInfo[$old_key]); | ||
184 | 1373 | if (isset(self::$connections[$old_key])) { | ||
185 | 1374 | self::$connections[$new_key] = self::$connections[$old_key]; | ||
186 | 1375 | unset(self::$connections[$old_key]); | ||
187 | 1376 | } | ||
188 | 1377 | } | ||
189 | 1378 | } | ||
190 | 1379 | |||
191 | 1380 | /** | ||
192 | 1381 | * Remove a connection and its corresponding connection information. | ||
193 | 1382 | * | ||
194 | 1383 | * @param $key | ||
195 | 1384 | * The connection key. | ||
196 | 1385 | */ | ||
197 | 1386 | final public static function removeConnection($key) { | ||
198 | 1387 | unset(self::$databaseInfo[$key]); | ||
199 | 1388 | unset(self::$connections[$key]); | ||
200 | 1323 | } | 1389 | } |
201 | 1324 | 1390 | ||
202 | 1325 | /** | 1391 | /** |
203 | @@ -1332,7 +1398,7 @@ | |||
204 | 1332 | * The database target to open. | 1398 | * The database target to open. |
205 | 1333 | */ | 1399 | */ |
206 | 1334 | final protected static function openConnection($key, $target) { | 1400 | final protected static function openConnection($key, $target) { |
208 | 1335 | global $db_prefix; | 1401 | global $databases; |
209 | 1336 | 1402 | ||
210 | 1337 | if (empty(self::$databaseInfo)) { | 1403 | if (empty(self::$databaseInfo)) { |
211 | 1338 | self::parseConnectionInfo(); | 1404 | self::parseConnectionInfo(); |
212 | @@ -1359,12 +1425,29 @@ | |||
213 | 1359 | if (!empty(self::$logs[$key])) { | 1425 | if (!empty(self::$logs[$key])) { |
214 | 1360 | $new_connection->setLogger(self::$logs[$key]); | 1426 | $new_connection->setLogger(self::$logs[$key]); |
215 | 1361 | } | 1427 | } |
216 | 1362 | |||
217 | 1363 | // We need to pass around the simpletest database prefix in the request | 1428 | // We need to pass around the simpletest database prefix in the request |
218 | 1364 | // and we put that in the user_agent header. The header HMAC was already | 1429 | // and we put that in the user_agent header. The header HMAC was already |
219 | 1365 | // validated in bootstrap.inc. | 1430 | // validated in bootstrap.inc. |
220 | 1366 | if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/^(simpletest\d+);/", $_SERVER['HTTP_USER_AGENT'], $matches)) { | 1431 | if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/^(simpletest\d+);/", $_SERVER['HTTP_USER_AGENT'], $matches)) { |
222 | 1367 | $db_prefix .= $matches[1]; | 1432 | $test_prefix = $matches[1]; |
223 | 1433 | drupal_test_info(array('test_run_id' => $test_prefix, 'in_child_site' => TRUE)); | ||
224 | 1434 | foreach ($databases['default'] as $target => $value) { | ||
225 | 1435 | // Extract the current default database prefix. | ||
226 | 1436 | if (empty($value['prefix'])) { | ||
227 | 1437 | $current_prefix = ''; | ||
228 | 1438 | } | ||
229 | 1439 | else if (is_array($value['prefix'])) { | ||
230 | 1440 | $current_prefix = $value['prefix']['default']; | ||
231 | 1441 | } | ||
232 | 1442 | else { | ||
233 | 1443 | $current_prefix = $value['prefix']; | ||
234 | 1444 | } | ||
235 | 1445 | |||
236 | 1446 | // Remove the current database prefix and replace it by our own. | ||
237 | 1447 | $databases['default'][$target]['prefix'] = array( | ||
238 | 1448 | 'default' => $current_prefix . $test_prefix, | ||
239 | 1449 | ); | ||
240 | 1450 | } | ||
241 | 1368 | } | 1451 | } |
242 | 1369 | return $new_connection; | 1452 | return $new_connection; |
243 | 1370 | } | 1453 | } |
244 | 1371 | 1454 | ||
245 | === modified file 'includes/database/mysql/database.inc' | |||
246 | --- includes/database/mysql/database.inc 2009-09-18 00:04:21 +0000 | |||
247 | +++ includes/database/mysql/database.inc 2009-10-13 23:58:11 +0000 | |||
248 | @@ -25,6 +25,8 @@ | |||
249 | 25 | $connection_options['port'] = 3306; | 25 | $connection_options['port'] = 3306; |
250 | 26 | } | 26 | } |
251 | 27 | 27 | ||
252 | 28 | $this->setPrefix(isset($connection_options['prefix']) ? $connection_options['prefix'] : ''); | ||
253 | 29 | |||
254 | 28 | $dsn = 'mysql:host=' . $connection_options['host'] . ';port=' . $connection_options['port'] . ';dbname=' . $connection_options['database']; | 30 | $dsn = 'mysql:host=' . $connection_options['host'] . ';port=' . $connection_options['port'] . ';dbname=' . $connection_options['database']; |
255 | 29 | parent::__construct($dsn, $connection_options['username'], $connection_options['password'], array( | 31 | parent::__construct($dsn, $connection_options['username'], $connection_options['password'], array( |
256 | 30 | // So we don't have to mess around with cursors and unbuffered queries by default. | 32 | // So we don't have to mess around with cursors and unbuffered queries by default. |
257 | 31 | 33 | ||
258 | === modified file 'includes/database/pgsql/database.inc' | |||
259 | --- includes/database/pgsql/database.inc 2009-09-18 00:04:21 +0000 | |||
260 | +++ includes/database/pgsql/database.inc 2009-10-13 23:58:11 +0000 | |||
261 | @@ -26,6 +26,8 @@ | |||
262 | 26 | $connection_options['port'] = 5432; | 26 | $connection_options['port'] = 5432; |
263 | 27 | } | 27 | } |
264 | 28 | 28 | ||
265 | 29 | $this->setPrefix(isset($connection_options['prefix']) ? $connection_options['prefix'] : ''); | ||
266 | 30 | |||
267 | 29 | // PostgreSQL in trust mode doesn't require a password to be supplied. | 31 | // PostgreSQL in trust mode doesn't require a password to be supplied. |
268 | 30 | if (empty($connection_options['password'])) { | 32 | if (empty($connection_options['password'])) { |
269 | 31 | $connection_options['password'] = null; | 33 | $connection_options['password'] = null; |
270 | 32 | 34 | ||
271 | === modified file 'includes/database/sqlite/database.inc' | |||
272 | --- includes/database/sqlite/database.inc 2009-09-18 00:04:21 +0000 | |||
273 | +++ includes/database/sqlite/database.inc 2009-10-13 23:58:11 +0000 | |||
274 | @@ -25,6 +25,8 @@ | |||
275 | 25 | // This driver defaults to transaction support, except if explicitly passed FALSE. | 25 | // This driver defaults to transaction support, except if explicitly passed FALSE. |
276 | 26 | $this->transactionSupport = !isset($connection_options['transactions']) || $connection_options['transactions'] !== FALSE; | 26 | $this->transactionSupport = !isset($connection_options['transactions']) || $connection_options['transactions'] !== FALSE; |
277 | 27 | 27 | ||
278 | 28 | $this->setPrefix(isset($connection_options['prefix']) ? $connection_options['prefix'] : ''); | ||
279 | 29 | |||
280 | 28 | parent::__construct('sqlite:' . $connection_options['database'], '', '', array( | 30 | parent::__construct('sqlite:' . $connection_options['database'], '', '', array( |
281 | 29 | // Force column names to lower case. | 31 | // Force column names to lower case. |
282 | 30 | PDO::ATTR_CASE => PDO::CASE_LOWER, | 32 | PDO::ATTR_CASE => PDO::CASE_LOWER, |
283 | 31 | 33 | ||
284 | === modified file 'install.php' | |||
285 | --- install.php 2009-10-13 14:15:08 +0000 | |||
286 | +++ install.php 2009-10-13 23:58:10 +0000 | |||
287 | @@ -788,7 +788,7 @@ | |||
288 | 788 | * Verify existing settings.php | 788 | * Verify existing settings.php |
289 | 789 | */ | 789 | */ |
290 | 790 | function install_verify_settings() { | 790 | function install_verify_settings() { |
292 | 791 | global $db_prefix, $databases; | 791 | global $databases; |
293 | 792 | 792 | ||
294 | 793 | // Verify existing settings (if any). | 793 | // Verify existing settings (if any). |
295 | 794 | if (!empty($databases)) { | 794 | if (!empty($databases)) { |
296 | @@ -814,7 +814,7 @@ | |||
297 | 814 | * The form API definition for the database configuration form. | 814 | * The form API definition for the database configuration form. |
298 | 815 | */ | 815 | */ |
299 | 816 | function install_settings_form($form, &$form_state, &$install_state) { | 816 | function install_settings_form($form, &$form_state, &$install_state) { |
301 | 817 | global $databases, $db_prefix; | 817 | global $databases; |
302 | 818 | $profile = $install_state['parameters']['profile']; | 818 | $profile = $install_state['parameters']['profile']; |
303 | 819 | $install_locale = $install_state['parameters']['locale']; | 819 | $install_locale = $install_state['parameters']['locale']; |
304 | 820 | 820 | ||
305 | @@ -909,13 +909,13 @@ | |||
306 | 909 | ); | 909 | ); |
307 | 910 | 910 | ||
308 | 911 | // Table prefix | 911 | // Table prefix |
311 | 912 | $db_prefix = ($profile == 'default') ? 'drupal_' : $profile . '_'; | 912 | $prefix = ($profile == 'default') ? 'drupal_' : $profile . '_'; |
312 | 913 | $form['advanced_options']['db_prefix'] = array( | 913 | $form['advanced_options']['prefix'] = array( |
313 | 914 | '#type' => 'textfield', | 914 | '#type' => 'textfield', |
314 | 915 | '#title' => st('Table prefix'), | 915 | '#title' => st('Table prefix'), |
315 | 916 | '#default_value' => '', | 916 | '#default_value' => '', |
316 | 917 | '#size' => 45, | 917 | '#size' => 45, |
318 | 918 | '#description' => st('If more than one application will be sharing this database, enter a table prefix such as %prefix for your @drupal site here.', array('@drupal' => drupal_install_profile_name(), '%prefix' => $db_prefix)), | 918 | '#description' => st('If more than one application will be sharing this database, enter a table prefix such as %prefix for your @drupal site here.', array('@drupal' => drupal_install_profile_name(), '%prefix' => $prefix)), |
319 | 919 | ); | 919 | ); |
320 | 920 | 920 | ||
321 | 921 | $form['save'] = array( | 921 | $form['save'] = array( |
322 | @@ -948,12 +948,12 @@ | |||
323 | 948 | global $databases; | 948 | global $databases; |
324 | 949 | $errors = array(); | 949 | $errors = array(); |
325 | 950 | // Verify the table prefix | 950 | // Verify the table prefix |
328 | 951 | if (!empty($database['db_prefix']) && is_string($database['db_prefix']) && !preg_match('/^[A-Za-z0-9_.]+$/', $database['db_prefix'])) { | 951 | if (!empty($database['prefix']) && is_string($database['prefix']) && !preg_match('/^[A-Za-z0-9_.]+$/', $database['prefix'])) { |
329 | 952 | $errors['db_prefix'] = st('The database table prefix you have entered, %db_prefix, is invalid. The table prefix can only contain alphanumeric characters, periods, or underscores.', array('%db_prefix' => $database['db_prefix'])); | 952 | $errors['prefix'] = st('The database table prefix you have entered, %prefix, is invalid. The table prefix can only contain alphanumeric characters, periods, or underscores.', array('%prefix' => $database['prefix'])); |
330 | 953 | } | 953 | } |
331 | 954 | 954 | ||
332 | 955 | if (!empty($database['port']) && !is_numeric($database['port'])) { | 955 | if (!empty($database['port']) && !is_numeric($database['port'])) { |
334 | 956 | $errors['db_port'] = st('Database port must be a number.'); | 956 | $errors['port'] = st('Database port must be a number.'); |
335 | 957 | } | 957 | } |
336 | 958 | 958 | ||
337 | 959 | // Check database type | 959 | // Check database type |
338 | @@ -989,16 +989,12 @@ | |||
339 | 989 | function install_settings_form_submit($form, &$form_state) { | 989 | function install_settings_form_submit($form, &$form_state) { |
340 | 990 | global $install_state; | 990 | global $install_state; |
341 | 991 | 991 | ||
343 | 992 | $database = array_intersect_key($form_state['values']['_database'], array_flip(array('driver', 'database', 'username', 'password', 'host', 'port'))); | 992 | $database = array_intersect_key($form_state['values']['_database'], array_flip(array('driver', 'database', 'username', 'password', 'host', 'port', 'prefix'))); |
344 | 993 | // Update global settings array and save | 993 | // Update global settings array and save |
345 | 994 | $settings['databases'] = array( | 994 | $settings['databases'] = array( |
346 | 995 | 'value' => array('default' => array('default' => $database)), | 995 | 'value' => array('default' => array('default' => $database)), |
347 | 996 | 'required' => TRUE, | 996 | 'required' => TRUE, |
348 | 997 | ); | 997 | ); |
349 | 998 | $settings['db_prefix'] = array( | ||
350 | 999 | 'value' => $form_state['values']['db_prefix'], | ||
351 | 1000 | 'required' => TRUE, | ||
352 | 1001 | ); | ||
353 | 1002 | drupal_rewrite_settings($settings); | 998 | drupal_rewrite_settings($settings); |
354 | 1003 | // Indicate that the settings file has been verified, and check the database | 999 | // Indicate that the settings file has been verified, and check the database |
355 | 1004 | // for the last completed task, now that we have a valid connection. This | 1000 | // for the last completed task, now that we have a valid connection. This |
356 | 1005 | 1001 | ||
357 | === modified file 'modules/simpletest/drupal_web_test_case.php' | |||
358 | --- modules/simpletest/drupal_web_test_case.php 2009-10-13 07:14:26 +0000 | |||
359 | +++ modules/simpletest/drupal_web_test_case.php 2009-10-13 23:58:11 +0000 | |||
360 | @@ -15,11 +15,11 @@ | |||
361 | 15 | protected $testId; | 15 | protected $testId; |
362 | 16 | 16 | ||
363 | 17 | /** | 17 | /** |
365 | 18 | * The original database prefix, before it was changed for testing purposes. | 18 | * The database prefix of this test run. |
366 | 19 | * | 19 | * |
367 | 20 | * @var string | 20 | * @var string |
368 | 21 | */ | 21 | */ |
370 | 22 | protected $originalPrefix = NULL; | 22 | protected $databasePrefix = NULL; |
371 | 23 | 23 | ||
372 | 24 | /** | 24 | /** |
373 | 25 | * The original file directory, before it was changed for testing purposes. | 25 | * The original file directory, before it was changed for testing purposes. |
374 | @@ -90,8 +90,6 @@ | |||
375 | 90 | * is the caller function itself. | 90 | * is the caller function itself. |
376 | 91 | */ | 91 | */ |
377 | 92 | protected function assert($status, $message = '', $group = 'Other', array $caller = NULL) { | 92 | protected function assert($status, $message = '', $group = 'Other', array $caller = NULL) { |
378 | 93 | global $db_prefix; | ||
379 | 94 | |||
380 | 95 | // Convert boolean status to string status. | 93 | // Convert boolean status to string status. |
381 | 96 | if (is_bool($status)) { | 94 | if (is_bool($status)) { |
382 | 97 | $status = $status ? 'pass' : 'fail'; | 95 | $status = $status ? 'pass' : 'fail'; |
383 | @@ -105,10 +103,6 @@ | |||
384 | 105 | $caller = $this->getAssertionCall(); | 103 | $caller = $this->getAssertionCall(); |
385 | 106 | } | 104 | } |
386 | 107 | 105 | ||
387 | 108 | // Switch to non-testing database to store results in. | ||
388 | 109 | $current_db_prefix = $db_prefix; | ||
389 | 110 | $db_prefix = $this->originalPrefix; | ||
390 | 111 | |||
391 | 112 | // Creation assertion array that can be displayed while tests are running. | 106 | // Creation assertion array that can be displayed while tests are running. |
392 | 113 | $this->assertions[] = $assertion = array( | 107 | $this->assertions[] = $assertion = array( |
393 | 114 | 'test_id' => $this->testId, | 108 | 'test_id' => $this->testId, |
394 | @@ -122,12 +116,11 @@ | |||
395 | 122 | ); | 116 | ); |
396 | 123 | 117 | ||
397 | 124 | // Store assertion for display after the test has completed. | 118 | // Store assertion for display after the test has completed. |
399 | 125 | db_insert('simpletest') | 119 | Database::getConnection('default', 'simpletest_original_default') |
400 | 120 | ->insert('simpletest') | ||
401 | 126 | ->fields($assertion) | 121 | ->fields($assertion) |
402 | 127 | ->execute(); | 122 | ->execute(); |
403 | 128 | 123 | ||
404 | 129 | // Return to testing prefix. | ||
405 | 130 | $db_prefix = $current_db_prefix; | ||
406 | 131 | // We do not use a ternary operator here to allow a breakpoint on | 124 | // We do not use a ternary operator here to allow a breakpoint on |
407 | 132 | // test failure. | 125 | // test failure. |
408 | 133 | if ($status == 'pass') { | 126 | if ($status == 'pass') { |
409 | @@ -473,18 +466,18 @@ | |||
410 | 473 | * is not restricted. | 466 | * is not restricted. |
411 | 474 | * | 467 | * |
412 | 475 | * @param $length | 468 | * @param $length |
414 | 476 | * Length of random string to generate which will be appended to $db_prefix. | 469 | * Length of random string to generate which will be appended to $test_info['test_run_id']. |
415 | 477 | * @return | 470 | * @return |
416 | 478 | * Randomly generated string. | 471 | * Randomly generated string. |
417 | 479 | */ | 472 | */ |
418 | 480 | public static function randomString($length = 8) { | 473 | public static function randomString($length = 8) { |
419 | 481 | global $db_prefix; | ||
420 | 482 | |||
421 | 483 | $str = ''; | 474 | $str = ''; |
422 | 484 | for ($i = 0; $i < $length; $i++) { | 475 | for ($i = 0; $i < $length; $i++) { |
423 | 485 | $str .= chr(mt_rand(32, 126)); | 476 | $str .= chr(mt_rand(32, 126)); |
424 | 486 | } | 477 | } |
426 | 487 | return str_replace('simpletest', 's', $db_prefix) . $str; | 478 | |
427 | 479 | $test_info = drupal_test_info(); | ||
428 | 480 | return str_replace('simpletest', 's', $test_info['test_run_id']) . $str; | ||
429 | 488 | } | 481 | } |
430 | 489 | 482 | ||
431 | 490 | /** | 483 | /** |
432 | @@ -496,20 +489,19 @@ | |||
433 | 496 | * spaces and non-standard characters) this method is best. | 489 | * spaces and non-standard characters) this method is best. |
434 | 497 | * | 490 | * |
435 | 498 | * @param $length | 491 | * @param $length |
437 | 499 | * Length of random string to generate which will be appended to $db_prefix. | 492 | * Length of random string to generate which will be appended to $test_info['test_run_id']. |
438 | 500 | * @return | 493 | * @return |
439 | 501 | * Randomly generated string. | 494 | * Randomly generated string. |
440 | 502 | */ | 495 | */ |
441 | 503 | public static function randomName($length = 8) { | 496 | public static function randomName($length = 8) { |
442 | 504 | global $db_prefix; | ||
443 | 505 | |||
444 | 506 | $values = array_merge(range(65, 90), range(97, 122), range(48, 57)); | 497 | $values = array_merge(range(65, 90), range(97, 122), range(48, 57)); |
445 | 507 | $max = count($values) - 1; | 498 | $max = count($values) - 1; |
446 | 508 | $str = ''; | 499 | $str = ''; |
447 | 509 | for ($i = 0; $i < $length; $i++) { | 500 | for ($i = 0; $i < $length; $i++) { |
448 | 510 | $str .= chr($values[mt_rand(0, $max)]); | 501 | $str .= chr($values[mt_rand(0, $max)]); |
449 | 511 | } | 502 | } |
451 | 512 | return str_replace('simpletest', 's', $db_prefix) . $str; | 503 | $test_info = drupal_test_info(); |
452 | 504 | return str_replace('simpletest', 's', $test_info['test_run_id']) . $str; | ||
453 | 513 | } | 505 | } |
454 | 514 | 506 | ||
455 | 515 | } | 507 | } |
456 | @@ -533,15 +525,14 @@ | |||
457 | 533 | } | 525 | } |
458 | 534 | 526 | ||
459 | 535 | function setUp() { | 527 | function setUp() { |
461 | 536 | global $db_prefix, $conf; | 528 | global $conf; |
462 | 537 | 529 | ||
463 | 538 | // Store necessary current values before switching to prefixed database. | 530 | // Store necessary current values before switching to prefixed database. |
464 | 539 | $this->originalPrefix = $db_prefix; | ||
465 | 540 | $this->originalFileDirectory = file_directory_path(); | 531 | $this->originalFileDirectory = file_directory_path(); |
466 | 541 | 532 | ||
467 | 542 | // Generate temporary prefixed database to ensure that tests have a clean starting point. | 533 | // Generate temporary prefixed database to ensure that tests have a clean starting point. |
470 | 543 | $db_prefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}'); | 534 | $this->databasePrefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}'); |
471 | 544 | $conf['file_public_path'] = $this->originalFileDirectory . '/' . $db_prefix; | 535 | $conf['file_public_path'] = $this->originalFileDirectory . '/' . $this->databasePrefix; |
472 | 545 | 536 | ||
473 | 546 | // If locale is enabled then t() will try to access the database and | 537 | // If locale is enabled then t() will try to access the database and |
474 | 547 | // subsequently will fail as the database is not accessible. | 538 | // subsequently will fail as the database is not accessible. |
475 | @@ -554,11 +545,10 @@ | |||
476 | 554 | } | 545 | } |
477 | 555 | 546 | ||
478 | 556 | function tearDown() { | 547 | function tearDown() { |
481 | 557 | global $db_prefix, $conf; | 548 | global $conf; |
482 | 558 | if (preg_match('/simpletest\d+/', $db_prefix)) { | 549 | |
483 | 550 | if (preg_match('/simpletest\d+/', $this->databasePrefix)) { | ||
484 | 559 | $conf['file_public_path'] = $this->originalFileDirectory; | 551 | $conf['file_public_path'] = $this->originalFileDirectory; |
485 | 560 | // Return the database prefix to the original. | ||
486 | 561 | $db_prefix = $this->originalPrefix; | ||
487 | 562 | // Restore modules if necessary. | 552 | // Restore modules if necessary. |
488 | 563 | if (isset($this->originalModuleList)) { | 553 | if (isset($this->originalModuleList)) { |
489 | 564 | module_list(TRUE, FALSE, FALSE, $this->originalModuleList); | 554 | module_list(TRUE, FALSE, FALSE, $this->originalModuleList); |
490 | @@ -1025,27 +1015,34 @@ | |||
491 | 1025 | * List of modules to enable for the duration of the test. | 1015 | * List of modules to enable for the duration of the test. |
492 | 1026 | */ | 1016 | */ |
493 | 1027 | protected function setUp() { | 1017 | protected function setUp() { |
495 | 1028 | global $db_prefix, $user, $language; | 1018 | global $user, $language; |
496 | 1019 | |||
497 | 1020 | // Generate a temporary prefixed database to ensure that tests have a clean starting point. | ||
498 | 1021 | $this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000); | ||
499 | 1022 | |||
500 | 1023 | // Clone the current connection and replace the current prefix. | ||
501 | 1024 | $connection_info = Database::getConnectionInfo('default'); | ||
502 | 1025 | Database::renameConnection('default', 'simpletest_original_default'); | ||
503 | 1026 | foreach ($connection_info as $target => $value) { | ||
504 | 1027 | $connection_info[$target]['prefix'] = array( | ||
505 | 1028 | 'default' => $value['prefix']['default'] . $this->databasePrefix, | ||
506 | 1029 | ); | ||
507 | 1030 | } | ||
508 | 1031 | Database::addConnectionInfo('default', 'default', $connection_info['default']); | ||
509 | 1029 | 1032 | ||
510 | 1030 | // Store necessary current values before switching to prefixed database. | 1033 | // Store necessary current values before switching to prefixed database. |
511 | 1031 | $this->originalLanguage = $language; | 1034 | $this->originalLanguage = $language; |
512 | 1032 | $this->originalLanguageDefault = variable_get('language_default'); | 1035 | $this->originalLanguageDefault = variable_get('language_default'); |
513 | 1033 | $this->originalPrefix = $db_prefix; | ||
514 | 1034 | $this->originalFileDirectory = file_directory_path(); | 1036 | $this->originalFileDirectory = file_directory_path(); |
515 | 1035 | $this->originalProfile = drupal_get_profile(); | 1037 | $this->originalProfile = drupal_get_profile(); |
516 | 1036 | $clean_url_original = variable_get('clean_url', 0); | 1038 | $clean_url_original = variable_get('clean_url', 0); |
517 | 1037 | 1039 | ||
525 | 1038 | // Generate temporary prefixed database to ensure that tests have a clean starting point. | 1040 | // Set the simpletest id for use in other parts of Drupal. |
526 | 1039 | $db_prefix_new = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}'); | 1041 | drupal_test_info(array('test_run_id' => $this->databasePrefix, 'in_child_site' => FALSE)); |
520 | 1040 | db_update('simpletest_test_id') | ||
521 | 1041 | ->fields(array('last_prefix' => $db_prefix_new)) | ||
522 | 1042 | ->condition('test_id', $this->testId) | ||
523 | 1043 | ->execute(); | ||
524 | 1044 | $db_prefix = $db_prefix_new; | ||
527 | 1045 | 1042 | ||
528 | 1046 | // Create test directory ahead of installation so fatal errors and debug | 1043 | // Create test directory ahead of installation so fatal errors and debug |
529 | 1047 | // information can be logged during installation process. | 1044 | // information can be logged during installation process. |
531 | 1048 | $directory = $this->originalFileDirectory . '/simpletest/' . substr($db_prefix, 10); | 1045 | $directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10); |
532 | 1049 | file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); | 1046 | file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); |
533 | 1050 | 1047 | ||
534 | 1051 | // Log fatal errors. | 1048 | // Log fatal errors. |
535 | @@ -1109,7 +1106,7 @@ | |||
536 | 1109 | variable_set('mail_sending_system', array('default-system' => 'TestingMailSystem')); | 1106 | variable_set('mail_sending_system', array('default-system' => 'TestingMailSystem')); |
537 | 1110 | 1107 | ||
538 | 1111 | // Use temporary files directory with the same prefix as the database. | 1108 | // Use temporary files directory with the same prefix as the database. |
540 | 1112 | $public_files_directory = $this->originalFileDirectory . '/' . $db_prefix; | 1109 | $public_files_directory = $this->originalFileDirectory . '/' . $this->databasePrefix; |
541 | 1113 | $private_files_directory = $public_files_directory . '/private'; | 1110 | $private_files_directory = $public_files_directory . '/private'; |
542 | 1114 | 1111 | ||
543 | 1115 | // Set path variables | 1112 | // Set path variables |
544 | @@ -1130,8 +1127,10 @@ | |||
545 | 1130 | * setup a clean environment for the current test run. | 1127 | * setup a clean environment for the current test run. |
546 | 1131 | */ | 1128 | */ |
547 | 1132 | protected function preloadRegistry() { | 1129 | protected function preloadRegistry() { |
550 | 1133 | db_query('INSERT INTO {registry} SELECT * FROM ' . $this->originalPrefix . 'registry'); | 1130 | $original_connection = Database::getConnection('default', 'simpletest_original_default'); |
551 | 1134 | db_query('INSERT INTO {registry_file} SELECT * FROM ' . $this->originalPrefix . 'registry_file'); | 1131 | $this->pass('INSERT INTO {registry} SELECT * FROM ' . $original_connection->prefixTables('{registry}')); |
552 | 1132 | db_query('INSERT INTO {registry} SELECT * FROM ' . $original_connection->prefixTables('{registry}')); | ||
553 | 1133 | db_query('INSERT INTO {registry_file} SELECT * FROM ' . $original_connection->prefixTables('{registry_file}')); | ||
554 | 1135 | } | 1134 | } |
555 | 1136 | 1135 | ||
556 | 1137 | /** | 1136 | /** |
557 | @@ -1157,14 +1156,9 @@ | |||
558 | 1157 | * and reset the database prefix. | 1156 | * and reset the database prefix. |
559 | 1158 | */ | 1157 | */ |
560 | 1159 | protected function tearDown() { | 1158 | protected function tearDown() { |
562 | 1160 | global $db_prefix, $user, $language; | 1159 | global $user, $language; |
563 | 1161 | 1160 | ||
570 | 1162 | // In case a fatal error occured that was not in the test process read the | 1161 | simpletest_log_read($this->testId, $this->databasePrefix, get_class($this), TRUE); |
565 | 1163 | // log to pick up any fatal errors. | ||
566 | 1164 | $db_prefix_temp = $db_prefix; | ||
567 | 1165 | $db_prefix = $this->originalPrefix; | ||
568 | 1166 | simpletest_log_read($this->testId, $db_prefix, get_class($this), TRUE); | ||
569 | 1167 | $db_prefix = $db_prefix_temp; | ||
571 | 1168 | 1162 | ||
572 | 1169 | $emailCount = count(variable_get('drupal_test_email_collector', array())); | 1163 | $emailCount = count(variable_get('drupal_test_email_collector', array())); |
573 | 1170 | if ($emailCount) { | 1164 | if ($emailCount) { |
574 | @@ -1172,48 +1166,47 @@ | |||
575 | 1172 | $this->pass($message, t('E-mail')); | 1166 | $this->pass($message, t('E-mail')); |
576 | 1173 | } | 1167 | } |
577 | 1174 | 1168 | ||
620 | 1175 | if (preg_match('/simpletest\d+/', $db_prefix)) { | 1169 | // Delete temporary files directory. |
621 | 1176 | // Delete temporary files directory. | 1170 | file_unmanaged_delete_recursive(file_directory_path()); |
622 | 1177 | file_unmanaged_delete_recursive(file_directory_path()); | 1171 | |
623 | 1178 | 1172 | // Remove all prefixed tables (all the tables in the schema). | |
624 | 1179 | // Remove all prefixed tables (all the tables in the schema). | 1173 | $schema = drupal_get_schema(NULL, TRUE); |
625 | 1180 | $schema = drupal_get_schema(NULL, TRUE); | 1174 | $ret = array(); |
626 | 1181 | $ret = array(); | 1175 | foreach ($schema as $name => $table) { |
627 | 1182 | foreach ($schema as $name => $table) { | 1176 | db_drop_table($name); |
628 | 1183 | db_drop_table($name); | 1177 | } |
629 | 1184 | } | 1178 | |
630 | 1185 | 1179 | // Get back to the original connection. | |
631 | 1186 | // Return the database prefix to the original. | 1180 | Database::removeConnection('default'); |
632 | 1187 | $db_prefix = $this->originalPrefix; | 1181 | Database::renameConnection('simpletest_original_default', 'default'); |
633 | 1188 | 1182 | ||
634 | 1189 | // Return the user to the original one. | 1183 | // Return the user to the original one. |
635 | 1190 | $user = $this->originalUser; | 1184 | $user = $this->originalUser; |
636 | 1191 | drupal_save_session(TRUE); | 1185 | drupal_save_session(TRUE); |
637 | 1192 | 1186 | ||
638 | 1193 | // Ensure that internal logged in variable and cURL options are reset. | 1187 | // Ensure that internal logged in variable and cURL options are reset. |
639 | 1194 | $this->loggedInUser = FALSE; | 1188 | $this->isLoggedIn = FALSE; |
640 | 1195 | $this->additionalCurlOptions = array(); | 1189 | $this->additionalCurlOptions = array(); |
641 | 1196 | 1190 | ||
642 | 1197 | // Reload module list and implementations to ensure that test module hooks | 1191 | // Reload module list and implementations to ensure that test module hooks |
643 | 1198 | // aren't called after tests. | 1192 | // aren't called after tests. |
644 | 1199 | module_list(TRUE); | 1193 | module_list(TRUE); |
645 | 1200 | module_implements('', FALSE, TRUE); | 1194 | module_implements('', FALSE, TRUE); |
646 | 1201 | 1195 | ||
647 | 1202 | // Reset the Field API. | 1196 | // Reset the Field API. |
648 | 1203 | field_cache_clear(); | 1197 | field_cache_clear(); |
649 | 1204 | 1198 | ||
650 | 1205 | // Rebuild caches. | 1199 | // Rebuild caches. |
651 | 1206 | $this->refreshVariables(); | 1200 | $this->refreshVariables(); |
652 | 1207 | 1201 | ||
653 | 1208 | // Reset language. | 1202 | // Reset language. |
654 | 1209 | $language = $this->originalLanguage; | 1203 | $language = $this->originalLanguage; |
655 | 1210 | if ($this->originalLanguageDefault) { | 1204 | if ($this->originalLanguageDefault) { |
656 | 1211 | $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault; | 1205 | $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault; |
657 | 1212 | } | 1206 | } |
658 | 1213 | 1207 | ||
659 | 1214 | // Close the CURL handler. | 1208 | // Close the CURL handler. |
660 | 1215 | $this->curlClose(); | 1209 | $this->curlClose(); |
619 | 1216 | } | ||
661 | 1217 | } | 1210 | } |
662 | 1218 | 1211 | ||
663 | 1219 | /** | 1212 | /** |
664 | @@ -1225,7 +1218,7 @@ | |||
665 | 1225 | * See the description of $curl_options for other options. | 1218 | * See the description of $curl_options for other options. |
666 | 1226 | */ | 1219 | */ |
667 | 1227 | protected function curlInitialize() { | 1220 | protected function curlInitialize() { |
669 | 1228 | global $base_url, $db_prefix; | 1221 | global $base_url; |
670 | 1229 | 1222 | ||
671 | 1230 | if (!isset($this->curlHandle)) { | 1223 | if (!isset($this->curlHandle)) { |
672 | 1231 | $this->curlHandle = curl_init(); | 1224 | $this->curlHandle = curl_init(); |
673 | @@ -1238,6 +1231,7 @@ | |||
674 | 1238 | CURLOPT_SSL_VERIFYPEER => FALSE, // Required to make the tests run on https. | 1231 | CURLOPT_SSL_VERIFYPEER => FALSE, // Required to make the tests run on https. |
675 | 1239 | CURLOPT_SSL_VERIFYHOST => FALSE, // Required to make the tests run on https. | 1232 | CURLOPT_SSL_VERIFYHOST => FALSE, // Required to make the tests run on https. |
676 | 1240 | CURLOPT_HEADERFUNCTION => array(&$this, 'curlHeaderCallback'), | 1233 | CURLOPT_HEADERFUNCTION => array(&$this, 'curlHeaderCallback'), |
677 | 1234 | CURLOPT_USERAGENT => $this->databasePrefix, | ||
678 | 1241 | ); | 1235 | ); |
679 | 1242 | if (isset($this->httpauth_credentials)) { | 1236 | if (isset($this->httpauth_credentials)) { |
680 | 1243 | $curl_options[CURLOPT_USERPWD] = $this->httpauth_credentials; | 1237 | $curl_options[CURLOPT_USERPWD] = $this->httpauth_credentials; |
681 | @@ -1249,7 +1243,7 @@ | |||
682 | 1249 | } | 1243 | } |
683 | 1250 | // We set the user agent header on each request so as to use the current | 1244 | // We set the user agent header on each request so as to use the current |
684 | 1251 | // time and a new uniqid. | 1245 | // time and a new uniqid. |
686 | 1252 | if (preg_match('/simpletest\d+/', $db_prefix, $matches)) { | 1246 | if (preg_match('/simpletest\d+/', $this->databasePrefix, $matches)) { |
687 | 1253 | curl_setopt($this->curlHandle, CURLOPT_USERAGENT, drupal_generate_test_ua($matches[0])); | 1247 | curl_setopt($this->curlHandle, CURLOPT_USERAGENT, drupal_generate_test_ua($matches[0])); |
688 | 1254 | } | 1248 | } |
689 | 1255 | } | 1249 | } |
690 | @@ -1692,7 +1686,7 @@ | |||
691 | 1692 | protected function xpath($xpath) { | 1686 | protected function xpath($xpath) { |
692 | 1693 | if ($this->parse()) { | 1687 | if ($this->parse()) { |
693 | 1694 | return $this->elements->xpath($xpath); | 1688 | return $this->elements->xpath($xpath); |
695 | 1695 | } | 1689 | } |
696 | 1696 | return FALSE; | 1690 | return FALSE; |
697 | 1697 | } | 1691 | } |
698 | 1698 | 1692 | ||
699 | 1699 | 1693 | ||
700 | === modified file 'modules/simpletest/simpletest.module' | |||
701 | --- modules/simpletest/simpletest.module 2009-10-09 00:59:53 +0000 | |||
702 | +++ modules/simpletest/simpletest.module 2009-10-13 23:58:11 +0000 | |||
703 | @@ -414,16 +414,18 @@ | |||
704 | 414 | function simpletest_clean_database() { | 414 | function simpletest_clean_database() { |
705 | 415 | $tables = db_find_tables(Database::getConnection()->prefixTables('{simpletest}') . '%'); | 415 | $tables = db_find_tables(Database::getConnection()->prefixTables('{simpletest}') . '%'); |
706 | 416 | $schema = drupal_get_schema_unprocessed('simpletest'); | 416 | $schema = drupal_get_schema_unprocessed('simpletest'); |
707 | 417 | $removed = 0; | ||
708 | 417 | foreach (array_diff_key($tables, $schema) as $table) { | 418 | foreach (array_diff_key($tables, $schema) as $table) { |
709 | 418 | // Strip the prefix and skip tables without digits following "simpletest", | 419 | // Strip the prefix and skip tables without digits following "simpletest", |
710 | 419 | // e.g. {simpletest_test_id}. | 420 | // e.g. {simpletest_test_id}. |
711 | 420 | if (preg_match('/simpletest\d+.*/', $table, $matches)) { | 421 | if (preg_match('/simpletest\d+.*/', $table, $matches)) { |
712 | 421 | db_drop_table($matches[0]); | 422 | db_drop_table($matches[0]); |
713 | 423 | ++$removed; | ||
714 | 422 | } | 424 | } |
715 | 423 | } | 425 | } |
716 | 424 | 426 | ||
719 | 425 | if (count($ret) > 0) { | 427 | if (count($removed) > 0) { |
720 | 426 | drupal_set_message(format_plural(count($ret), 'Removed 1 leftover table.', 'Removed @count leftover tables.')); | 428 | drupal_set_message(format_plural(count($removed), 'Removed 1 leftover table.', 'Removed @count leftover tables.')); |
721 | 427 | } | 429 | } |
722 | 428 | else { | 430 | else { |
723 | 429 | drupal_set_message(t('No leftover tables to remove.')); | 431 | drupal_set_message(t('No leftover tables to remove.')); |
724 | 430 | 432 | ||
725 | === modified file 'sites/default/default.settings.php' | |||
726 | --- sites/default/default.settings.php 2009-10-09 07:48:06 +0000 | |||
727 | +++ sites/default/default.settings.php 2009-10-13 23:58:11 +0000 | |||
728 | @@ -61,6 +61,7 @@ | |||
729 | 61 | * 'password' => 'password', | 61 | * 'password' => 'password', |
730 | 62 | * 'host' => 'localhost', | 62 | * 'host' => 'localhost', |
731 | 63 | * 'port' => 3306, | 63 | * 'port' => 3306, |
732 | 64 | * 'prefix' => 'myprefix_', | ||
733 | 64 | * ); | 65 | * ); |
734 | 65 | * | 66 | * |
735 | 66 | * The "driver" property indicates what Drupal database driver the | 67 | * The "driver" property indicates what Drupal database driver the |
736 | @@ -105,30 +106,31 @@ | |||
737 | 105 | * 'username' => 'username', | 106 | * 'username' => 'username', |
738 | 106 | * 'password' => 'password', | 107 | * 'password' => 'password', |
739 | 107 | * 'host' => 'localhost', | 108 | * 'host' => 'localhost', |
740 | 109 | * 'prefix' => 'main_', | ||
741 | 108 | * ); | 110 | * ); |
742 | 109 | * | 111 | * |
743 | 110 | * You can optionally set prefixes for some or all database table names | 112 | * You can optionally set prefixes for some or all database table names |
745 | 111 | * by using the $db_prefix setting. If a prefix is specified, the table | 113 | * by using the 'prefix' setting. If a prefix is specified, the table |
746 | 112 | * name will be prepended with its value. Be sure to use valid database | 114 | * name will be prepended with its value. Be sure to use valid database |
747 | 113 | * characters only, usually alphanumeric and underscore. If no prefixes | 115 | * characters only, usually alphanumeric and underscore. If no prefixes |
748 | 114 | * are desired, leave it as an empty string ''. | 116 | * are desired, leave it as an empty string ''. |
749 | 115 | * | 117 | * |
755 | 116 | * To have all database names prefixed, set $db_prefix as a string: | 118 | * To have all database names prefixed, set 'prefix' as a string: |
756 | 117 | * | 119 | * |
757 | 118 | * $db_prefix = 'main_'; | 120 | * 'prefix' => 'main_', |
758 | 119 | * | 121 | * |
759 | 120 | * To provide prefixes for specific tables, set $db_prefix as an array. | 122 | * To provide prefixes for specific tables, set 'prefix' as an array. |
760 | 121 | * The array's keys are the table names and the values are the prefixes. | 123 | * The array's keys are the table names and the values are the prefixes. |
763 | 122 | * The 'default' element holds the prefix for any tables not specified | 124 | * The 'default' element is mandatory and holds the prefix for any tables |
764 | 123 | * elsewhere in the array. Example: | 125 | * not specified elsewhere in the array. Example: |
765 | 124 | * | 126 | * |
767 | 125 | * $db_prefix = array( | 127 | * 'prefix' = array( |
768 | 126 | * 'default' => 'main_', | 128 | * 'default' => 'main_', |
769 | 127 | * 'users' => 'shared_', | 129 | * 'users' => 'shared_', |
770 | 128 | * 'sessions' => 'shared_', | 130 | * 'sessions' => 'shared_', |
771 | 129 | * 'role' => 'shared_', | 131 | * 'role' => 'shared_', |
772 | 130 | * 'authmap' => 'shared_', | 132 | * 'authmap' => 'shared_', |
774 | 131 | * ); | 133 | * ), |
775 | 132 | * | 134 | * |
776 | 133 | * Database configuration format: | 135 | * Database configuration format: |
777 | 134 | * $databases['default']['default'] = array( | 136 | * $databases['default']['default'] = array( |
778 | @@ -137,6 +139,7 @@ | |||
779 | 137 | * 'username' => 'username', | 139 | * 'username' => 'username', |
780 | 138 | * 'password' => 'password', | 140 | * 'password' => 'password', |
781 | 139 | * 'host' => 'localhost', | 141 | * 'host' => 'localhost', |
782 | 142 | * 'prefix' => '', | ||
783 | 140 | * ); | 143 | * ); |
784 | 141 | * $databases['default']['default'] = array( | 144 | * $databases['default']['default'] = array( |
785 | 142 | * 'driver' => 'pgsql', | 145 | * 'driver' => 'pgsql', |
786 | @@ -144,6 +147,7 @@ | |||
787 | 144 | * 'username' => 'username', | 147 | * 'username' => 'username', |
788 | 145 | * 'password' => 'password', | 148 | * 'password' => 'password', |
789 | 146 | * 'host' => 'localhost', | 149 | * 'host' => 'localhost', |
790 | 150 | * 'prefix' => '', | ||
791 | 147 | * ); | 151 | * ); |
792 | 148 | * $databases['default']['default'] = array( | 152 | * $databases['default']['default'] = array( |
793 | 149 | * 'driver' => 'sqlite', | 153 | * 'driver' => 'sqlite', |
794 | @@ -151,7 +155,6 @@ | |||
795 | 151 | * ); | 155 | * ); |
796 | 152 | */ | 156 | */ |
797 | 153 | $databases = array(); | 157 | $databases = array(); |
798 | 154 | $db_prefix = ''; | ||
799 | 155 | 158 | ||
800 | 156 | /** | 159 | /** |
801 | 157 | * Access control for update.php script | 160 | * Access control for update.php script |