The module worked well for some times, but now when i want to create content the following error appears:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 16777217 bytes) in /home/ewaste/public_html/modules/subscriptions/subscriptions.module on line 709

Comments

markdionne’s picture

Title: Fatal error » Fatal Error: Memory Exhausted

I'm getting a similar error with Drupal 5.1, and it goes away if I disable the taxonomy_super_select module. The problem occurs here:

 foreach ($taxa as $tid) {
       $strsent .= subscriptions_mailvars($tid, $node->nid, $user->uid, 'taxa', $strsent);
}

in the "insert" case of the nodeapi hook. $strsent starts out as "!". After the first loop it is "!!" then "!!!!" then "!!!!!!!!" so it doesn't take long to run out of memory!

It looks like in multiple places, this code:
$strsent .= subscriptions_mailvars...
should be changed to
$strsent = subscriptions_mailvars...
but I have not read the code closely enough to be sure.

There must also be some kind of issue with Taxonomy Super Select.

Note: I changed the Title of this issue from "Fatal Error" to something a bit more descriptive.

markdionne’s picture

In the case of taxonomy_super_select, the loop:

 foreach ($taxa as $tid) {
       $strsent .= subscriptions_mailvars($tid, $node->nid, $user->uid, 'taxa', $strsent);
}

is getting a zero value for $tid for each of the unused taxonomy items. This makes the previously described memory failure much more likely to happen, not to mention being inefficient in general. The fix is obvious, though note there are several similar loops in the module.

csc4’s picture

Doesn't this issue need moving/copying to the taxonomy super select issue queue?

chx’s picture

Version: 4.7.x-1.4 » 5.x-1.x-dev
Component: Miscellaneous » Code
Assigned: Unassigned » chx
Priority: Normal » Critical
Status: Active » Needs review
StatusFileSize
new8.07 KB

The problem is that every call to subscriptions_mailvars at least doubles the length of the strsent string. This is braindead. The whole concept of strsent is flawed. The attached patch removes it.

chx’s picture

That was a good start but it had bugs and could be simplified further.

chx’s picture

Status: Needs review » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)