From 31a17d6791322ff79bb894b6e6d72e5c4e284b60 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 27 Aug 2014 21:42:07 +0400 Subject: [PATCH 01/16] Revert "Fixes #4829: Removed `PARSING_ONLY` from `\yii\rest\UrlRule` to allow creating non-GET URLs for forms and tests" This reverts commit 4ffbfec9aa032e5923b6fdfd7db9bc7e25275b40. --- framework/CHANGELOG.md | 1 - framework/rest/UrlRule.php | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 415fdd8..ee92654 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -242,7 +242,6 @@ Yii Framework 2 Change Log - Chg #4586: Signed bigint and unsigned int will be converted into integers when they are loaded from DB by AR (qiangxue) - Chg #4591: `yii\helpers\Url::to()` will no longer prefix relative URLs with the base URL (qiangxue) - Chg #4595: `yii\widgets\LinkPager`'s `nextPageLabel`, `prevPageLabel`, `firstPageLabel`, `lastPageLabel` are now taking `false` instead of `null` for "no label" (samdark) -- Chg #4829: Removed `PARSING_ONLY` from `\yii\rest\UrlRule` to allow creating non-GET URLs for forms and tests (samdark) - Chg: Replaced `clearAll()` and `clearAllAssignments()` in `yii\rbac\ManagerInterface` with `removeAll()`, `removeAllRoles()`, `removeAllPermissions()`, `removeAllRules()` and `removeAllAssignments()` (qiangxue) - Chg: Added `$user` as the first parameter of `yii\rbac\Rule::execute()` (qiangxue) - Chg: `yii\grid\DataColumn::getDataCellValue()` visibility is now `public` to allow accessing the value from a GridView directly (cebe) diff --git a/framework/rest/UrlRule.php b/framework/rest/UrlRule.php index 7968baa..565da5b 100644 --- a/framework/rest/UrlRule.php +++ b/framework/rest/UrlRule.php @@ -201,6 +201,9 @@ class UrlRule extends CompositeUrlRule $config['verb'] = $verbs; $config['pattern'] = rtrim($prefix . '/' . strtr($pattern, $this->tokens), '/'); $config['route'] = $action; + if (!in_array('GET', $verbs)) { + $config['mode'] = \yii\web\UrlRule::PARSING_ONLY; + } $config['suffix'] = $this->suffix; return Yii::createObject($config); From 693ec944f0901831881e147b2808af7222ffe1b8 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 27 Aug 2014 21:13:47 +0200 Subject: [PATCH 02/16] simplified composer call to one speed up process a lot because 3 composer updates are reduced to one --- apps/advanced/tests/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/advanced/tests/README.md b/apps/advanced/tests/README.md index 80bafd6..e1cd5b2 100644 --- a/apps/advanced/tests/README.md +++ b/apps/advanced/tests/README.md @@ -7,9 +7,7 @@ After creating and setting up the advanced application, follow these steps to pr 1. Install Codeception if it's not yet installed: ``` -composer global require "codeception/codeception=2.0.*" -composer global require "codeception/specify=*" -composer global require "codeception/verify=*" +composer global require "codeception/codeception=2.0.*" "codeception/specify=*" "codeception/verify=*" ``` If you've never used Composer for global packages run `composer global status`. It should output: From 32fc3babff418a8e88770fd368decc511391c243 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 27 Aug 2014 21:36:29 +0200 Subject: [PATCH 03/16] Update README.md --- apps/advanced/tests/README.md | 73 +++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/apps/advanced/tests/README.md b/apps/advanced/tests/README.md index e1cd5b2..259c5c5 100644 --- a/apps/advanced/tests/README.md +++ b/apps/advanced/tests/README.md @@ -6,55 +6,54 @@ After creating and setting up the advanced application, follow these steps to pr 1. Install Codeception if it's not yet installed: -``` -composer global require "codeception/codeception=2.0.*" "codeception/specify=*" "codeception/verify=*" -``` + ``` + composer global require "codeception/codeception=2.0.*" "codeception/specify=*" "codeception/verify=*" + ``` -If you've never used Composer for global packages run `composer global status`. It should output: + If you've never used Composer for global packages run `composer global status`. It should output: -``` -Changed current directory to -``` + ``` + Changed current directory to + ``` -Then add `/vendor/bin` to you `PATH` environment variable. Now we're able to use `codecept` from command -line globally. + Then add `/vendor/bin` to you `PATH` environment variable. Now you're able to use `codecept` from command + line globally. 2. Install faker extension by running the following from template root directory where `composer.json` is: -``` -composer require --dev yiisoft/yii2-faker:* -``` - + ``` + composer require --dev yiisoft/yii2-faker:* + ``` 3. Create `yii2_advanced_tests` database then update it by applying migrations: -``` -codeception/bin/yii migrate -``` + ``` + codeception/bin/yii migrate + ``` 4. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in -webserver. In the root directory where `common`, `frontend` etc. are execute the following: + webserver. In the root directory where `common`, `frontend` etc. are execute the following: -``` -php -S localhost:8080 -``` + ``` + php -S localhost:8080 + ``` 5. Now you can run the tests with the following commands: -``` -# frontend tests -cd frontend -codecept build -codecept run - -# backend tests - -cd backend -codecept build -codecept run - -# etc. -``` - -If you already have run `codecept build` for each application, you can run all tests by a single `codecept run` in the -`tests` directory. + ``` + # frontend tests + cd frontend + codecept build + codecept run + + # backend tests + + cd backend + codecept build + codecept run + + # etc. + ``` + + If you already have run `codecept build` for each application, you can run all tests by a single `codecept run` in the + `tests` directory. From c6a1afe2eae92ed8541ac540a872d2d2d9e0a04e Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Wed, 27 Aug 2014 17:02:20 -0400 Subject: [PATCH 04/16] updated bower dependency [skip ci] --- framework/bower.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/bower.json b/framework/bower.json index 05f9753..26fde81 100644 --- a/framework/bower.json +++ b/framework/bower.json @@ -29,6 +29,7 @@ ], "dependencies": { "jquery.inputmask": ">=3.0.0", - "punycode": ">=1.3.0" + "punycode": ">=1.3.0", + "yii2-pjax": ">=2.0.0" } } From 269cb07842f5793b65bf2b0ca002d690b4812d44 Mon Sep 17 00:00:00 2001 From: Vasiliy Baukin Date: Thu, 28 Aug 2014 12:21:59 +0400 Subject: [PATCH 05/16] unneeded use class --- docs/guide/concept-behaviors.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/guide/concept-behaviors.md b/docs/guide/concept-behaviors.md index 3523138..8627c36 100644 --- a/docs/guide/concept-behaviors.md +++ b/docs/guide/concept-behaviors.md @@ -17,7 +17,6 @@ To define a behavior, create a class that extends [[yii\base\Behavior]], or exte ```php namespace app\components; -use yii\base\Model; use yii\base\Behavior; class MyBehavior extends Behavior From 78b5c7db66d75cb168fb3a36fc4f81624bc2c429 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 28 Aug 2014 11:18:14 +0200 Subject: [PATCH 06/16] fixed boolean handling for PostgreSQL - do not allow boolean values for integer columns - use native boolean type with boolean values - removed workaround that turned out to be wrong when schema and values are used correctly. Workaround resulted from wrong usage of boolean values before. fixes #4672 --- framework/CHANGELOG.md | 1 + framework/db/pgsql/Schema.php | 23 ---- tests/unit/data/postgres.sql | 11 +- .../db/pgsql/PostgreSQLActiveRecordTest.php | 128 ++++++++++++++++++++- .../framework/db/pgsql/PostgreSQLSchemaTest.php | 21 ++-- 5 files changed, 147 insertions(+), 37 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index ee92654..df990d3 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -82,6 +82,7 @@ Yii Framework 2 Change Log - Bug #4519: `yii\base\Model::isAttributeRequired()` should check if the `when` option of the validator is set (thiagotalma) - Bug #4592: Fixed `yii help` command was listing incorrect action names for methods like `actionSayNO` (samdark) - Bug #4654: Fixed issue with PostgreSQL and inserting boolean values with batch insert (cebe) +- Bug #4672: Fixed issue with PostgreSQL handling of boolean values in queries, dropped support for using boolean value for integer columns (cebe) - Bug #4727: Fixed wrong Stylus definition in `\yii\web\AssetConverter` (samdark) - Bug #4813: Fixed MSSQL schema that was getting incorrect info about constraints (samdark, SerjRamone, o-rey) - Bug: Fixed inconsistent return of `\yii\console\Application::runAction()` (samdark) diff --git a/framework/db/pgsql/Schema.php b/framework/db/pgsql/Schema.php index 15f9b08..8ccfa72 100644 --- a/framework/db/pgsql/Schema.php +++ b/framework/db/pgsql/Schema.php @@ -167,29 +167,6 @@ class Schema extends \yii\db\Schema } /** - * Determines the PDO type for the given PHP data value. - * @param mixed $data the data whose PDO type is to be determined - * @return integer the PDO type - * @see http://www.php.net/manual/en/pdo.constants.php - */ - public function getPdoType($data) - { - // php type => PDO type - static $typeMap = [ - // https://github.com/yiisoft/yii2/issues/1115 - // Cast boolean to integer values to work around problems with PDO casting false to string '' https://bugs.php.net/bug.php?id=33876 - 'boolean' => \PDO::PARAM_INT, - 'integer' => \PDO::PARAM_INT, - 'string' => \PDO::PARAM_STR, - 'resource' => \PDO::PARAM_LOB, - 'NULL' => \PDO::PARAM_NULL, - ]; - $type = gettype($data); - - return isset($typeMap[$type]) ? $typeMap[$type] : \PDO::PARAM_STR; - } - - /** * Returns all table names in the database. * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema. * @return array all table names in the database. The names have NO schema name prefix. diff --git a/tests/unit/data/postgres.sql b/tests/unit/data/postgres.sql index 8ebc714..4c23a1b 100644 --- a/tests/unit/data/postgres.sql +++ b/tests/unit/data/postgres.sql @@ -35,6 +35,7 @@ CREATE TABLE "customer" ( name varchar(128), address text, status integer DEFAULT 0, + bool_status boolean DEFAULT FALSE, profile_id integer ); @@ -109,8 +110,8 @@ CREATE TABLE "type" ( blob_col bytea, numeric_col decimal(5,2) DEFAULT '33.22', time timestamp NOT NULL DEFAULT '2002-01-01 00:00:00', - bool_col smallint NOT NULL, - bool_col2 smallint DEFAULT '1', + bool_col boolean NOT NULL, + bool_col2 boolean DEFAULT TRUE, ts_default TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, bit_col BIT(8) NOT NULL DEFAULT B'10000010' ); @@ -125,9 +126,9 @@ CREATE TABLE "bool_values" ( INSERT INTO "profile" (description) VALUES ('profile customer 1'); INSERT INTO "profile" (description) VALUES ('profile customer 3'); -INSERT INTO "customer" (email, name, address, status, profile_id) VALUES ('user1@example.com', 'user1', 'address1', 1, 1); -INSERT INTO "customer" (email, name, address, status) VALUES ('user2@example.com', 'user2', 'address2', 1); -INSERT INTO "customer" (email, name, address, status, profile_id) VALUES ('user3@example.com', 'user3', 'address3', 2, 2); +INSERT INTO "customer" (email, name, address, status, bool_status, profile_id) VALUES ('user1@example.com', 'user1', 'address1', 1, true, 1); +INSERT INTO "customer" (email, name, address, status, bool_status) VALUES ('user2@example.com', 'user2', 'address2', 1, true); +INSERT INTO "customer" (email, name, address, status, bool_status, profile_id) VALUES ('user3@example.com', 'user3', 'address3', 2, false, 2); INSERT INTO "category" (name) VALUES ('Books'); INSERT INTO "category" (name) VALUES ('Movies'); diff --git a/tests/unit/framework/db/pgsql/PostgreSQLActiveRecordTest.php b/tests/unit/framework/db/pgsql/PostgreSQLActiveRecordTest.php index a4cb39e..5dc3cbe 100644 --- a/tests/unit/framework/db/pgsql/PostgreSQLActiveRecordTest.php +++ b/tests/unit/framework/db/pgsql/PostgreSQLActiveRecordTest.php @@ -2,8 +2,12 @@ namespace yiiunit\framework\db\pgsql; +use yii\behaviors\TimestampBehavior; +use yii\db\pgsql\Schema; use yiiunit\data\ar\ActiveRecord; +use yiiunit\framework\ar\ActiveRecordTestTrait; use yiiunit\framework\db\ActiveRecordTest; +use yiiunit\TestCase; /** * @group db @@ -13,6 +17,72 @@ class PostgreSQLActiveRecordTest extends ActiveRecordTest { protected $driverName = 'pgsql'; + public function testBooleanAttribute() + { + /* @var $customerClass \yii\db\ActiveRecordInterface */ + $customerClass = $this->getCustomerClass(); + /* @var $this TestCase|ActiveRecordTestTrait */ + $customer = new $customerClass(); + $customer->name = 'boolean customer'; + $customer->email = 'mail@example.com'; + $customer->bool_status = false; + $customer->save(false); + + $customer->refresh(); + $this->assertSame(false, $customer->bool_status); + + $customer->bool_status = true; + $customer->save(false); + + $customer->refresh(); + $this->assertSame(true, $customer->bool_status); + + $customers = $customerClass::find()->where(['bool_status' => true])->all(); + $this->assertEquals(3, count($customers)); + + $customers = $customerClass::find()->where(['bool_status' => false])->all(); + $this->assertEquals(1, count($customers)); + } + + public function testFindAsArray() + { + /* @var $customerClass \yii\db\ActiveRecordInterface */ + $customerClass = $this->getCustomerClass(); + + // asArray + $customer = $customerClass::find()->where(['id' => 2])->asArray()->one(); + $this->assertEquals([ + 'id' => 2, + 'email' => 'user2@example.com', + 'name' => 'user2', + 'address' => 'address2', + 'status' => 1, + 'profile_id' => null, + 'bool_status' => true, + ], $customer); + + // find all asArray + $customers = $customerClass::find()->asArray()->all(); + $this->assertEquals(3, count($customers)); + $this->assertArrayHasKey('id', $customers[0]); + $this->assertArrayHasKey('name', $customers[0]); + $this->assertArrayHasKey('email', $customers[0]); + $this->assertArrayHasKey('address', $customers[0]); + $this->assertArrayHasKey('status', $customers[0]); + $this->assertArrayHasKey('bool_status', $customers[0]); + $this->assertArrayHasKey('id', $customers[1]); + $this->assertArrayHasKey('name', $customers[1]); + $this->assertArrayHasKey('email', $customers[1]); + $this->assertArrayHasKey('address', $customers[1]); + $this->assertArrayHasKey('status', $customers[1]); + $this->assertArrayHasKey('bool_status', $customers[1]); + $this->assertArrayHasKey('id', $customers[2]); + $this->assertArrayHasKey('name', $customers[2]); + $this->assertArrayHasKey('email', $customers[2]); + $this->assertArrayHasKey('address', $customers[2]); + $this->assertArrayHasKey('status', $customers[2]); + $this->assertArrayHasKey('bool_status', $customers[2]); + } public function testBooleanValues() { @@ -40,6 +110,42 @@ class PostgreSQLActiveRecordTest extends ActiveRecordTest $this->assertSame(false, BoolAR::find()->where(['bool_col' => false])->one($db)->bool_col); } + /** + * https://github.com/yiisoft/yii2/issues/4672 + */ + public function testBooleanValues2() + { + $db = $this->getConnection(); + $db->charset = 'utf8'; + + $db->createCommand("DROP TABLE IF EXISTS bool_user;")->execute(); + $db->createCommand()->createTable('bool_user', [ + 'id' => Schema::TYPE_PK, + 'username' => Schema::TYPE_STRING . ' NOT NULL', + 'auth_key' => Schema::TYPE_STRING . '(32) NOT NULL', + 'password_hash' => Schema::TYPE_STRING . ' NOT NULL', + 'password_reset_token' => Schema::TYPE_STRING, + 'email' => Schema::TYPE_STRING . ' NOT NULL', + 'role' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10', + + 'status' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10', + 'created_at' => Schema::TYPE_INTEGER . ' NOT NULL', + 'updated_at' => Schema::TYPE_INTEGER . ' NOT NULL', + ])->execute(); + $db->createCommand()->addColumn('bool_user', 'is_deleted', Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT FALSE')->execute(); + + $user = new UserAR(); + $user->username = 'test'; + $user->auth_key = 'test'; + $user->password_hash = 'test'; + $user->email = 'test@example.com'; + $user->save(false); + + $this->assertEquals(1, count(UserAR::find()->where(['is_deleted' => false])->all($db))); + $this->assertEquals(0, count(UserAR::find()->where(['is_deleted' => true])->all($db))); + $this->assertEquals(1, count(UserAR::find()->where(['is_deleted' => [true, false]])->all($db))); + } + public function testBooleanDefaultValues() { $model = new BoolAR(); @@ -61,4 +167,24 @@ class BoolAR extends ActiveRecord { return 'bool_values'; } -} \ No newline at end of file +} + +class UserAR extends ActiveRecord +{ + const STATUS_DELETED = 0; + const STATUS_ACTIVE = 10; + const ROLE_USER = 10; + + public static function tableName() + { + return '{{%bool_user}}'; + } + + public function behaviors() + { + return [ + TimestampBehavior::className(), + ]; + } +} + diff --git a/tests/unit/framework/db/pgsql/PostgreSQLSchemaTest.php b/tests/unit/framework/db/pgsql/PostgreSQLSchemaTest.php index 9654c79..5f6c403 100644 --- a/tests/unit/framework/db/pgsql/PostgreSQLSchemaTest.php +++ b/tests/unit/framework/db/pgsql/PostgreSQLSchemaTest.php @@ -47,14 +47,19 @@ class PostgreSQLSchemaTest extends SchemaTest $columns['blob_col']['type'] = 'binary'; $columns['numeric_col']['dbType'] = 'numeric'; $columns['numeric_col']['size'] = null; - $columns['bool_col']['dbType'] = 'int2'; + $columns['bool_col']['type'] = 'boolean'; + $columns['bool_col']['phpType'] = 'boolean'; + $columns['bool_col']['dbType'] = 'bool'; $columns['bool_col']['size'] = null; - $columns['bool_col']['precision'] = 16; - $columns['bool_col']['scale'] = 0; - $columns['bool_col2']['dbType'] = 'int2'; + $columns['bool_col']['precision'] = null; + $columns['bool_col']['scale'] = null; + $columns['bool_col2']['type'] = 'boolean'; + $columns['bool_col2']['phpType'] = 'boolean'; + $columns['bool_col2']['dbType'] = 'bool'; $columns['bool_col2']['size'] = null; - $columns['bool_col2']['precision'] = 16; - $columns['bool_col2']['scale'] = 0; + $columns['bool_col2']['precision'] = null; + $columns['bool_col2']['scale'] = null; + $columns['bool_col2']['defaultValue'] = true; $columns['ts_default']['defaultValue'] = new Expression('now()'); $columns['bit_col']['dbType'] = 'bit'; $columns['bit_col']['size'] = 8; @@ -71,8 +76,8 @@ class PostgreSQLSchemaTest extends SchemaTest [0, \PDO::PARAM_INT], [1, \PDO::PARAM_INT], [1337, \PDO::PARAM_INT], - [true, \PDO::PARAM_INT], - [false, \PDO::PARAM_INT], + [true, \PDO::PARAM_BOOL], + [false, \PDO::PARAM_BOOL], [$fp = fopen(__FILE__, 'rb'), \PDO::PARAM_LOB], ]; From c27c9de5b862edaf17ff1ee940bae7cf0b922724 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 28 Aug 2014 12:14:05 +0200 Subject: [PATCH 07/16] check if sphinx is installed --- tests/unit/data/travis/sphinx-setup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/unit/data/travis/sphinx-setup.sh b/tests/unit/data/travis/sphinx-setup.sh index ba09595..2c097aa 100755 --- a/tests/unit/data/travis/sphinx-setup.sh +++ b/tests/unit/data/travis/sphinx-setup.sh @@ -2,6 +2,8 @@ SCRIPT=$(readlink -f "$0") CWD=$(dirname "$SCRIPT") +sudo dpkg -l |grep sphinx + # log files sudo mkdir /var/log/sphinx sudo touch /var/log/sphinx/searchd.log From 326d26af0667e6651e8191d7ec3c83473016c990 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 28 Aug 2014 13:49:36 +0200 Subject: [PATCH 08/16] install cubrid DB not using sudo and use travis cache --- .gitignore | 2 + .travis.yml | 12 ++++++ tests/unit/data/travis/cubrid-setup.sh | 68 +++++++++++++++++++++++++++++----- 3 files changed, 73 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index fb5029b..657cc74 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,8 @@ Thumbs.db # composer vendor dir /vendor +# cubrid install dir +/cubrid # composer itself is not needed composer.phar diff --git a/.travis.yml b/.travis.yml index 6657fab..a373965 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,9 @@ php: - hhvm - hhvm-nightly +env: + - CUBRID_VERSION=9.3.0/CUBRID-9.3.0.0206 CUBRID_PDO_VERSION=9.2.0.0001 + # run build against hhvm but allow them to fail # http://docs.travis-ci.com/user/build-configuration/#Rows-That-are-Allowed-To-Fail matrix: @@ -21,6 +24,15 @@ services: - elasticsearch - mongodb +# faster builds on new travis setup not using sudo +sudo: false + +# cache vendor dirs +cache: + directories: + - cubrid + - vendor + # try running against postgres 9.3 addons: postgresql: "9.3" diff --git a/tests/unit/data/travis/cubrid-setup.sh b/tests/unit/data/travis/cubrid-setup.sh index 13b0a4b..1eaa257 100755 --- a/tests/unit/data/travis/cubrid-setup.sh +++ b/tests/unit/data/travis/cubrid-setup.sh @@ -7,18 +7,64 @@ if (php --version | grep -i HipHop > /dev/null); then exit 0 fi +CWD=$(pwd) + # cubrid dbms -echo 'yes' | sudo add-apt-repository ppa:cubrid/cubrid -sudo apt-get update -sudo apt-get install cubrid -/etc/profile.d/cubrid.sh -sudo apt-get install cubrid-demodb +mkdir -p cubrid/$CUBRID_VERSION +cd cubrid +if (test -f $CUBRID_VERSION-linux.x86_64.tar.gz); then + echo "CUBRID is already installed" +else + wget http://ftp.cubrid.org/CUBRID_Engine/$CUBRID_VERSION-linux.x86_64.tar.gz -O $CUBRID_VERSION-linux.x86_64.tar.gz +fi + + cd $CUBRID_VERSION + tar xzvf ../../$CUBRID_VERSION-linux.x86_64.tar.gz + cd ../.. + + +# setting cubrid env +CUBRID=$CWD/cubrid/$CUBRID_VERSION/CUBRID +CUBRID_DATABASES=$CUBRID/databases +CUBRID_LANG=en_US + +ld_lib_path=`printenv LD_LIBRARY_PATH` +if [ "$ld_lib_path" = "" ] +then + LD_LIBRARY_PATH=$CUBRID/lib +else + LD_LIBRARY_PATH=$CUBRID/lib:$LD_LIBRARY_PATH +fi + +SHLIB_PATH=$LD_LIBRARY_PATH +LIBPATH=$LD_LIBRARY_PATH +PATH=$CUBRID/bin:$CUBRID/cubridmanager:$PATH + +export CUBRID +export CUBRID_DATABASES +export CUBRID_LANG +export LD_LIBRARY_PATH +export SHLIB_PATH +export LIBPATH +export PATH + +# start cubrid +cubrid service start +# create and start the demo db +$CUBRID/demo/make_cubrid_demo.sh +cubrid server start demodb + +echo "" +echo "Installed CUBRID $CUBRID_VERSION" +echo "" # cubrid pdo install_pdo_cubrid() { - wget "http://pecl.php.net/get/PDO_CUBRID-9.2.0.0001.tgz" && - tar -zxf "PDO_CUBRID-9.2.0.0001.tgz" && - sh -c "cd PDO_CUBRID-9.2.0.0001 && phpize && ./configure && make && sudo make install" + if (test "! -f PDO_CUBRID-$CUBRID_PDO_VERSION.tgz"); then + wget "http://pecl.php.net/get/PDO_CUBRID-$CUBRID_PDO_VERSION.tgz" + fi + tar -zxf "PDO_CUBRID-$CUBRID_PDO_VERSION.tgz" + sh -c "cd PDO_CUBRID-$CUBRID_PDO_VERSION && phpize && ./configure && make && sudo make install" echo "extension=pdo_cubrid.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini @@ -27,4 +73,8 @@ install_pdo_cubrid() { install_pdo_cubrid > ~/pdo_cubrid.log || ( echo "=== PDO CUBRID BUILD FAILED ==="; cat ~/pdo_cubrid.log ) -echo "Installed CUBRID `dpkg -s cubrid |grep Version`" +echo "" +echo "Installed CUBRID PDO $CUBRID_PDO_VERSION" +echo "" + +cd .. From 83f5f49469b45193e1e6a8a5d55d31d62d1ac5ea Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 28 Aug 2014 14:01:29 +0200 Subject: [PATCH 09/16] try mongodb without sudo --- tests/unit/data/travis/mongodb-setup.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/unit/data/travis/mongodb-setup.sh b/tests/unit/data/travis/mongodb-setup.sh index b79a897..fb2e80d 100755 --- a/tests/unit/data/travis/mongodb-setup.sh +++ b/tests/unit/data/travis/mongodb-setup.sh @@ -2,10 +2,12 @@ # # install mongodb +mongod --version + echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini -sudo sh -c 'echo "setParameter = textSearchEnabled=true" >> /etc/mongodb.conf' -cat /etc/mongodb.conf -mongod --version +# version 2.6 has this enabled by default +#sudo sh -c 'echo "setParameter = textSearchEnabled=true" >> /etc/mongodb.conf' +cat /etc/mongodb.conf -sudo service mongodb restart +#sudo service mongodb restart From 9174358f7e64a896f421384e77ac89f08dc8e9ba Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 28 Aug 2014 14:17:15 +0200 Subject: [PATCH 10/16] fixed sphinx setup --- tests/unit/data/travis/sphinx-setup.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/unit/data/travis/sphinx-setup.sh b/tests/unit/data/travis/sphinx-setup.sh index 2c097aa..83fd7c6 100755 --- a/tests/unit/data/travis/sphinx-setup.sh +++ b/tests/unit/data/travis/sphinx-setup.sh @@ -2,21 +2,22 @@ SCRIPT=$(readlink -f "$0") CWD=$(dirname "$SCRIPT") -sudo dpkg -l |grep sphinx +# work around https://github.com/travis-ci/travis-ci/issues/2728 +PATH=$PATH:/usr/local/sphinx-2.1.9/bin # log files -sudo mkdir /var/log/sphinx -sudo touch /var/log/sphinx/searchd.log -sudo touch /var/log/sphinx/query.log -sudo chmod -R 777 /var/log/sphinx # ugly (for travis) +#sudo mkdir /var/log/sphinx +#sudo touch /var/log/sphinx/searchd.log +#sudo touch /var/log/sphinx/query.log +#sudo chmod -R 777 /var/log/sphinx # ugly (for travis) # spl dir -sudo mkdir /var/lib/sphinx -sudo chmod 777 /var/lib/sphinx # ugly (for travis) +#sudo mkdir /var/lib/sphinx +#sudo chmod 777 /var/lib/sphinx # ugly (for travis) # run dir pid -sudo mkdir /var/run/sphinx -sudo chmod 777 /var/run/sphinx # ugly (for travis) +#sudo mkdir /var/run/sphinx +#sudo chmod 777 /var/run/sphinx # ugly (for travis) # Setup source database mysql -D yiitest -u travis < $CWD/../sphinx/source.sql From e648aef799c23d75696c4972998baef8c3df0ec6 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 28 Aug 2014 14:43:49 +0200 Subject: [PATCH 11/16] sphinx setup without sudo --- tests/unit/data/sphinx/sphinx.conf | 16 ++++++++-------- tests/unit/data/travis/cubrid-setup.sh | 4 ++-- tests/unit/data/travis/sphinx-setup.sh | 4 ++++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/unit/data/sphinx/sphinx.conf b/tests/unit/data/sphinx/sphinx.conf index 909fdbd..583bcc5 100644 --- a/tests/unit/data/sphinx/sphinx.conf +++ b/tests/unit/data/sphinx/sphinx.conf @@ -68,7 +68,7 @@ source yii2_test_item_delta_src : yii2_test_item_src index yii2_test_article_index { source = yii2_test_article_src - path = /var/lib/sphinx/yii2_test_article + path = SPHINX_BASE_DIR/yii2_test_article docinfo = extern charset_type = sbcs } @@ -77,7 +77,7 @@ index yii2_test_article_index index yii2_test_item_index { source = yii2_test_item_src - path = /var/lib/sphinx/yii2_test_item + path = SPHINX_BASE_DIR/yii2_test_item docinfo = extern charset_type = sbcs } @@ -86,14 +86,14 @@ index yii2_test_item_index index yii2_test_item_delta_index : yii2_test_item_index { source = yii2_test_item_delta_src - path = /var/lib/sphinx/yii2_test_item_delta + path = SPHINX_BASE_DIR/yii2_test_item_delta } index yii2_test_rt_index { type = rt - path = /var/lib/sphinx/yii2_test_rt + path = SPHINX_BASE_DIR/yii2_test_rt rt_field = title rt_field = content rt_attr_uint = type_id @@ -118,15 +118,15 @@ searchd { listen = 127.0.0.1:9312 listen = 9306:mysql41 - log = /var/log/sphinx/searchd.log - query_log = /var/log/sphinx/query.log + log = SPHINX_BASE_DIR/searchd.log + query_log = SPHINX_BASE_DIR/query.log read_timeout = 5 max_children = 30 - pid_file = /var/run/sphinx/searchd.pid + pid_file = SPHINX_BASE_DIR/searchd.pid max_matches = 1000 seamless_rotate = 1 preopen_indexes = 1 unlink_old = 1 workers = threads # for RT to work - binlog_path = /var/lib/sphinx + binlog_path = SPHINX_BASE_DIR } diff --git a/tests/unit/data/travis/cubrid-setup.sh b/tests/unit/data/travis/cubrid-setup.sh index 1eaa257..dfcbfce 100755 --- a/tests/unit/data/travis/cubrid-setup.sh +++ b/tests/unit/data/travis/cubrid-setup.sh @@ -19,7 +19,7 @@ else fi cd $CUBRID_VERSION - tar xzvf ../../$CUBRID_VERSION-linux.x86_64.tar.gz + tar xzf ../../$CUBRID_VERSION-linux.x86_64.tar.gz cd ../.. @@ -64,7 +64,7 @@ install_pdo_cubrid() { wget "http://pecl.php.net/get/PDO_CUBRID-$CUBRID_PDO_VERSION.tgz" fi tar -zxf "PDO_CUBRID-$CUBRID_PDO_VERSION.tgz" - sh -c "cd PDO_CUBRID-$CUBRID_PDO_VERSION && phpize && ./configure && make && sudo make install" + sh -c "cd PDO_CUBRID-$CUBRID_PDO_VERSION && phpize && ./configure --prefix=$CWD/cubrid/PDO_CUBRID-$CUBRID_PDO_VERSION && make && sudo make install" echo "extension=pdo_cubrid.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini diff --git a/tests/unit/data/travis/sphinx-setup.sh b/tests/unit/data/travis/sphinx-setup.sh index 83fd7c6..09ddf57 100755 --- a/tests/unit/data/travis/sphinx-setup.sh +++ b/tests/unit/data/travis/sphinx-setup.sh @@ -5,6 +5,10 @@ CWD=$(dirname "$SCRIPT") # work around https://github.com/travis-ci/travis-ci/issues/2728 PATH=$PATH:/usr/local/sphinx-2.1.9/bin +mkdir -p sphinx + +sed -i s\~SPHINX_BASE_DIR~$PWD/sphinx~g $CWD/../sphinx/sphinx.conf + # log files #sudo mkdir /var/log/sphinx #sudo touch /var/log/sphinx/searchd.log From 68323f6428497a05b392b5fa595f155f3609692e Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 28 Aug 2014 14:49:32 +0200 Subject: [PATCH 12/16] fixed cubrid PDO --- tests/unit/data/travis/cubrid-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/data/travis/cubrid-setup.sh b/tests/unit/data/travis/cubrid-setup.sh index dfcbfce..30b3215 100755 --- a/tests/unit/data/travis/cubrid-setup.sh +++ b/tests/unit/data/travis/cubrid-setup.sh @@ -64,9 +64,9 @@ install_pdo_cubrid() { wget "http://pecl.php.net/get/PDO_CUBRID-$CUBRID_PDO_VERSION.tgz" fi tar -zxf "PDO_CUBRID-$CUBRID_PDO_VERSION.tgz" - sh -c "cd PDO_CUBRID-$CUBRID_PDO_VERSION && phpize && ./configure --prefix=$CWD/cubrid/PDO_CUBRID-$CUBRID_PDO_VERSION && make && sudo make install" + sh -c "cd PDO_CUBRID-$CUBRID_PDO_VERSION && phpize && ./configure --prefix=$CWD/cubrid/PDO_CUBRID-$CUBRID_PDO_VERSION && make" - echo "extension=pdo_cubrid.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini + echo "extension=$CWD/cubrid/PDO_CUBRID-$CUBRID_PDO_VERSION/modules/pdo_cubrid.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini return $? } From 63543c0a81240748253bea95decd36ca4c16740d Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 28 Aug 2014 15:01:55 +0200 Subject: [PATCH 13/16] enable mongo text search --- tests/unit/data/travis/mongodb-setup.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/unit/data/travis/mongodb-setup.sh b/tests/unit/data/travis/mongodb-setup.sh index fb2e80d..1bcf100 100755 --- a/tests/unit/data/travis/mongodb-setup.sh +++ b/tests/unit/data/travis/mongodb-setup.sh @@ -6,8 +6,7 @@ mongod --version echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini -# version 2.6 has this enabled by default -#sudo sh -c 'echo "setParameter = textSearchEnabled=true" >> /etc/mongodb.conf' -cat /etc/mongodb.conf +# enable text search +mongo --eval 'db.adminCommand( { setParameter: true, textSearchEnabled : true})' -#sudo service mongodb restart +cat /etc/mongodb.conf From c4dffa0f1fb1f3e0a5f6e811d7caaecaddd908d3 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 28 Aug 2014 15:08:37 +0200 Subject: [PATCH 14/16] simplified travis installation --- .travis.yml | 4 +--- tests/unit/data/travis/cubrid-setup.sh | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index a373965..d3a51df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,9 +47,7 @@ install: - tests/unit/data/travis/memcache-setup.sh - tests/unit/data/travis/cubrid-setup.sh # codeception - - composer global require "codeception/codeception=2.0.*" - - composer global require "codeception/specify=*" - - composer global require "codeception/verify=*" + - composer global require "codeception/codeception=2.0.*" "codeception/specify=*" "codeception/verify=*" # basic and advanced application: - tests/unit/data/travis/setup-apps.sh diff --git a/tests/unit/data/travis/cubrid-setup.sh b/tests/unit/data/travis/cubrid-setup.sh index 30b3215..67b4bf2 100755 --- a/tests/unit/data/travis/cubrid-setup.sh +++ b/tests/unit/data/travis/cubrid-setup.sh @@ -60,8 +60,8 @@ echo "" # cubrid pdo install_pdo_cubrid() { - if (test "! -f PDO_CUBRID-$CUBRID_PDO_VERSION.tgz"); then - wget "http://pecl.php.net/get/PDO_CUBRID-$CUBRID_PDO_VERSION.tgz" + if (test "! (-f PDO_CUBRID-$CUBRID_PDO_VERSION.tgz)"); then + wget "http://pecl.php.net/get/PDO_CUBRID-$CUBRID_PDO_VERSION.tgz" -O PDO_CUBRID-$CUBRID_PDO_VERSION.tgz fi tar -zxf "PDO_CUBRID-$CUBRID_PDO_VERSION.tgz" sh -c "cd PDO_CUBRID-$CUBRID_PDO_VERSION && phpize && ./configure --prefix=$CWD/cubrid/PDO_CUBRID-$CUBRID_PDO_VERSION && make" From 452fcc0fcfaf3bd9f7afa8d75594f28c6eb82f02 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Thu, 28 Aug 2014 10:32:34 -0400 Subject: [PATCH 15/16] Fixes #4845 --- docs/guide/intro-upgrade-from-v1.md | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/guide/intro-upgrade-from-v1.md b/docs/guide/intro-upgrade-from-v1.md index 46f90df..79bd0bb 100644 --- a/docs/guide/intro-upgrade-from-v1.md +++ b/docs/guide/intro-upgrade-from-v1.md @@ -459,13 +459,45 @@ public function init() } ``` -There where some problems with overriding the constructor of an ActiveRecord class in 1.1. These are not present in +There were some problems with overriding the constructor of an ActiveRecord class in 1.1. These are not present in version 2.0 anymore. Note that when adding parameters to the constructor you might have to override [[yii\db\ActiveRecord::instantiate()]]. There are many other changes and enhancements to Active Record. Please refer to the [Active Record](db-active-record.md) section for more details. +Active Record Behaviors +----------------------- + +In 2.0, we have dropped the base behavior class `CActiveRecordBehavior`. If you want to create an Active Record Behavior, +you will have to extend directly from `yii\base\Behavior`. If the behavior class needs to respond to some events +of the owner, you have to override the `events()` method like the following, + +```php +namespace app\components; + +use yii\db\ActiveRecord; +use yii\base\Behavior; + +class MyBehavior extends Behavior +{ + // ... + + public function events() + { + return [ + ActiveRecord::EVENT_BEFORE_VALIDATE => 'beforeValidate', + ]; + } + + public function beforeValidate($event) + { + // ... + } +} +``` + + User and IdentityInterface -------------------------- From 1336cff31af0d9cd22e6e0f178eb074694d4b06f Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Thu, 28 Aug 2014 14:27:35 -0400 Subject: [PATCH 16/16] Added bower.json to bootstrap and jui extensions. --- extensions/bootstrap/bower.json | 21 +++++++++++++++++ extensions/jui/bower.json | 20 +++++++++++++++++ extensions/jui/composer.json | 50 +++++++++++++++++++++-------------------- 3 files changed, 67 insertions(+), 24 deletions(-) create mode 100644 extensions/bootstrap/bower.json create mode 100644 extensions/jui/bower.json diff --git a/extensions/bootstrap/bower.json b/extensions/bootstrap/bower.json new file mode 100644 index 0000000..28261f6 --- /dev/null +++ b/extensions/bootstrap/bower.json @@ -0,0 +1,21 @@ +{ + "name": "yii2-bootstrap", + "version": "2.0.0", + "homepage": "http://www.yiiframework.com/", + "authors": [ + "Qiang Xue " + ], + "description": "The Twitter Bootstrap extension for the Yii framework", + "keywords": [ + "yii2", + "bootstrap" + ], + "license": "BSD-3-Clause", + "ignore": [ + "**/.*", + "**/*" + ], + "dependencies": { + "bootstrap": ">=3.0.0" + } +} diff --git a/extensions/jui/bower.json b/extensions/jui/bower.json new file mode 100644 index 0000000..2d49c7b --- /dev/null +++ b/extensions/jui/bower.json @@ -0,0 +1,20 @@ +{ + "name": "yii2-jui", + "version": "2.0.0", + "homepage": "http://www.yiiframework.com/", + "authors": [ + "Qiang Xue " + ], + "description": "The Jquery UI extension for the Yii framework", + "keywords": [ + "yii2", "Jquery UI" + ], + "license": "BSD-3-Clause", + "ignore": [ + "**/.*", + "**/*" + ], + "dependencies": { + "jquery.ui": ">=1.10.0" + } +} diff --git a/extensions/jui/composer.json b/extensions/jui/composer.json index f129fef..ff67c6d 100644 --- a/extensions/jui/composer.json +++ b/extensions/jui/composer.json @@ -1,26 +1,28 @@ { - "name": "yiisoft/yii2-jui", - "description": "The Jquery UI extension for the Yii framework", - "keywords": ["yii2", "Jquery UI", "renderer"], - "type": "yii2-extension", - "license": "BSD-3-Clause", - "support": { - "issues": "https://github.com/yiisoft/yii2/issues?labels=ext%3Ajui", - "forum": "http://www.yiiframework.com/forum/", - "wiki": "http://www.yiiframework.com/wiki/", - "irc": "irc://irc.freenode.net/yii", - "source": "https://github.com/yiisoft/yii2" - }, - "authors": [ - { - "name": "Qiang Xue", - "email": "qiang.xue@gmail.com" - } - ], - "require": { - "yiisoft/yii2": "*" - }, - "autoload": { - "psr-4": { "yii\\jui\\": "" } - } + "name": "yiisoft/yii2-jui", + "description": "The Jquery UI extension for the Yii framework", + "keywords": ["yii2", "Jquery UI"], + "type": "yii2-extension", + "license": "BSD-3-Clause", + "support": { + "issues": "https://github.com/yiisoft/yii2/issues?labels=ext%3Ajui", + "forum": "http://www.yiiframework.com/forum/", + "wiki": "http://www.yiiframework.com/wiki/", + "irc": "irc://irc.freenode.net/yii", + "source": "https://github.com/yiisoft/yii2" + }, + "authors": [ + { + "name": "Qiang Xue", + "email": "qiang.xue@gmail.com" + } + ], + "require": { + "yiisoft/yii2": "*" + }, + "autoload": { + "psr-4": { + "yii\\jui\\": "" + } + } }