2amigos / yiiaws

Amazon Web Services SDK PHP 2 Wrapper
21 stars 15 forks source link

Wrong argument delegation in A2Base #13

Closed uniconstructor closed 11 years ago

uniconstructor commented 11 years ago

I found a serious error in __call() method.

you shoud use current() function for the $args array.

Without it - it's impossible to pass any arguments to AWS framework functions (because inside $args you will always have an indexed array instread of associative). And you will always have an error "argument validation failed".

That's why only functions without arguments will work.

My example of fixed code is here:

   /**
 * Magic call to wrapped amazon aws methods. If not command found, then call parent component
 * @param string $method
 * @param array $args
 * @return mixed
 */
public function __call($method, $args)
{// the "current" is nessesary here:
    $args = current($args);
    try
    {
        $command = $this->getClient()
            ->getCommand(Inflector::getDefault()->camel($method), $args);

        if ($command)
            return $this->getClient()->execute($command, $args);

    } catch(Exception $e) {
        // do nothing
        throw new CException(Yii::t('zii', $e->getMessage()));//custom added
    }
    return parent::__call($method, $args);
}

Please update the extension.

Kind regards, Ilya.

tonydspaniard commented 11 years ago

Is that a fix for the current? Cuz i did a fix and it was working, though yours looks more elegant.

Could you PR to full branch?

Thanks! Enviado desde mi BlackBerry® de Vodafone

-----Original Message----- From: uniconstructor notifications@github.com Date: Fri, 29 Mar 2013 15:04:45 To: 2amigos/yii-awsyii-aws@noreply.github.com Reply-To: 2amigos/yii-aws reply@reply.github.com Subject: [yii-aws] Wrong argument delegation in A2Base (#13)

I found a serious error in __call() method.

you shoud use current() function for the $args array.

Without it - it's impossible to pass any arguments to AWS framework functions (because inside $args you will always have an indexed array instread of associative). And you will always have an error "argument validation failed".

That's why only functions without arguments will work.

My example of fixed code is here:

   /**
 * Magic call to wrapped amazon aws methods. If not command found, then call parent component
 * @param string $method
 * @param array $args
 * @return mixed
 */
public function __call($method, $args)
{// the "current" is nessesary here:
    $args = current($args);
    try
    {
        $command = $this->getClient()
            ->getCommand(Inflector::getDefault()->camel($method), $args);

        if ($command)
            return $this->getClient()->execute($command, $args);

    } catch(Exception $e) {
        // do nothing
        throw new CException(Yii::t('zii', $e->getMessage()));//custom added
    }
    return parent::__call($method, $args);
}

Please update the extension.

Kind regards, Ilya.


Reply to this email directly or view it on GitHub: https://github.com/2amigos/yii-aws/issues/13