There are many, many E_ALL notices errors in the module.
It would be better to develop the module with E_ALL notices enabled so as to notice them straight away (display on screen and not only in the logs).

Here are some I already noticed:
notice: Undefined property: stdClass::$tableofcontents_toc_automatic in /tableofcontents.module on line 121 when saving a node.

Comments

jennifer.chang’s picture

notice: Undefined property: stdClass::$tableofcontents_toc_automatic in tableofcontents.module on line 124.
notice: Undefined offset: 1 in tableofcontents.pages.inc on line 454.

when previewing and saving node.

jennifer.chang’s picture

notice: Undefined property: stdClass::$tableofcontents_toc_automatic in tableofcontents.pages.inc on line 640 when viewing a node without TOC!

jennifer.chang’s picture

notice: Undefined index: nid in tableofcontents.admin.inc on line 307.
notice: Undefined index: type in tableofcontents.admin.inc on line 316.
after visting the 'outline' tab (book.module) of a node.

AlexisWilke’s picture

Version: 6.x-3.5 » 6.x-3.x-dev

Hi Jennifer,

I could not replicate anyone of those... I wrote fixes for all of them but since I could not see them in the first place, I have no clue whether it was properly fixed. Please, try the -dev once available (within 12h) and let me know if that works for you.

Thank you.
Alexis Wilke

jennifer.chang’s picture

Thanks for the prompt feedback.

The latest -dev does not fix this one, at least:
notice: Undefined property: stdClass::$tableofcontents_toc_automatic in tableofcontents.module on line 121.

Setting to NULL amounts to unsetting the variable. Maybe you should set to an empty string ''.
Hmm... I just tried and even setting to '' (line 138) does nothing: there is still an error.

I'm now running the latest -dev (DRUPAL-6--3). I only need to do cvs udpate to get the latest code.

The fact that you do not see those notices shows that your development platform is not optimized for coding.
Whatever we are doing on the site, this notice #761770: Use of undefined constant TABLEOFCONTENTS_REMOVE_PATTERN - would show on every page. So you can use it to make sure your development platform is properly set up:
check in Drupal that error messages are set to display on screen as well as in the logs.
check your php installation (php.ini?) to make sure that E_ALL notices are reported. There is a setting that hides them. E_ALL should always be noted on a computer used for development. The most convenient is to use #761770 to test this.

Thanks again for the module and the quick feedback. I have the latest code and I'll use this issue to report other notices, if I find them in the next day or two.

jennifer.chang’s picture

A new one, after editing and saving a node (with latest code):
notice: Undefined offset: 1 in tableofcontents.pages.inc on line 454.

Previously, I had been playing with the filter settings:
admin/settings/filters/2/configure
what's changed was I configured it to add a TOC automatically and unchecked the option 'remove the TOC tags from the node summary.'

jennifer.chang’s picture

Those two still exist when saving a new node:

* notice: Undefined property: stdClass::$tableofcontents_toc_automatic in tableofcontents.module on line 121.
* notice: Undefined property: stdClass::$tableofcontents_toc_automatic in tableofcontents.module on line 124.

AlexisWilke’s picture

Hi Jennifer,

Okay, I have applied a few more fixes. Let me know how it works now. 8-)

Thank you.
Alexis

jennifer.chang’s picture

Thanks. The last ones I reported seem to have been fixed in 6--3-dev.

I just noticed another one right now while testing:

notice: Undefined property: TOC::$id in tableofcontents.pages.inc on line 832.
when editing and saving a node (the node type is set to have automatic TOC at the top.

jennifer.chang’s picture

Where you able to adjust your dev platform to report such notices? Otherwise this will be a recurring problem with this module.

AlexisWilke’s picture

Hi Jennifer,

I added a fix for the error on line 832.

I have turned on the E_NOTICE messages and had to fix many errors in many modules, but 0 errors from tableofcontents shown up. Dunno why... I use many modules on my development site... so maybe one of them prevents the errors.

I also edited the Core error module which would not report the E_NOTICE errors. And my PHP is always setup to show really bad errors in the browser (even on my production server.) And I still get no errors from the tableofcontents.

Now, maybe you could learn to write patches... 8-)

Thank you.
Alexis

jennifer.chang’s picture

Status: Active » Fixed

Thank you Alexis. Notice in #9 is fixed :)

It's strange you're not seeing those notices. I am not sure which core error module you're referring to.
Thanks for promptly fixing those errors. As far as I am aware, everything is fixed here.
If I find anything else, I'll reopen... maybe with a patch :)

AlexisWilke’s picture

Assigned: Unassigned » AlexisWilke

Jennifer,

Here:

// $Id: common.inc,v 1.756.2.79 2010/03/04 00:15:28 goba Exp $
[...]
function drupal_error_handler($errno, $message, $filename, $line, $context) {
  // If the @ error suppression operator was used, error_reporting will have
  // been temporarily set to 0.
  if (error_reporting() == 0) {
    return;
  }

  if ($errno & (E_ALL ^ E_DEPRECATED ^ E_NOTICE)) {
[...]

Thank you.
Alexis

jennifer.chang’s picture

I have:

  if ($errno & (E_ALL ^ E_DEPRECATED)) {

in my unpatched Drupal installation. Did you add ^ E_NOTICE ?

AlexisWilke’s picture

That's what I have in Drupal 6.16. I checked everything else and could not find a call that would clear the E_NOTICE flag other than that one line. I use the tarball though, not the CVS version of Drupal. They may have some magic in there? 8-)

jennifer.chang’s picture

I think we found the culprit. I checkout from CVS.

Apparently that line is updated back and forth before and after each release:
http://drupalcode.org/viewvc/drupal/drupal/includes/common.inc?view=log&...
It's obviously done on purpose so that developers see the notices, but not regular users.

The morale of the story: we should not develop using a Drupal platform installed from a tarball.
I was wondering why I was seeing so many notices in so many modules.... and I was apparently the only one to see them :(

I think I'll patch my production platform accordingly!

AlexisWilke’s picture

I wonder whether there are other differences in the tarball... 8-}

jennifer.chang’s picture

Title: Plenty of E_ALL notices in modules developed on installation with Drupal tarball » Plenty of E_ALL notices
Project: Documentation » Table of Contents
Version: » 6.x-3.x-dev
Component: Other documentation issues » Code
Assigned: Unassigned » AlexisWilke
Priority: Critical » Normal
Status: Active » Fixed

This is obviously also different.

define('VERSION', '6.17-dev');

I'll redirect this issue to another queue: module developers should all be aware of this! It's surprising we had to find about it the hard way. Only a minority of contrib module developers are also core developers (using Drupal-dev).

jennifer.chang’s picture

Title: Plenty of E_ALL notices » Plenty of E_ALL notices in modules developed on installation with Drupal tarball
Project: Table of Contents » Documentation
Version: 6.x-3.x-dev »
Component: Code » Other documentation issues
Assigned: AlexisWilke » Unassigned
Priority: Normal » Critical
Status: Fixed » Active

Many contrib module developers only develop on a drupal installation using the latest tarball from the current stable version.
All these developers miss on plenty of E_ALL notices.

jennifer.chang’s picture

What I mean is: a way should be found to notify such developers (current and future) of this issue.
They should either patch their Drupal tarball, or use the -dev version from the stable branch.

AlexisWilke’s picture

I updated my script to automatically remove the E_NOTICE from my development server. 8-)

I'm glad you noticed that a few other modules had the same problem. I reported those errors too to several modules.

Alexis

AlexisWilke’s picture

Title: Plenty of E_ALL notices » Plenty of E_ALL notices in modules developed on installation with Drupal tarball
Project: Table of Contents » Documentation
Version: 6.x-3.x-dev »
Component: Code » Other documentation issues
Assigned: AlexisWilke » Unassigned
Priority: Normal » Critical
Status: Fixed » Active

Sorry, I messed around with the settings... Fixing those now!

AlexisWilke’s picture

Something to think about:

For all the programmers who are on your security list, you may want to include information about this notice (maybe write a concise Help page...) by including a link in your security report with something such as:

And please, do not forget to use E_NOTICE on your test servers see [page link].

This would eventually save time to a lot of people in regard to using the wrong variable and wondering why something or other does not work properly.

Thank you.
Alexis Wilke

AlexisWilke’s picture

I guess that the E_ALL & E_NOTICE are mentioned in the documentation as we can plainly see here:

http://drupal.org/node/34341

I'm wondering whether D7 could have a flag in an interface instead of a PHP flag, even if that PHP flag is expected to be in the settings.php file...

Thank you.
Alexis Wilke

P.S. Since I started using this error detection mechanism, I fixed one security bug and 4 or 5 other bugs in that many modules. I think that's a given that each programmer should know about this issue...

P.S. I did not test D7, but I can see that you can switch the error reporting level from within the Interface! So we can hope that developers will catch many of those errors.

chx’s picture

Project: Documentation » Table of Contents
Version: » 6.x-3.x-dev
Component: Other documentation issues » Code

Moving to the right queue. I have no idea what this is doing in documentation

AlexisWilke’s picture

chx,

You may want to ask Jennifer... If you don't want it, I'll close it.

Thank you.
Alexis

AlexisWilke’s picture

Status: Active » Closed (fixed)

Closing, I guess I did not check this thread for a while. 8-)