Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use count to use check return by ->get() #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions addons/vultr/helpers/ProductsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private static function prepareConfigurableOptions($vultrAPI, $productID)
{
$checkIsset = DB::table('tblproductconfiglinks')->where('pid', $productID)->get();

if ($checkIsset)
if (count($checkIsset) > 0)
{
return array('status' => false, 'message' => 'Product configurable options already exist!');
}
Expand Down Expand Up @@ -116,7 +116,7 @@ public static function getProductConfigOptions($productID, $field = 'all', $defa
public static function customFields($productID)
{
$result = DB::table('tblcustomfields')->where('fieldname', 'subid|Virtual machine ID')->where('type', 'product')->where('relid', $productID)->select('id')->get();
if (!$result)
if (count($result) < 1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be a good and necessary change needed for php72+ from what i can tell

{
DB::table('tblcustomfields')->insert(array('type' => 'product', 'relid' => $productID, 'fieldname' => 'subid|Virtual machine ID', 'fieldtype' => 'text', 'adminonly' => 'on'));
return array('status' => true, 'reload' => true, 'message' => 'success');
Expand Down
4 changes: 2 additions & 2 deletions servers/vultr/controller/main.controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,12 @@ private function addVMCustomFields($SUBID)
->where('type', 'product')
->where('relid', $this->params['packageid'])
->where('fieldname', 'LIKE', 'subid|%')->get();
if ($customField)
if (count($customField) > 0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed and actually breaks the logic flow in things when was debugging this thoroughly today

{
$customFieldValue = Capsule::table('tblcustomfieldsvalues')
->where('fieldid', $customField[0]->id)
->where('relid', $this->serviceID)->get();
if ($customFieldValue)
if (count($customFieldValue) > 0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing here.

{
$customFieldValue = Capsule::table('tblcustomfieldsvalues')
->where('fieldid', $customField[0]->id)
Expand Down
2 changes: 1 addition & 1 deletion servers/vultr/controller/sshkeys.controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function indexAction()
if ($this->getVultrAPI())
{
$allowKeys = Capsule::table('vultr_sshkeys')->where('client_id', $this->clientID)->get();
if (empty($allowKeys))
if (count($allowKeys) < 1)
{
return array();
}
Expand Down
4 changes: 2 additions & 2 deletions servers/vultr/helper/vultr.helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ public static function getAvailableIsos($isosList)
public static function getUserScripts($clientID, $scripts)
{
$allowScripts = Capsule::table('vultr_scripts')->where('client_id', $clientID)->get();
if (empty($allowScripts))
if (count($allowScripts) < 1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also good.

{
return array();
}
Expand Down Expand Up @@ -521,7 +521,7 @@ public static function getUserScripts($clientID, $scripts)
public static function getUserSSHKeys($clientID, $keys)
{
$allowKeys = Capsule::table('vultr_sshkeys')->where('client_id', $clientID)->get();
if (empty($allowKeys))
if (count($allowKeys) < 1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also good.

{
return array();
}
Expand Down