Attached Files | 0001-Cosmetics-Simplify-some-if-conditions.patch [^] (2,454 bytes) 2013-08-07 12:49 [Show Content] [Hide Content]From 5db4b8e7fc02e90b046f79cd9abdaea45973d9bb Mon Sep 17 00:00:00 2001
From: Igor Murzov <e-mail@date.by>
Date: Tue, 6 Aug 2013 14:51:49 +0400
Subject: [PATCH] Cosmetics: Simplify some if conditions
Unset variables is a subset of empty variables:
!isset($var) == true implies empty($var) == true
!empty($var) == true implies isset($var) == true
Thus,
!isset($var) || empty($var)
could be simplified to:
empty($var)
The patch is generated by:
find . -type f -name '*.php' -exec sed -i 's/if(!isset($\([^)]*\)) || empty($\1)/if(empty($\1)/' '{}' \;
find . -type f -name '*.php' -exec sed -i 's/if(empty($\([^)]*\)) || !isset($\1)/if(empty($\1)/' '{}' \;
find . -type f -name '*.php' -exec sed -i 's/if(isset($\([^)]*\)) && !empty($\1)/if(!empty($\1)/' '{}' \;
find . -type f -name '*.php' -exec sed -i 's/if(!empty($\([^)]*\)) && isset($\1)/if(!empty($\1)/' '{}' \;
---
displayImage.php | 2 +-
removeBuilds.php | 2 +-
xml_handlers/testing_junit_handler.php | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/displayImage.php b/displayImage.php
index 9765bc7..5812a9a 100644
--- a/displayImage.php
+++ b/displayImage.php
@@ -20,7 +20,7 @@ require_once("cdash/pdo.php");
$imgid = pdo_real_escape_numeric($_GET["imgid"]);
// Checks
-if(empty($imgid) || !isset($imgid) || !is_numeric($imgid))
+if(empty($imgid) || !is_numeric($imgid))
{
echo "Not a valid imgid!";
return;
diff --git a/removeBuilds.php b/removeBuilds.php
index 55b5077..c602db3 100644
--- a/removeBuilds.php
+++ b/removeBuilds.php
@@ -46,7 +46,7 @@ $xml = begin_XML_for_XSLT();
//get date info here
@$dayTo = pdo_real_escape_numeric($_POST["dayFrom"]);
-if(!isset($dayTo) || empty($dayTo))
+if(empty($dayTo))
{
$time = strtotime("2000-01-01 00:00:00");
diff --git a/xml_handlers/testing_junit_handler.php b/xml_handlers/testing_junit_handler.php
index 56bbc55..fce7b4a 100644
--- a/xml_handlers/testing_junit_handler.php
+++ b/xml_handlers/testing_junit_handler.php
@@ -205,7 +205,7 @@ class TestingJUnitHandler extends AbstractHandler
if($this->HasSiteTag == false)
{
// Hostname is not necessarily defined
- if(isset($attributes['HOSTNAME']) && !empty($attributes['HOSTNAME']))
+ if(!empty($attributes['HOSTNAME']))
{
$this->Site->Name = $attributes['HOSTNAME'];
$this->Site->Insert();
--
1.7.9.5
|