Warnings in cre.module

josedazag - November 13, 2008 - 01:11
Project:Content Recommendation Engine
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Cordial saludo.

Today I setup cre-5.x-1.x-dev.tar.gz released in 2008-Nov-04. When I'm going to CRE Settings (admin/settings/cre) I get the following warnings:

    * user warning: Table 'drupal_00_05_12_.votingapi_vote' doesn't exist query: SELECT MAX(vote_id) FROM votingapi_vote in /var/www/html/drupal/includes/database.mysqli.inc on line 156.
      * warning: Division by zero in /var/www/html/drupal/sites/all/modules/cre/cre.module on line 49.

      First warning is related with call to votingapi_vote table in line 46. My database tables are prefixed. Because of that I had to enclose votingapi_vote in curly brackets {} as follows:

      $max = db_result(db_query("SELECT MAX(vote_id) FROM {votingapi_vote}"));

      Second warning is related with $max variable in division $start / $max, because $max evaluate to 0 because my votingapi_vote table in beginning don't contain any value turned out of expression db_result(db_query("SELECT MAX(vote_id) FROM votingapi_vote")). Simply I evaluate $max variable for any value different of 0 o FALSE before execute the sentence in line 43, enclosing it as follows in a if-then-else structure:

      if ($max){
        $form['cre_index_status'] = array(
           '#type' => 'markup',
           '#value' => '<strong><em>' . $start / $max . '</em></strong> of the site indexed',
        );
      }
      else{
        $form['cre_index_status'] = array(
           '#type' => 'markup',
           '#value' => 'Still nothing to index',
        );
      }

      I create a patch for revision and test. Maybe of help.

AttachmentSize
cre.module.josedazag.1.patch921 bytes
 
 

Drupal is a registered trademark of Dries Buytaert.