diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-08-21 19:36:39 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-08-21 19:36:39 +0000 |
commit | 69e6f411a9ed5dcf3f71d4320218620d3444d295 (patch) | |
tree | f4d393bbda7d814c825878785221b65c73b225f8 /modules/dblog | |
parent | 0e79597812ad0b6b72cf65bfc928c4a591d80ff1 (diff) | |
download | brdo-69e6f411a9ed5dcf3f71d4320218620d3444d295.tar.gz brdo-69e6f411a9ed5dcf3f71d4320218620d3444d295.tar.bz2 |
- Patch #225450 by Crell, chx, bjaspan, catch, swentel, recidive et al: next generation database layer for Drupal 7.
Diffstat (limited to 'modules/dblog')
-rw-r--r-- | modules/dblog/dblog.install | 14 | ||||
-rw-r--r-- | modules/dblog/dblog.module | 3 | ||||
-rw-r--r-- | modules/dblog/dblog.test | 13 |
3 files changed, 24 insertions, 6 deletions
diff --git a/modules/dblog/dblog.install b/modules/dblog/dblog.install index 8c1b6af64..ca9107c8f 100644 --- a/modules/dblog/dblog.install +++ b/modules/dblog/dblog.install @@ -65,7 +65,7 @@ function dblog_schema() { 'link' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, + 'not null' => FALSE, 'default' => '', 'description' => t('Link to view the result of the event.'), ), @@ -77,7 +77,7 @@ function dblog_schema() { 'referer' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, + 'not null' => FALSE, 'default' => '', 'description' => t('URL of referring page.'), ), @@ -103,3 +103,13 @@ function dblog_schema() { return $schema; } + +/** + * Allow NULL values for links. + */ +function dblog_update_7001() { + $ret = array(); + db_change_field($ret, 'watchdog', 'link', 'link', array('type' => 'varchar', 'length' => 255, 'not null' => FALSE, 'default' => '')); + db_change_field($ret, 'watchdog', 'referer', 'referer', array('type' => 'varchar', 'length' => 255, 'not null' => FALSE, 'default' => '')); + return $ret; +} diff --git a/modules/dblog/dblog.module b/modules/dblog/dblog.module index d4791b5a8..4fb41b0f5 100644 --- a/modules/dblog/dblog.module +++ b/modules/dblog/dblog.module @@ -135,7 +135,8 @@ function dblog_watchdog($log = array()) { $log['request_uri'], $log['referer'], $log['ip'], - $log['timestamp']); + $log['timestamp'] + ); if ($current_db) { db_set_active($current_db); diff --git a/modules/dblog/dblog.test b/modules/dblog/dblog.test index 8fa75e4da..258e46601 100644 --- a/modules/dblog/dblog.test +++ b/modules/dblog/dblog.test @@ -210,11 +210,18 @@ class DBLogTestCase extends DrupalWebTestCase { // Count rows that have uids for the user. $count = db_result(db_query('SELECT COUNT(wid) FROM {watchdog} WHERE uid = %d', $user->uid)); $this->assertTrue($count == 0, t('DBLog contains @count records for @name', array('@count' => $count, '@name' => $user->name))); + // Fetch row ids in watchdog that previously related to the deleted user. - $result = db_query('SELECT wid FROM {watchdog} WHERE uid = 0 AND wid IN (%s)', implode(', ', $ids)); + $select = db_select('watchdog'); + $select->addField('watchdog', 'wid'); + $select->condition('uid', 0); + if ($ids) { + $select->condition('wid', $ids, 'IN'); + } + $result = $select->execute(); unset($ids); - while ($row = db_fetch_array($result)) { - $ids[] = $row['wid']; + foreach ($result as $row) { + $ids[] = $row->wid; } $count_after = (isset($ids)) ? count($ids) : 0; $this->assertTrue($count_after == $count_before, t('DBLog contains @count records for @name that now have uid = 0', array('@count' => $count_before, '@name' => $user->name))); |