Problem/Motivation

PHP isset allows the use of multiple parameters to be passed in a single isset call. Instead of doing a multiple consequetive isset($a) && isset($b) calls, we can do isset($a, $b). Naturally this leads to less code and less possible confusion with the use of boolean operators and therefore less possible bugs. Should be noted that performance boost is negligible.

Proposed resolution

Wherever found, replace consequetive non negated AND combined issets with a single one.

Patch as an example.

Comments

tcmug’s picture

Issue summary: View changes
StatusFileSize
new933 bytes
cilefen’s picture

Status: Active » Needs review
Issue tags: +Needs beta evaluation

There is a patch, so "needs review". @tcmug Did you open this intentionally against 8.1.x?

Status: Needs review » Needs work

The last submitted patch, 1: 2493429-core-includes-common-single-isset.patch, failed testing.

gsharm’s picture

Re-roll as function name change from _drupal_add_html_head() to drupal_add_html_head()

tcmug’s picture

@cilefen - semi intentionally - and well, initially I thought the patch would work as an example but hey - if it works, it works!

gsharm’s picture

Status: Needs work » Needs review
Issue tags: +SrijanSprintNight

Status: Needs review » Needs work

The last submitted patch, 4: 2493429-core-includes-common-single-isset-1.patch, failed testing.

j2r’s picture

Status: Needs work » Reviewed & tested by the community

Tested the patch applied successfully and working fine.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 4: 2493429-core-includes-common-single-isset-1.patch, failed testing.

_KurT_’s picture

Status: Needs work » Needs review
StatusFileSize
new39.99 KB

Status: Needs review » Needs work

The last submitted patch, 11: 2493429-core-includes-common-single-isset-11.patch, failed testing.

_KurT_’s picture

Status: Needs work » Needs review
StatusFileSize
new38.28 KB

Status: Needs review » Needs work

The last submitted patch, 13: 2493429-core-includes-common-single-isset-13.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 13: 2493429-core-includes-common-single-isset-13.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 13: 2493429-core-includes-common-single-isset-13.patch, failed testing.

neetu morwani’s picture

Assigned: Unassigned » neetu morwani
Issue tags: +Needs reroll
neetu morwani’s picture

Assigned: neetu morwani » Unassigned
deepakaryan1988’s picture

Assigned: Unassigned » deepakaryan1988
deepakaryan1988’s picture

Issue tags: -SrijanSprintNight
deepakaryan1988’s picture

Assigned: deepakaryan1988 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new29.83 KB

It was very difficult to find right file as file structure has been changed now. :(
But here I am uploading a patch. :)

Status: Needs review » Needs work

The last submitted patch, 23: 2493429-core-includes-common-single-isset-23.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 23: 2493429-core-includes-common-single-isset-23.patch, failed testing.

JMC’s picture

It looks like a change in MachineNameController.php had broken the patch. I've attempted to update it here.

JMC’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 27: 2493429-core-includes-common-single-isset-27.patch, failed testing.

deepakaryan1988’s picture

Rerolling my own patch #23

deepakaryan1988’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 30: 2493429-core-includes-common-single-isset-30.patch, failed testing.

_KurT_’s picture

Could someone explain why this error failed attempting to get list of tests from run-tests.sh appears? Seems like patches are ok and it is something wrong with testing process.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

j2r’s picture

Status: Needs work » Needs review
StatusFileSize
new43.86 KB

Adding patch !!

Status: Needs review » Needs work

The last submitted patch, 35: 2493429-core-includes-common-single-isset-35.patch, failed testing.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

prashant.c’s picture

Patch submitted by #35 does not apply successfully. Submitting a new patch against 8.3.x version which needs to be reviewed.
Replacing all isset($a) && isset($b) with isset($a, $b) and also !isset($a) && !isset($b) with !isset($a, $b) .

prashant.c’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 38: 2493429-core-includes-common-single-isset-38.patch, failed testing.

manuel garcia’s picture

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +stale-issue-cleanup

Thank you for creating this issue to improve Drupal.

We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

borisson_’s picture

I believe it is still relevant - though I am personally not a fan, but without a coding standards issue we shouldn't get this in. I think we need to create a CS issue and postpone this one on that.

quietone’s picture

Issue tags: +Needs followup

I agree with @borisson_.

There are still occurrences in core, as shown below.

$ grep -r -E "(isset.*){2}" --include=*.php core | wc -l
190
$ grep -r -E "(isset.*){2}" --include=*.php composer | wc -l
3

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.