Jump to content

About Tools::getIsset();


Kerm

Recommended Posts

Hello,

 

Addons site recommend use Tools::getIsset(); function instead if(isset($variable)) when validate my module.
 
Maybe it's better you know better...but
 
Lets see this function:
 
    public static function getIsset($key)
    {
        if (!isset($key) || empty($key) || !is_string($key)) {
            return false;
        }
        return isset($_POST[$key]) ? true : (isset($_GET[$key]) ? true : false);
    }

What if i use in my project this code:

 

$orderBy = Tools::getIsset($_GET['idreviewsOrderby']) ? $_GET['idreviewsOrderby'] : '1';


For get key value (idreviewsOrderby) in this url:

http://site.com/admin-dev/index.php?controller=AdminModules&configure=mymodule&tab_module=front_office_features&module_name=mymodule&idreviewsOrderby=31&idreviewsOrderway=asc&token=9692b64cf1fff2b3fa99a9bc0478f294

With get all works, and with Tools::getValue() all works too, i get value 31...but if after i do this:

 

Tools::getIsset(Tools::getValue('idreviewsOrderby'));

Verification does not work....why?

So i must use empty(); for my project or i must include "hack" in my module that override Tools::getIsset() function?

 

 

Empty like this?
 

$orderBy = (!empty(Tools::getValue('idreviewsOrderby'))) ? Tools::getValue('idreviewsOrderby') : '1';

With standart php function isset all works, why need override all standart php global functions?

Edited by Kerm (see edit history)
  • Like 1
Link to comment
Share on other sites

 

 

Hello, thanks for your reaply, i already fix this with this code:

 

 

$idreviewsOrderby = Tools::getValue('idreviewsOrderby');

$orderBy = (!empty($idreviewsOrderby)) ? $idreviewsOrderby : '31';
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...