After spam.module gets activated, every Drupal pages return an empty string (both the admin pages and the nodes).

Comments

avpaderno’s picture

That is also valid for the version 5.x-3.x-dev.

jeremy’s picture

I'm using the 3.0 spam module on several websites without problems, including KernelTrap.org -- I'd like to understand what's different about your system. What version of Drupal are you using? What OS? MySQL or PostgreSQL? What version of PHP are you using?

Do you see any errors in Drupal's watchdog logs or in Apache's error_log?

avpaderno’s picture

I confirm it. Whenever I install it, Drupal doesn't work anymore, and I am not even able to see the modules administration page.
This is the info about the Drupal installation:

Drupal 5.8-dev
Configuration file Protected
Cron maintenance tasks Last run 7 hours 43 min ago
Database schema Up to date
File system Writable (public download method)
GD library bundled (2.0.28 compatible)
JQuery Update Installed correctly
The current installed version of JQuery is 1.2.3
MySQL database 4.1.22
PHP 4.4.6
PHP register globals Disabled
Unicode library PHP Mbstring Extension
Web server

The web server is not listed by Drupal but it is a Linux i686.
I will check for any errors in the Drupal log, but at the moment I have to understand which ones come after I activate the module, and which ones come after I delete the module files (that is the only way to have Drupal working again).

avpaderno’s picture

The error I get when I activate the Spam API module (yes, that is enough to cause the "boom") is something like this:

Can't find file: './avpnet_drupal/spam_tracker.frm' (errno: 2) query: RENAME TABLE spam_tracker TO old_spam_tracker in /home/avpnet/public_html/includes/database.mysql.inc on line 172.

That is repeated everytime it tries to rename a table from XXX to old_XXX. I guess the hook_update_N() tries to update the module even if there are not any previous installed versions.

avpaderno’s picture

The only function that tries to rename tables is spam_upgrade_0(). That function is actually called from spam_install(), which is not supposed to be called when the module is being updated, but when the module is being installed for the first time.
If you want to update from previous versions, in Drupal 5.x you can simply add a function like spam_update_1(), as Drupal 5.x numbers the updates sequentially starting with 1 (see Drupal API).

In detail, Drupal 5.x executes the update function whose number is the first number higher than the number it finds in the {system} table (which is 0 in the case Drupal didn't execute any updates for that module).

Things change from Drupal 6.x, as reported in the Drupal API changes page.

avpaderno’s picture

I tried to create a patch for spam.install but the code is almost completely wrong.

This is because:

  • spam_install() should not be called from spam_update_5300(); hook_update_N() is supposed to call update_sql() for every change to the database, while hook_install() should call db_query().
  • every call to _spam_upgrade_in_progress() should be deleted.
  • if there isn't any action to take in the passage to a new version, but you want Drupal to record the passage to a new version, create a function that doesn't do anything but returns an empty array.
jeremy’s picture

Status: Active » Fixed

The call to spam_install() from _update_5300 was supposed to be a call to spam_upgrade_0(), not sure how that slipped through. Anyway, thanks for reporting it, fixed in the latest development version.

Status: Fixed » Closed (fixed)

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