PHP-strict notice in sitenotes "Undefined Property"
dman - September 17, 2008 - 07:23
| Project: | Site notes |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
Trying for PHP strict notice cleanliness in D6 is tedious, but we might as well live up to expectations.
On a new install, I get "Undefined property: stdClass::$weight ... " . Not fatal, or even a problem, but *sigh*
--- sitenotes.module 16 Sep 2008 15:41:33 -0000 1.10.2.6
+++ sitenotes.module 17 Sep 2008 06:58:44 -0000
@@ -129,7 +129,7 @@ function sitenotes_form(&$node) {
$form['body_field']['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight'),
- '#default_value' => $node->weight ? $node->weight : 0,
+ '#default_value' => isset($node->weight) ? $node->weight : 0,
'#delta' => 20,
'#description' => t('Optional. The heavier items will sink and the lighter items will be positioned nearer the top.'),
);| Attachment | Size |
|---|---|
| sitenotes-strict_notice.patch | 810 bytes |

#1
Found another undefined variable usage. Here's an inclusive patch with the two fixes.
#2
Actually, I'd like to know how to turn that on so that you never see it again.
Thanks for catching these.
#3
I've always been getting it when I didn't want it, so it's made me paranoid. It is NOT dependant on my php.ini, it seems to be handled totally by the drupal_error_handler()
... It appears that some magic happens in CVS, so that CVS drupal core checkouts (which I most often use in development) have it set to E_ALL, yet drupal core release tarballs (which humans use) has it set to E_ALL & ^E_NOTICE
So now I know why I get bugged by the errors that I thought would be obvious to everyone :-}
I couldn't find docs of that explained any more than this page in coding standards:
http://drupal.org/node/34341
So I THINK that means if you work on a DRUPAL-x-dev tarball you will start seeing these notices.
#4
Automatically closed -- issue fixed for two weeks with no activity.