hi.. when i access a custom node type with installed toc module, i get
notice: Undefined offset: 0 in /var/www/drupal/sites/all/modules/tableofcontents/tableofcontents.module on line 73.
this patch fixes it :)

Comments

deviantintegral’s picture

It looks like you missed actually attaching the patch.

--Andrew

eMPee584’s picture

StatusFileSize
new602 bytes

:O
DOH!!! i swear i attached it *g
here it is though..

deviantintegral’s picture

Can you paste the tableofcontents string which is causing this error? I'm wondering if this should be caught instead on the node submit.

--Andrew

eMPee584’s picture

well that's the point, there is not tableofcontents stuff anywhere, that's why the results array from preg_match_all is empty!

eMPee584’s picture

please, query your watchdog table for php errors:
SELECT * FROM `watchdog` WHERE `variables` REGEXP 'tableofcontents'
i had *a lot* of them on my site...

deviantintegral’s picture

Anyone else having errors like this? I haven't been able to replicate this on any of my installs across a variety of PHP versions and OS's. Obviously the patch is simple, but I just want to be sure that it actually fixes the issue.

--Andrew

deviantintegral’s picture

Status: Needs review » Closed (won't fix)

I'm marking this as won't fix as I can't replicate it myself, and there hasn't been any other reports of the same error. If this error re-appears, please re-open this issue.

--Andrew

eMPee584’s picture

Status: Closed (won't fix) » Reviewed & tested by the community

??????
Superb code verification method. If not more than one guy who doesn't know sh*t about drupal complains about a bug, there is no bug? ???? Have you even tried and executed the above SQL query?? How trivial is it to understand that, on a page where there is no tableofcontents tag, the preg_match result is EMPTY and accessing it by index ... heck in C this would friggin' seg fault!

deviantintegral’s picture

Status: Reviewed & tested by the community » Needs review

Please keep your flaming off-line. Yelling doesn't get bugs fixed or solutions created.

I don't have any errors in my watchdog database. I'm not disputing that the patch works for you, and that's great, but try running the following on your server in interactive mode with php -a:

<?php
$text = "<p>This is the body of a node.</p>";
preg_match_all('!<\!-- ?tableofcontents(.*)-->!', $text, $options_str, PREG_PATTERN_ORDER);

print "Here are the contents of options_str: ";
print_r($options_str);

print "\n";

if($options_str[0][0] == "some text to search for") {
  print "We found text.";
}
else {
  print "We didn't find text.";
}
?>

None of my machines throw any warnings or errors. If your server does, please post the output of php -v.

--Andrew

eMPee584’s picture

Priority: Minor » Critical

yeah well, add error_reporting(E_ALL); at the top.

(This function produces an error on *every single filtered string* that does not contain the TOC tag, you can do the maths how many php errors it has put in logs all over the world...)

deviantintegral’s picture

Status: Needs review » Fixed

Awesome - I was able to replicate the error. I've committed the patch to both the D5 and the D6 versions.

Thanks,
--Andrew

eMPee584’s picture

Awesome - you took only three months to take me serious!

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

summit’s picture

Bookmarking, have same sort of problem with other module, still investigating.. greetings, Martijn

AlexisWilke’s picture

Summit,

D5 or D6?

Thank you.
Alexis