project.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. Additional
$output = '';
in project_page_overview(), that uses $output .= ... later.
2.
if ($_POST['edit']['rid']) {
changed to
if (!empty($_POST['edit']['rid'])) {
3.
if ($project->release_count > 1) {
changed to
if (isset($project->release_count) && $project->release_count > 1) {
4.
if (module_invoke($module, 'project_sort_methods', 'group by date', $sort_method) && $date = _project_date($project->changed)) {
changed to
+ if (isset($module) && module_invoke($module, 'project_sort_methods', 'group by date', $sort_method)
&& $date = _project_date($project->changed)) {
(Actually this indicates some other possible problem project_page_overview(), since presumably $module ought to exist at this point. So maybe this should be left as a bug to be fixed).
5.
$output .= '<div class="project" id="project-overview">' . $projects . '</div>';
changed to
$output .= '<div class="project" id="project-overview">' . (isset($projects) ? $projects : '') . '</div>';
although an alternative would be to show an alternative message if no projects were listed.
Best wishes,
Mark.
Comments
Comment #1
plumbley commented(Setting correct status)
Comment #2
drewish commentedhere's a re-roll for 5
Comment #3
hunmonk commentedthis is definitely wrong:
what are you doing that's resulting in $module not being set? that doesn't look possible to me. if it is, then we need to fix elsewhere.
Comment #4
plumbley commented@hummonk - Sorry this is so long ago now that I don't remember what I did exactly. But I only ever started to try out Project, so this was probably either (1) browse of projects with no projects created yet, or (2) creation of first project. I think (2) is most likely, since most node add/edit forms ask for something about the (assumed to exist) item, but on create it doesn't exist yet so instead returns NULL node with PHP Notice.
A clean bare installation would be the most likely place to see this I think, since creating the first of a particular type can sometimes be a boundary case that isn't always catered for well.
Comment #5
hunmonk commentedthe above mentioned weirdness w/ $module has been fixed elsewhere, so rip that out and roll a new patch against the latest code.
Comment #6
hunmonk commentedthis should do what we need. quick review would be nice.
Comment #7
dwwVisually looks fine and light testing on a local site reveals no problems. Didn't actually turn on E_ALL yet, so it's possible there are other warnings lurking, but this is certainly an improvement. Thanks.
Comment #8
drewish commentedi turned on E_ALL and found a few more. we might as well get them all at once.
Comment #9
hunmonk commentedsomething's wrong here. that form isn't built anywhere else that i can see, so what's the deal with
function project_release_version_filter_form($version = NULL)if we're removing $version in the patch? do we need to get rid of $version as an arg, or correctly supply $version infunction project_page_overview()?Comment #10
hunmonk commentedComment #11
hunmonk commentedreviewed, tested, committed to 5.x-1.x -- leaving to be ported if anybody cares to fix this in the older versions.
Comment #12
dwwComment #13
(not verified) commented