The included feed.inc has a little error.
When no feeds are availble the variable $feeds will be NULL, thus leading to the error:
* warning: implode(): Bad arguments. in /var/www/tatnet07/html/drupal/sites/all/modules/mysite/plugins/types/feed.inc on line 443.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 query: SELECT cid, title, description FROM drupalaggregator_category WHERE cid IN () in /var/www/tatnet07/html/drupal/includes/database.mysql.inc on line 172.

By adding:
if($feeds) {
just right before $implode = ".........
and add:
}
right before: if( empty(.......

I think the bug is fixed .... or am I doing it wrong?

Comments

agentrickard’s picture

Status: Fixed » Closed (works as designed)

This is an error you might see during configuration of the module, and it is based on a design choice.

See http://drupal.org/node/119580 (or section 1.8 of the README) for the logic behind this design choice.

The assumption, if you allow users to add feeds, is that you want to store them in a category separate from the administrator-defined feeds. Some people don't use Aggregator categories, however, which is why you get this error.

This section of code, however, assumes that you have configured aggregator's feeds to put user-submitted feeds into a 'default category.'

You define that category at: admin/settings/mysite/type/feed.

The fix is either to set up a default category for user feeds, or to change the function, starting at line 439:

    else {
      $edit['category'] = variable_get('mysite_feed_default', array());
    }
    if (!empty($edit['category'])) {
      $implode = "(". implode(", ", $feeds) .")";
      $sql = "SELECT cid, title, description FROM {aggregator_category} WHERE cid IN %s";
      $result = db_query($sql, $implode);
      $options = array();
      while ($category = db_fetch_object($result)) {
        $options[$category->cid] = check_plain($category->title);
      }
      if (empty($options)) {
       $form['new_feed']['no_feeds'] = array(
         '#value' => t('<p>There are no categories configured.  Please go to <a href="@url">aggregator categories</a> to add one. <br /><b>User Feeds</b> is a good choice.</p>', array('@url' => url('admin/content/aggregator/add/category'))) ,
        ); 
      }
      else if (count($options) > 1) {
        $form['new_feed']['category'] = array(
          '#type' => 'radios', '#title' => t('Feed Categories'), '#default_value' => $edit['category'],
          '#options' =>  $options,
          '#description' => t('Select a category for this feed')
        );
      }
      else {
        $form['new_feed']['category'] = array(
          '#type' => 'hidden', '#title' => t('Feed Categories'), '#default_value' => $edit['category']
        );
      }
    }

Note: Please do not mark issues as fixed when you first enter them. Issues are only fixed when code is approved and/or committed.

agentrickard’s picture

Related note.

If you look at the function mysite_type_feed_active() [lines 40-80 of feed.inc], you should not be allowed to activate this plugin until you have configured the default categories.

So my question is: why didn't that stop you from activating the plugin? Did you set the "allow users to add new feeds" setting on the Feed admin page?

I think the error is in this function, which is designed to prevent you from encountering mis-configuration errors. I think it should be:

function mysite_type_feed_active($type) {
  // there must be some aggregator categories
  $message = '';
  $br = '';
  $count = db_result(db_query("SELECT count(fid) FROM {aggregator_feed}"));
  if ($count > 0) {
    $value = TRUE;
  }
  else {
    $value = FALSE;
    $message .= l(t('There are no Aggregator feeds available.'), 'admin/content/aggregator/add/feed');
    $br =  '<br />';
  }
  // if user feeds are allowed, they must be configured
  $feed = variable_get('mysite_feed', 0);
  if ($feed) {
    $cats = variable_get('mysite_feed_categories', array());
    $default = variable_get('mysite_feed_default', NULL);
    if (empty($cats)) {
      $value = FALSE;
      $message .= $br . l(t('User Feed categories are not configured'), 'admin/settings/mysite/type/feed');
      $br =  '<br />';
    }
    if (empty($default)) {
      $value = FALSE;
      $message .= $br . l(t('Default User Feed category is not configured'), 'admin/settings/mysite/type/feed');     
      $br =  '<br />'; 
    }
    // some users must be allowed to add feeds, otherwise, give a configuration message
    $result = db_query("SELECT perm FROM {permission}");
    $check = '';
    while ($perms = db_fetch_object($result)) {
      $check .= $perms->perm;
    }
    if (!stristr($check, 'add mysite feeds')) {
      $value = FALSE;
      $message .=  $br . l(t('There are no users with the "add mysite feeds" permissions'), 'admin/user/access');
    }
  }
  else{
      $value = FALSE;
      $message .= $br . l(t('You have not configured user feeds for MySite.'), 'admin/settings/mysite/type/feed');
  }
  return array($type => $value, 'message' => $message);
}
agentrickard’s picture

Status: Closed (works as designed) » Active

Based on last note, re-assigning status.

agentrickard’s picture

Status: Active » Fixed

This is a good catch. It is still required that you establish a default category for user feeds. (See README section 1.8). However, I fixed the errors that we caused by mis-configuration.

Committed to HEAD.

Thanks.

mounte’s picture

Sorry for the inconvinience (spelling?) regarding the use of the tracking system.
I am new to all this, anyways, thanks for the explanation of the situation.

agentrickard’s picture

Status: Fixed » Closed (fixed)

Fixed in 5.x.2.1.

Thanks!