Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
issue.inc 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.
switch ($_POST['op'] ? $_POST['op'] : arg(2)) {
changed to
switch (!empty($_POST['op']) ? $_POST['op'] : arg(2)) {
2.
'#default_value' => $status[$nid],
changed to
'#default_value' => isset($status[$nid]) ? $status[$nid] : NULL,
3.
$pid = $node->pid ? $node->pid : $_POST['edit']['pid'];
changed to
$pid = !empty($node->pid) ? $node->pid : (isset($_POST['edit']['pid']) ? $_POST['edit']['pid'] : NULL);
4.
if (trim($project->help)) {
changed to
if (isset($project->help) && trim($project->help)) {
5.
'#default_value' => ($query->states) ? $query->states : array(1, 2, 8, 13, 14),
changed to
'#default_value' => !empty($query->states) ? $query->states : array(1, 2, 8, 13, 14),
Best wishes,
Mark.
Comment | File | Size | Author |
---|---|---|---|
#2 | project_issue_103795.patch | 5.66 KB | drewish |
issue.inc_3.patch | 14.33 KB | plumbley |
Comments
Comment #1
dwwa) Doesn't apply cleanly anymore (my fault, sorry it took so long to get to this)
b) this:
would be better as:
c) this:
would be better as:
d) same here:
your version is hard to understand, and doesn't follow our coding conventions regarding spaces and string concatenation.
otherwise, this is a good start, thanks! we'll certainly want something like this before we start porting to D6, so we might as well get this fixed up and committed to all branches.
also, even though i already committed the other patch that included a bunch of similar code, I'm having second thoughts about this style:
I wonder if this would be better for both readability and speed (after the initial array definition):
I'm not sure which I prefer, but I wanted to raise it in case anyone else sees this issue and has strong opinions. ;)
Comment #2
drewish CreditAttribution: drewish commentedtried to apply these by hand to HEAD and then worked on cleaning up some others.
Comment #3
hunmonk CreditAttribution: hunmonk commentedapplied with some minor adjustments to 5.x-1.x. doesn't apply at all to either 4.7 branch -- i'll leave it as to be ported if anybody is interested,,,
Comment #4
(not verified) CreditAttribution: commented