-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[3.1.0] Issue with doLowUpdate() - First argument is not array #12742
Comments
Fixed in the |
@sergeyklay I think it would be necessary to release a hotfix version (like 3.1.0-1) immediately, because this is really a serious bug. |
Not really a serious bug, it only happens in one case - if in new Robots you will set primary key by yourself and it will exists in database, like in this case from this issue, and most of the time you shouldn't do it like this anyway, otherwise there is no this error. You can always use zephir and compile and have it fixed immediately. Though i guess it's not problem to release version like you mention and recreate build right now, i guess in some apps to not have additional query for select you could use it perhaps. |
@Jurigag No, it may occur even with a new primary key, if you save the model and then save it again. Let's take a k-v table as a example: <?php
use Phalcon\Mvc\Model;
use Phalcon\Db\Adapter\Pdo\Mysql as PhalconMysql;
class TestPhalconSnapshot extends Model
{
public $key;
public $value;
public function initialize()
{
$this->setSource('test_snapshot');
$this->keepSnapshots(true);
}
}
$di = new Phalcon\Di\FactoryDefault;
$di->set('db', function () {
return new PhalconMysql([
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'phalcon_test',
]);
});
/* @var PhalconMysql $db */
$db = $di->getShared('db');
$db->execute('CREATE TABLE IF NOT EXISTS `test_snapshot` (
`key` VARCHAR(32) COLLATE utf8_unicode_ci NOT NULL,
`value` TEXT COLLATE utf8_unicode_ci,
PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci');
Model::setup([
'exceptionOnFailedSave' => true,
]);
$model = new TestPhalconSnapshot;
$model->key = microtime();
$model->value = '';
$model->save(); // OK here
$model->value = time();
$model->save(); // Error Result: christopher@Christopher-Macmini:/var/www/test/php/phalcon/3.1.0$ php --ri phalcon|grep Ver
Version => 3.1.0
Powered by Zephir => Version 0.9.6a-dev-1bad5e7742
christopher@Christopher-Macmini:/var/www/test/php/phalcon/3.1.0$ php model.snapshot.bug.php
PHP Warning: First argument is not an array in /var/www/test/php/phalcon/3.1.0/model.snapshot.bug.php on line 46
PHP Stack trace:
PHP 1. {main}() /var/www/test/php/phalcon/3.1.0/model.snapshot.bug.php:0
PHP 2. Phalcon\Mvc\Model->save() /var/www/test/php/phalcon/3.1.0/model.snapshot.bug.php:46
PHP 3. Phalcon\Mvc\Model->_doLowUpdate() /var/www/test/php/phalcon/3.1.0/model.snapshot.bug.php:46 |
use Phalcon\Db;
use Phalcon\Di\FactoryDefault;
use Phalcon\Mvc\Model;
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
Model::setup(['castOnHydrate' => true]);
$di = new FactoryDefault();
$di->set(
'db',
function () {
$adapter = new \Phalcon\Db\Adapter\Pdo\Mysql(
[
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'phalcon_test',
'options' => [
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
],
'charset' => 'utf8',
]
);
return $adapter;
}
);
class Robots extends \Phalcon\Mvc\Model
{
public function initialize()
{
$this->keepSnapshots(true);
}
}
$robot = new Robots();
$robot->name = "asd";
$robot->type = "mechanical";
$robot->text = "text";
$robot->datetime = "1952-01-01 00:00:00";
$robot->save();
$robot->name = "asds";
$robot->save(); don't have a warning, you sure? |
Results in:
ERROR: First argument is not an array
The text was updated successfully, but these errors were encountered: