E_ALL Compliance: Fix PHP Notices in project_issue.module
plumbley - December 17, 2006 - 14:41
| Project: | Project issue tracking |
| Version: | 4.7.x-1.0 |
| Component: | Issues |
| Category: | bug report |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
project_issue.module produces various PHP Notices with E_ALL on. These are all due to variables, array keys or object fields which may not exist when used.
This patch fixes those that I spotted, by changing to equivalent behaviour without Notices.
Examples:
1.
<?php
if (is_array($node->components)) {
?>changed to
<?php
if (isset($node->components) && is_array($node->components)) {
?>2.
<?php
if ($_GET['edit'][$field]) {
?>changed to
<?php
if (!empty($_GET['edit'][$field])) {
?>3.
<?php
'#default_value' => $node->mail_copy_filter[$key],
?>changed to
<?php
'#default_value' => isset($node->mail_copy_filter[$key]) ? $node->mail_copy_filter[$key] : NULL,
?>4. Immediate bail from project_issue_project_load() if not found in table {project_issue_projects}:
<?php
function project_issue_project_load(&$node, $arg) {
$project = db_fetch_object(db_query('SELECT * FROM {project_issue_projects} WHERE nid = %d', $node->nid));
// If nothing loaded, bail immediately
if (!$project) {
return $node;
}
//assert($project);
$node->components = unserialize($project->components);
...
?>Here
return $node; has been used to match the later return in the function, although this the return value is ignored by project_issue_project_nodeapi(), which appears to be the only place it is called ($node is called by reference and modified in place). Perhaps some documentation for project_issue_project_nodeapi() could clarify whether it should return anything.
Best wishes,
Mark.
| Attachment | Size |
|---|---|
| project_issue.module.patch | 3.74 KB |

#1
(Set correct status. Again :-( )
#2
Patch didn't cleanly apply, but I resolved the conflicts, reviewed, tested, and commited to HEAD, DRUPAL-4-7--2 and DRUPAL-4-7. A good step towards the D6 port. ;) Thanks.
#3