Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Crell’s picture

It's somewhat more than a week... :-) Are you still working on this, or should someone else jump in?

R.Muilwijk’s picture

Sorry, I'll put in on top of my list for next thursday. We have open source thursday at our company so should have plenty of time then.

Crell’s picture

Assigned: R.Muilwijk » Unassigned
Issue tags: +DBTNG Conversion, +dc2009 code sprint

This is open for anyone who wants it.

Dave Reid’s picture

Title: DBTNG: dblog » DBTNG dblog.module
Component: database system » dblog.module
tizzo’s picture

Assigned: Unassigned » tizzo

Working on this now!

Ryan Palmer’s picture

FileSize
2.12 KB

Also working on this atm. Can somebody give me a quick sanity check to see if I'm doing this right? tx!

Dave Reid’s picture

Status: Active » Needs work

$max = db_query('SELECT MAX(wid) FROM {watchdog}')->fetchObject();
should use ->fetchResult();

Ryan Palmer’s picture

FileSize
2.14 KB

Noticed that just after I submitted it... otherwise ok? (rerolled)

Ryan Palmer’s picture

Status: Needs work » Needs review
Dave Reid’s picture

foreach ($results AS $object) {
should just be lowercase 'as' :)

Other than that, it looks ok. I don't have anything to test that it actually works, but I guess the testbot can help us there.

Status: Needs review » Needs work

The last submitted patch failed testing.

Ryan Palmer’s picture

Status: Needs work » Needs review
FileSize
2.14 KB

Oh really! I've been doing it wrong all this time!

Thanks for the help.

Ryan Palmer’s picture

Assigned: tizzo » Ryan Palmer
FileSize
2.09 KB

Looks like it failed.. not sure why. Try this once more.

tizzo’s picture

Assigned: Ryan Palmer » Unassigned
FileSize
1.69 KB

[Edit] Sorry, hadn't refreshed the page in a while. I think my patch applies and all tests pass. Big frown on duplicate work but I guess we'll all get a little more experience with DBTNG!

[Edit Edit] Durp! Also I missed the admin.inc, oh well! Hopefully your patch works!

Status: Needs review » Needs work

The last submitted patch failed testing.

tizzo’s picture

Status: Needs work » Needs review
FileSize
3.37 KB

Fixed up a few other things in admin.inc, I do think everything is done and working now. All pretty straightforward stuff, switched all of the while loops to foreach.

[Edit - I found a problem with my setup that caused that fail, I also realized that none of us have updated the test. Working on that now]

Status: Needs review » Needs work

The last submitted patch failed testing.

tizzo’s picture

Status: Needs work » Needs review
FileSize
7.64 KB

Ok, I think I have this working. Really this time.

Went through the test file and updated that as well as fixing my previous issue (and typos that accompanied it).

Crell’s picture

Status: Needs review » Needs work
+    $result = db_query('SELECT wid FROM {watchdog} WHERE uid = :uid', array(':uid' => $user->uid));
+    foreach($result as $row) {
+      $ids[] = $row->wid;

The foreach block can be replaced with $ides = db_query()->fetchCol(); I believe that appears twice.

   $result = db_query('SELECT DISTINCT(type) FROM {watchdog} ORDER BY type');
-  while ($object = db_fetch_object($result)) {
+  foreach ($result as $object) {
     $types[] = $object->type;
   }

This can also be condensed into just fetchCol().

And of course there's still a pager query.

phoolish’s picture

Title: DBTNG dblog.module » DBTNG dblog.admin.inc
Status: Needs work » Needs review
FileSize
3.09 KB

Here is the dblog.admin.inc Still having issues with setHeader and setCountQuery, but simpletest seems to pass.

tizzo’s picture

Assigned: Unassigned » tizzo
Status: Needs review » Needs work

I'll roll this patch into the one I'm repairing as per Crell's comments above.

tizzo’s picture

Assigned: tizzo » Unassigned
Status: Needs work » Needs review
FileSize
10.78 KB

Sorry for the delay! Patch re-rolled with bubbasan's patch and Crell's comments above implemented. Hopefully this works!

tizzo’s picture

FileSize
10.9 KB

Rolled a cleaner patch, not sure if the last one would have worked or not but I think this one will.

tizzo’s picture

Title: DBTNG dblog.admin.inc » DBTNG dblog

Changing title to reflect that this patch is for the whole dblog module and not just dblog.admin.inc

Dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD. Thanks!

Dave Reid’s picture

Priority: Normal » Critical
Status: Fixed » Active

The recent log events tablesort is now completely broken and sorting by filter does not work as well. I'm looking into fixing it.

Dave Reid’s picture

Status: Active » Needs work
FileSize
2.59 KB

This at least gets the table sort working. Filtering is still broken completely.

Dave Reid’s picture

Note to anyone doing DBTNG conversion. To convert table sorts, you must do:

...
$query = $query->extend('PagerDefault')->limit(your_limit);
$query = $query->extend('TableSort')->setHeader($header);
...

These have to be separate lines and cannot be chained. This happened in dblog, poll, and comment.

Dave Reid’s picture

Status: Needs work » Active
FileSize
5.17 KB

Left in an unwanted debugging statement.

Dave Reid’s picture

Status: Active » Needs review
Crell’s picture

That seems wrong then. I know I ran into a case where ordered mattered, but you should be able to extend in a chain as long as you do assign back to $query at the end.

Dave Reid’s picture

That seems like it would work. Comparing:

   $query = db_select('watchdog', 'w');
   $query = $query
     ->addExpression('COUNT(wid)', 'count');
     ->fields('w', array('message', 'variables'))
     ->condition('w.type', $type)
     ->groupBy('message')
     ->groupBy('variables')
     ->extend('PagerDefault')
     ->extend('TableSort')
     ->limit(30)
     ->setHeader($header)
     ->setCountQuery($count_query);
   $result = $query->execute();

to:

   $query = db_select('watchdog', 'w');
   $query->addExpression('COUNT(wid)', 'count');
   $query->fields('w', array('message', 'variables'));
   $query->condition('w.type', $type);
   $query->groupBy('message');
   $query->groupBy('variables');
   $query = $query->extend('PagerDefault')->limit(30);
   $query = $query->extend('TableSort')->setHeader($header);
   $query->setCountQuery($count_query);
   $result = $query->execute();

The latter is easier for me to see what is going on. I also remember something about some parts of db_select not able to be chained (fields and conditions?), but I guess it depends on what we're deciding is our offical DBTNG syntax.

Crell’s picture

I believe the standard is "chain whenever possible", because it's easier to read overall. addField() and addExpression() are not chainable, neither are the join*() methods. extend() ischainable, however, the returned object is the extender, not the original query, so if you don't call ->execute() in that chain then you have to assign back to $query, otherwise the extending object gets lost.

Dave Reid’s picture

Title: DBTNG dblog » TableSorts and PagerDefault queries broken
Component: dblog.module » database system
Berdir’s picture

Status: Needs review » Needs work

Same here,

Regarding coding style..

After talking with Crell/webchick, I try to follow the following rules when working with DBTNG:

- The docs at http://drupal.org/node/310069 should be used as examples for coding style
- Chain methods if possible
- If chaining is used, all methods should be on their own line
- Extend early (see #425872: DX problem with DB extenders)

I know that some disagree with point 2 for example, but we should really agree on something, whatever it is..

Berdir’s picture

Status: Needs work » Needs review
FileSize
5.4 KB

Re-roll.

Status: Needs review » Needs work

The last submitted patch failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
6.77 KB

Re-rolled.

Also cleaned up a few queries that didn't early extend, even if they were working correctly.

Status: Needs review » Needs work

The last submitted patch failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
4.91 KB

Re-roll.

Status: Needs review » Needs work

The last submitted patch failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
4.91 KB

Re-roll, forgot to change a setHeader() call...

Dries’s picture

Should we write tests for this?

Berdir’s picture

We have generic paging tests and we have tests for the functionality of those pages. Moshe was against writing paging tests for every page where we used it, see #394582-8: DBTNG: Tracker module.

I'd say that with the new early extend CS, it is unlikely that it is used wrong and usually, we don't protect against wrong usage of our API.

Dries’s picture

Fair enough. Committed to CVS HEAD.

Dries’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)
Issue tags: -DBTNG Conversion, -dc2009 code sprint

Automatically closed -- issue fixed for 2 weeks with no activity.