BitTorrent Module - Bugs can drive you mad...

Events happening in the community are now at Drupal community events on www.drupal.org.
bradfordcp's picture

I have been continuing work on Views integration and I finally have all specified fields working. I ran into an issue where the bt_torrents table was playing nice with views, but when I tried to use fields from bt_torrents_files everything went screwy and all I would get is an error. This is no fun so I started looking at the code and everything appeared normal. That was my problem I stared at the screen looking for the problem, but it wasn't the kind that just jumps out at you. The error message showed the SQL statement that was being generated and the table bt_torrents_files was not being joined. This made no sense my statement was:

<?php
$table
= array(
   
'name' => 'bt_torrents_files',
   
'join' => array(
     
'left' => array(
       
'name' => 'node',
       
'field' => 'nid',
      ),
     
'right' => array(
       
'field' => 'nid',
      ),
    ),
   
'fields' => array(
     
'name' => array(
       
'name' => t('BitTorrent: File Name'),
       
'help' => t('The names of the files within the torrent.'),
       
'sortable' => TRUE,
      ),
     
'length' => array(
       
'name' => t('BitTorrent: File Length'),
       
'help' => t('The length of the files.'),
       
'sortable' => TRUE,
      ),
    ),
  );
?>

where the correct form is:

<?php
$table
= array(
   
'name' => 'bt_torrents_files',
   
'join' => array(
     
'left' => array(
       
'table' => 'node',
       
'field' => 'nid',
      ),
     
'right' => array(
       
'field' => 'nid',
      ),
    ),
   
'fields' => array(
     
'name' => array(
       
'name' => t('BitTorrent: File Name'),
       
'help' => t('The names of the files within the torrent.'),
       
'sortable' => TRUE,
      ),
     
'length' => array(
       
'name' => t('BitTorrent: File Length'),
       
'help' => t('The length of the files.'),
       
'sortable' => TRUE,
      ),
    ),
  );
?>

I used the array key 'name' instead of 'table' within the 'join' key. Needless to say after removing that little bit of trickery it worked fine. I was happily creating example views and everything started to behave. I also ran into issues where arguments were concerned. For example when listing the files that are contained within a torrent. The documentation was a little confusing, I thought I needed to write a handler and implement a couple of hooks. After looking at a few examples I realized that all I needed to do was put a couple of lines of code in one of the drop-downs on the Views' creation page. Now everything is happy and working, I am off to work on web-seeding which I can already see will be interesting.

~Chris

Comments

I feel your pain

mlncn's picture

on the table / name silent fail issue. It physically hurt just looking over your code to see what changed, when I knew there was a correction in there ;-)

~ ben melançon, Agaric Design Collective

benjamin, agaric

Just tested the Aug 12 release files, there are errors

droople's picture

There is a critical code error (bug)

during installation, this error comes up

Fatal error: Call to undefined function: bt_message() in /var/www/vhosts/mysite.co.uk/subdomains/torrent/httpdocs/bt_common.inc on line 373

don't reall know what that means, but it disables access to the whole site

SoC 2007

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: