From c2c2b318127d68ce9b9ab5dd176f400101b16af3 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 09:57:09 +0300 Subject: [PATCH 01/69] fix composer.json --- composer.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/composer.json b/composer.json index 447f29a8..dc00941f 100644 --- a/composer.json +++ b/composer.json @@ -38,5 +38,11 @@ "branch-alias": { "dev-master": "2.0.x-dev" } + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "yiisoft/yii2-composer": true + } } } From bc778c683f9bcb6f8dadc601bed67b6529187db0 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 10:00:48 +0300 Subject: [PATCH 02/69] try fix action --- .github/workflows/build.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 73f47542..261b87d9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,8 @@ on: - - pull_request - - push + pull_request: + push: + branches: + - master name: build @@ -17,16 +19,9 @@ jobs: strategy: matrix: os: - - ubuntu-18.04 + - ubuntu-20.04 php: - - "5.4" - - "5.5" - - "5.6" - - "7.0" - - "7.1" - - "7.2" - - "7.3" - "7.4" steps: From 46167c6cf9693b5ce1bfc6a998b6693ac94d1dc1 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 10:05:04 +0300 Subject: [PATCH 03/69] fix sphinx --- tests/data/actions/sphinx-setup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/data/actions/sphinx-setup.sh b/tests/data/actions/sphinx-setup.sh index 4e67fdb4..698575f8 100644 --- a/tests/data/actions/sphinx-setup.sh +++ b/tests/data/actions/sphinx-setup.sh @@ -2,6 +2,8 @@ SCRIPT=$(readlink -f "$0") CWD=$(dirname "$SCRIPT") +sudo apt -y install libmysqlclient20 + # install sphinx from https://sphinxsearch.com/downloads/release/ wget http://sphinxsearch.com/files/sphinxsearch_2.2.11-release-1~xenial_amd64.deb sudo dpkg -i sphinxsearch_2.2.11-release-1~xenial_amd64.deb From 6c1274499bb08c53424b32651be10308927d275a Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 10:10:32 +0300 Subject: [PATCH 04/69] fix --- .github/workflows/build.yml | 2 +- tests/data/actions/sphinx-setup.sh | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 261b87d9..575cb081 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - ubuntu-20.04 php: - - "7.4" + - "5.4" steps: - name: Checkout diff --git a/tests/data/actions/sphinx-setup.sh b/tests/data/actions/sphinx-setup.sh index 698575f8..4e67fdb4 100644 --- a/tests/data/actions/sphinx-setup.sh +++ b/tests/data/actions/sphinx-setup.sh @@ -2,8 +2,6 @@ SCRIPT=$(readlink -f "$0") CWD=$(dirname "$SCRIPT") -sudo apt -y install libmysqlclient20 - # install sphinx from https://sphinxsearch.com/downloads/release/ wget http://sphinxsearch.com/files/sphinxsearch_2.2.11-release-1~xenial_amd64.deb sudo dpkg -i sphinxsearch_2.2.11-release-1~xenial_amd64.deb From b869ba836511b04473ef0093fba2390e442efc64 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 10:13:00 +0300 Subject: [PATCH 05/69] fix --- tests/data/actions/sphinx-setup.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/data/actions/sphinx-setup.sh b/tests/data/actions/sphinx-setup.sh index 4e67fdb4..27382092 100644 --- a/tests/data/actions/sphinx-setup.sh +++ b/tests/data/actions/sphinx-setup.sh @@ -2,6 +2,11 @@ SCRIPT=$(readlink -f "$0") CWD=$(dirname "$SCRIPT") +# https://askubuntu.com/a/1337909 +echo 'deb http://security.ubuntu.com/ubuntu xenial-security main' | sudo tee /etc/apt/sources.list.d/xenial-security.list +sudo apt update +sudo apt install libmysqlclient20 + # install sphinx from https://sphinxsearch.com/downloads/release/ wget http://sphinxsearch.com/files/sphinxsearch_2.2.11-release-1~xenial_amd64.deb sudo dpkg -i sphinxsearch_2.2.11-release-1~xenial_amd64.deb From 7b3e9a3d32f8d14f2c17ba437b8d5abddff90686 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 10:22:26 +0300 Subject: [PATCH 06/69] fix --- tests/data/source.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/data/source.sql b/tests/data/source.sql index 9f37ad4d..7e9d995f 100644 --- a/tests/data/source.sql +++ b/tests/data/source.sql @@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS `yii2_test_article` ( `author_id` int(11) NOT NULL, `create_date` datetime NOT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; +) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3; CREATE TABLE IF NOT EXISTS `yii2_test_item` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -23,19 +23,19 @@ CREATE TABLE IF NOT EXISTS `yii2_test_item` ( `category_id` int(11) NOT NULL, `price` float NOT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3; +) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3; CREATE TABLE IF NOT EXISTS `yii2_test_tag` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5; +) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5; CREATE TABLE IF NOT EXISTS `yii2_test_article_tag` ( `article_id` int(11) NOT NULL, `tag_id` int(11) NOT NULL, PRIMARY KEY (`article_id`,`tag_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; +) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO `yii2_test_article` (`id`, `title`, `content`, `author_id`, `create_date`) VALUES (1, 'About cats', 'This article is about cats. Repeated.', 1, '2013-10-23 00:00:00'), @@ -1056,4 +1056,4 @@ INSERT INTO `yii2_test_article_tag` (`article_id`, `tag_id`) VALUES (1, 2), (1, 3), (2, 3), -(2, 4); \ No newline at end of file +(2, 4); From e82921ffd8324a98cbc54acc0a2810c636ac5228 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 10:25:18 +0300 Subject: [PATCH 07/69] fix --- tests/data/source.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/data/source.sql b/tests/data/source.sql index 7e9d995f..a2ec7f00 100644 --- a/tests/data/source.sql +++ b/tests/data/source.sql @@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS `yii2_test_article` ( `author_id` int(11) NOT NULL, `create_date` datetime NOT NULL, PRIMARY KEY (`id`) -) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3; +) CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3; CREATE TABLE IF NOT EXISTS `yii2_test_item` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -23,19 +23,19 @@ CREATE TABLE IF NOT EXISTS `yii2_test_item` ( `category_id` int(11) NOT NULL, `price` float NOT NULL, PRIMARY KEY (`id`) -) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3; +) CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3; CREATE TABLE IF NOT EXISTS `yii2_test_tag` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`) -) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5; +) CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5; CREATE TABLE IF NOT EXISTS `yii2_test_article_tag` ( `article_id` int(11) NOT NULL, `tag_id` int(11) NOT NULL, PRIMARY KEY (`article_id`,`tag_id`) -) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=MyISAM DEFAULT CHARSET=utf8; +) CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO `yii2_test_article` (`id`, `title`, `content`, `author_id`, `create_date`) VALUES (1, 'About cats', 'This article is about cats. Repeated.', 1, '2013-10-23 00:00:00'), From ce26ec6233fb5eb396d02a15d212eaba0f0b9a98 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 10:28:46 +0300 Subject: [PATCH 08/69] fix --- .github/workflows/build.yml | 2 +- tests/data/source.sql | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 575cb081..9a47eb3e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,7 +52,7 @@ jobs: run: | sudo /etc/init.d/mysql start mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' - mysql -D yiitest -uroot -proot < tests/data/source.sql + mysql --default-character-set=utf8 -D yiitest -uroot -proot < tests/data/source.sql - name: Install sphinx run: cd tests/data/actions && sh sphinx-setup.sh diff --git a/tests/data/source.sql b/tests/data/source.sql index a2ec7f00..74650476 100644 --- a/tests/data/source.sql +++ b/tests/data/source.sql @@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS `yii2_test_article` ( `author_id` int(11) NOT NULL, `create_date` datetime NOT NULL, PRIMARY KEY (`id`) -) CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3; +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; CREATE TABLE IF NOT EXISTS `yii2_test_item` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -23,19 +23,19 @@ CREATE TABLE IF NOT EXISTS `yii2_test_item` ( `category_id` int(11) NOT NULL, `price` float NOT NULL, PRIMARY KEY (`id`) -) CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3; +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3; CREATE TABLE IF NOT EXISTS `yii2_test_tag` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`) -) CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5; +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5; CREATE TABLE IF NOT EXISTS `yii2_test_article_tag` ( `article_id` int(11) NOT NULL, `tag_id` int(11) NOT NULL, PRIMARY KEY (`article_id`,`tag_id`) -) CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=MyISAM DEFAULT CHARSET=utf8; +) ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO `yii2_test_article` (`id`, `title`, `content`, `author_id`, `create_date`) VALUES (1, 'About cats', 'This article is about cats. Repeated.', 1, '2013-10-23 00:00:00'), From 03e68c48b4c16fc4fc32d376849eac303e34691a Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 10:33:22 +0300 Subject: [PATCH 09/69] fix --- tests/data/sphinx.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/data/sphinx.conf b/tests/data/sphinx.conf index 4a9ed53f..d2646218 100644 --- a/tests/data/sphinx.conf +++ b/tests/data/sphinx.conf @@ -87,6 +87,7 @@ index yii2_test_item_delta_index : yii2_test_item_index index yii2_test_rt_index { type = rt + charset_type = utf-8 path = SPHINX_BASE_DIR/yii2_test_rt rt_field = title rt_attr_string = title @@ -99,6 +100,7 @@ index yii2_test_rt_index index yii2_test_distributed { type = distributed + charset_type = utf-8 local = yii2_test_article_index } From f292f0b72e26861dbd1276da6db0d1616bbf679e Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 10:36:01 +0300 Subject: [PATCH 10/69] fix --- tests/data/config.php | 4 ++-- tests/data/sphinx.conf | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/data/config.php b/tests/data/config.php index 426e65e9..f30104ad 100644 --- a/tests/data/config.php +++ b/tests/data/config.php @@ -8,12 +8,12 @@ $config = [ 'sphinx' => [ - 'dsn' => 'mysql:host=127.0.0.1;port=19306;', + 'dsn' => 'mysql:host=127.0.0.1;port=19306;charset=utf8;', 'username' => 'root', 'password' => 'root', ], 'db' => [ - 'dsn' => 'mysql:host=127.0.0.1;dbname=yiitest', + 'dsn' => 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8;', 'username' => 'root', 'password' => 'root', 'fixture' => __DIR__ . '/source.sql', diff --git a/tests/data/sphinx.conf b/tests/data/sphinx.conf index d2646218..4a9ed53f 100644 --- a/tests/data/sphinx.conf +++ b/tests/data/sphinx.conf @@ -87,7 +87,6 @@ index yii2_test_item_delta_index : yii2_test_item_index index yii2_test_rt_index { type = rt - charset_type = utf-8 path = SPHINX_BASE_DIR/yii2_test_rt rt_field = title rt_attr_string = title @@ -100,7 +99,6 @@ index yii2_test_rt_index index yii2_test_distributed { type = distributed - charset_type = utf-8 local = yii2_test_article_index } From 63f145e2575a07dbd5ba40178063290b21212ab3 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 10:40:24 +0300 Subject: [PATCH 11/69] fix --- tests/data/actions/sphinx-setup.sh | 5 +++++ tests/data/config.php | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/data/actions/sphinx-setup.sh b/tests/data/actions/sphinx-setup.sh index 27382092..54067103 100644 --- a/tests/data/actions/sphinx-setup.sh +++ b/tests/data/actions/sphinx-setup.sh @@ -7,6 +7,11 @@ echo 'deb http://security.ubuntu.com/ubuntu xenial-security main' | sudo tee /et sudo apt update sudo apt install libmysqlclient20 +touch /etc/my.cnf +echo "[client]" > /etc/my.cnf +echo "default-character-set=utf8" > /etc/my.cnf +cat /etc/my.cnf + # install sphinx from https://sphinxsearch.com/downloads/release/ wget http://sphinxsearch.com/files/sphinxsearch_2.2.11-release-1~xenial_amd64.deb sudo dpkg -i sphinxsearch_2.2.11-release-1~xenial_amd64.deb diff --git a/tests/data/config.php b/tests/data/config.php index f30104ad..426e65e9 100644 --- a/tests/data/config.php +++ b/tests/data/config.php @@ -8,12 +8,12 @@ $config = [ 'sphinx' => [ - 'dsn' => 'mysql:host=127.0.0.1;port=19306;charset=utf8;', + 'dsn' => 'mysql:host=127.0.0.1;port=19306;', 'username' => 'root', 'password' => 'root', ], 'db' => [ - 'dsn' => 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8;', + 'dsn' => 'mysql:host=127.0.0.1;dbname=yiitest', 'username' => 'root', 'password' => 'root', 'fixture' => __DIR__ . '/source.sql', From 84c2cbfde8f7cba98b956ceeb7a2e4a0e385acdc Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 10:44:22 +0300 Subject: [PATCH 12/69] fix --- .github/workflows/build.yml | 2 +- tests/data/actions/sphinx-setup.sh | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a47eb3e..8b22ffaa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - ubuntu-20.04 php: - - "5.4" + - "7.2" steps: - name: Checkout diff --git a/tests/data/actions/sphinx-setup.sh b/tests/data/actions/sphinx-setup.sh index 54067103..d8304e03 100644 --- a/tests/data/actions/sphinx-setup.sh +++ b/tests/data/actions/sphinx-setup.sh @@ -7,10 +7,6 @@ echo 'deb http://security.ubuntu.com/ubuntu xenial-security main' | sudo tee /et sudo apt update sudo apt install libmysqlclient20 -touch /etc/my.cnf -echo "[client]" > /etc/my.cnf -echo "default-character-set=utf8" > /etc/my.cnf -cat /etc/my.cnf # install sphinx from https://sphinxsearch.com/downloads/release/ wget http://sphinxsearch.com/files/sphinxsearch_2.2.11-release-1~xenial_amd64.deb From e9cd236bebb08cae927cf2cc9609756be8f722e7 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 10:51:40 +0300 Subject: [PATCH 13/69] fix --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b22ffaa..bf70b8c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,6 +50,7 @@ jobs: - name: Setup source database run: | + echo -e '[client]\ndefault-character-set=utf8\n[mysql]\ndefault-character-set=utf8\n[mysqld]\ncollation-server=utf8_unicode_ci\ncharacter-set-server=utf8' > "$HOME/.my.cnf" sudo /etc/init.d/mysql start mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql --default-character-set=utf8 -D yiitest -uroot -proot < tests/data/source.sql From f53e03bd559e0c07cc12234d17e1b7d06078dabe Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 10:54:18 +0300 Subject: [PATCH 14/69] fix --- .github/workflows/build.yml | 1 + tests/data/actions/libmysqlclient20.sh | 6 ++++++ tests/data/actions/sphinx-setup.sh | 6 ------ 3 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 tests/data/actions/libmysqlclient20.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bf70b8c5..9df9a3eb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,6 +50,7 @@ jobs: - name: Setup source database run: | + tests/data/libmysqlclient20.sh echo -e '[client]\ndefault-character-set=utf8\n[mysql]\ndefault-character-set=utf8\n[mysqld]\ncollation-server=utf8_unicode_ci\ncharacter-set-server=utf8' > "$HOME/.my.cnf" sudo /etc/init.d/mysql start mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' diff --git a/tests/data/actions/libmysqlclient20.sh b/tests/data/actions/libmysqlclient20.sh new file mode 100644 index 00000000..28c6de69 --- /dev/null +++ b/tests/data/actions/libmysqlclient20.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +# https://askubuntu.com/a/1337909 +echo 'deb http://security.ubuntu.com/ubuntu xenial-security main' | sudo tee /etc/apt/sources.list.d/xenial-security.list +sudo apt update +sudo apt install libmysqlclient20 diff --git a/tests/data/actions/sphinx-setup.sh b/tests/data/actions/sphinx-setup.sh index d8304e03..4e67fdb4 100644 --- a/tests/data/actions/sphinx-setup.sh +++ b/tests/data/actions/sphinx-setup.sh @@ -2,12 +2,6 @@ SCRIPT=$(readlink -f "$0") CWD=$(dirname "$SCRIPT") -# https://askubuntu.com/a/1337909 -echo 'deb http://security.ubuntu.com/ubuntu xenial-security main' | sudo tee /etc/apt/sources.list.d/xenial-security.list -sudo apt update -sudo apt install libmysqlclient20 - - # install sphinx from https://sphinxsearch.com/downloads/release/ wget http://sphinxsearch.com/files/sphinxsearch_2.2.11-release-1~xenial_amd64.deb sudo dpkg -i sphinxsearch_2.2.11-release-1~xenial_amd64.deb From a108d5055c567fa431b5215325074e811a82276c Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 10:55:27 +0300 Subject: [PATCH 15/69] fix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9df9a3eb..5cbb51a5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: - name: Setup source database run: | - tests/data/libmysqlclient20.sh + cd tests/data/actions && sh libmysqlclient20.sh echo -e '[client]\ndefault-character-set=utf8\n[mysql]\ndefault-character-set=utf8\n[mysqld]\ncollation-server=utf8_unicode_ci\ncharacter-set-server=utf8' > "$HOME/.my.cnf" sudo /etc/init.d/mysql start mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' From c7318517bd701e78110390895f05abdb35dcdf71 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 10:56:56 +0300 Subject: [PATCH 16/69] fix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5cbb51a5..e790a985 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: - name: Setup source database run: | - cd tests/data/actions && sh libmysqlclient20.sh + sh tests/data/actions/libmysqlclient20.sh echo -e '[client]\ndefault-character-set=utf8\n[mysql]\ndefault-character-set=utf8\n[mysqld]\ncollation-server=utf8_unicode_ci\ncharacter-set-server=utf8' > "$HOME/.my.cnf" sudo /etc/init.d/mysql start mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' From 175b6154dda055e88b1356fc732f2324c64c3b93 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 10:59:55 +0300 Subject: [PATCH 17/69] fix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e790a985..7ff95bef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,7 +51,7 @@ jobs: - name: Setup source database run: | sh tests/data/actions/libmysqlclient20.sh - echo -e '[client]\ndefault-character-set=utf8\n[mysql]\ndefault-character-set=utf8\n[mysqld]\ncollation-server=utf8_unicode_ci\ncharacter-set-server=utf8' > "$HOME/.my.cnf" + echo -e '[client]\ndefault-character-set=utf8\n[mysql]\ndefault-character-set=utf8\n[mysqld]\ndefault-authentication-plugin=mysql_native_password\ncollation-server=utf8_unicode_ci\ncharacter-set-server=utf8' > "$HOME/.my.cnf" sudo /etc/init.d/mysql start mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql --default-character-set=utf8 -D yiitest -uroot -proot < tests/data/source.sql From ccca747e94e6437bb107a92ec976f45800050d7a Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 11:05:54 +0300 Subject: [PATCH 18/69] fix --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7ff95bef..f29ba899 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,8 +51,8 @@ jobs: - name: Setup source database run: | sh tests/data/actions/libmysqlclient20.sh - echo -e '[client]\ndefault-character-set=utf8\n[mysql]\ndefault-character-set=utf8\n[mysqld]\ndefault-authentication-plugin=mysql_native_password\ncollation-server=utf8_unicode_ci\ncharacter-set-server=utf8' > "$HOME/.my.cnf" - sudo /etc/init.d/mysql start + echo -e '[client]\ndefault-character-set=utf8\n[mysql]\ndefault-character-set=utf8\n[mysqld]\ncollation-server=utf8_unicode_ci\ncharacter-set-server=utf8' > "$HOME/.my.cnf" + sudo /etc/init.d/mysql start --default-authentication-plugin=mysql_native_password mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql --default-character-set=utf8 -D yiitest -uroot -proot < tests/data/source.sql From ffc761b2c37e7c663e83e8e2cd68cf1bc345a155 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 11:08:52 +0300 Subject: [PATCH 19/69] fix --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f29ba899..c83bd50b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,8 +51,8 @@ jobs: - name: Setup source database run: | sh tests/data/actions/libmysqlclient20.sh - echo -e '[client]\ndefault-character-set=utf8\n[mysql]\ndefault-character-set=utf8\n[mysqld]\ncollation-server=utf8_unicode_ci\ncharacter-set-server=utf8' > "$HOME/.my.cnf" - sudo /etc/init.d/mysql start --default-authentication-plugin=mysql_native_password + sudo mysql --default-authentication-plugin=mysql_native_password + sudo /etc/init.d/mysql start mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql --default-character-set=utf8 -D yiitest -uroot -proot < tests/data/source.sql From 8797c10207b0f14cc45c490197ce4a2556fa9a8a Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 11:14:21 +0300 Subject: [PATCH 20/69] fix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c83bd50b..492d3ed0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,8 +51,8 @@ jobs: - name: Setup source database run: | sh tests/data/actions/libmysqlclient20.sh - sudo mysql --default-authentication-plugin=mysql_native_password sudo /etc/init.d/mysql start + mysql -uroot -proot -e 'SET GLOBAL default_authentication_plugin=mysql_native_password;FLUSH PRIVILEGES;' mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql --default-character-set=utf8 -D yiitest -uroot -proot < tests/data/source.sql From 7b9b39fac294f4016bed5e16cf98e88586f4e844 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 11:17:53 +0300 Subject: [PATCH 21/69] fix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 492d3ed0..63d57e08 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,8 +51,8 @@ jobs: - name: Setup source database run: | sh tests/data/actions/libmysqlclient20.sh + echo -e '[client]\ndefault-character-set=utf8\n[mysql]\ndefault-character-set=utf8\n[mysqld]\ndefault_authentication_plugin=mysql_native_password\ncollation-server=utf8_unicode_ci\ncharacter-set-server=utf8' > "$HOME/.my.cnf" sudo /etc/init.d/mysql start - mysql -uroot -proot -e 'SET GLOBAL default_authentication_plugin=mysql_native_password;FLUSH PRIVILEGES;' mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql --default-character-set=utf8 -D yiitest -uroot -proot < tests/data/source.sql From 4737146583b904feb336041efa1f13ab46812cd8 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 11:22:57 +0300 Subject: [PATCH 22/69] fix --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 63d57e08..12ed3798 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,8 +51,8 @@ jobs: - name: Setup source database run: | sh tests/data/actions/libmysqlclient20.sh - echo -e '[client]\ndefault-character-set=utf8\n[mysql]\ndefault-character-set=utf8\n[mysqld]\ndefault_authentication_plugin=mysql_native_password\ncollation-server=utf8_unicode_ci\ncharacter-set-server=utf8' > "$HOME/.my.cnf" - sudo /etc/init.d/mysql start + sudo echo -e '[client]\ndefault-character-set=utf8\n[mysql]\ndefault-character-set=utf8\n[mysqld]\ndefault_authentication_plugin=mysql_native_password\ncollation-server=utf8_unicode_ci\ncharacter-set-server=utf8' > "/etc/mysql/.my.cnf" + sudo systemctl start mysql.service mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql --default-character-set=utf8 -D yiitest -uroot -proot < tests/data/source.sql From 8d1a9e85efe708279d2bbdf4304f38c991388c76 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 11:26:20 +0300 Subject: [PATCH 23/69] fix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 12ed3798..2fb931b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,8 +51,8 @@ jobs: - name: Setup source database run: | sh tests/data/actions/libmysqlclient20.sh - sudo echo -e '[client]\ndefault-character-set=utf8\n[mysql]\ndefault-character-set=utf8\n[mysqld]\ndefault_authentication_plugin=mysql_native_password\ncollation-server=utf8_unicode_ci\ncharacter-set-server=utf8' > "/etc/mysql/.my.cnf" sudo systemctl start mysql.service + mysql -uroot -proot -e 'ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';FLUSH PRIVILEGES;' mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql --default-character-set=utf8 -D yiitest -uroot -proot < tests/data/source.sql From 0d674cb5b9fbb8ea284493eb5df7d91f2f56871a Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 11:29:18 +0300 Subject: [PATCH 24/69] fix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2fb931b4..605d2ae2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,7 +52,7 @@ jobs: run: | sh tests/data/actions/libmysqlclient20.sh sudo systemctl start mysql.service - mysql -uroot -proot -e 'ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';FLUSH PRIVILEGES;' + mysql -uroot -proot -e 'ALTER USER \'root\'@\'localhost\' IDENTIFIED WITH mysql_native_password BY \'root\';FLUSH PRIVILEGES;' mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql --default-character-set=utf8 -D yiitest -uroot -proot < tests/data/source.sql From 8d0f38b2fc5a2a226511bec8ba3de3924c9bf377 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 11:33:00 +0300 Subject: [PATCH 25/69] fix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 605d2ae2..7bc450b5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,7 +52,7 @@ jobs: run: | sh tests/data/actions/libmysqlclient20.sh sudo systemctl start mysql.service - mysql -uroot -proot -e 'ALTER USER \'root\'@\'localhost\' IDENTIFIED WITH mysql_native_password BY \'root\';FLUSH PRIVILEGES;' + mysql -uroot -proot -e 'ALTER USER "root"@"localhost" IDENTIFIED WITH mysql_native_password BY "root";FLUSH PRIVILEGES;' mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql --default-character-set=utf8 -D yiitest -uroot -proot < tests/data/source.sql From 588e56c596e3a0f1abaab118b569fa34bab3c744 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 11:36:14 +0300 Subject: [PATCH 26/69] fix test --- tests/QueryTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/QueryTest.php b/tests/QueryTest.php index 2ff9b16d..3c9363d7 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -18,7 +18,7 @@ public function testSelect() $query = new Query(); $query->select('*'); $this->assertEquals(['*' => '*'], $query->select); - $this->assertNull($query->distinct); + $this->assertFalse($query->distinct); $this->assertEquals(null, $query->selectOption); $query = new Query(); From 9ef00f044a4ccfee239ab4940f2c8927bcb931df Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 11:40:28 +0300 Subject: [PATCH 27/69] improve --- .github/workflows/build.yml | 18 +++++++++--------- tests/data/actions/libmysqlclient20.sh | 6 ------ ...{sphinx-setup.sh => sphinx-setup-2.2.11.sh} | 5 +++++ 3 files changed, 14 insertions(+), 15 deletions(-) delete mode 100644 tests/data/actions/libmysqlclient20.sh rename tests/data/actions/{sphinx-setup.sh => sphinx-setup-2.2.11.sh} (71%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7bc450b5..cda54f7e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,9 +20,10 @@ jobs: matrix: os: - ubuntu-20.04 - php: - "7.2" + sphinx: + - "2.2.11" steps: - name: Checkout @@ -48,16 +49,15 @@ jobs: if: matrix.php == '8.0' run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + - name: Install sphinx + run: sh tests/data/actions/sphinx-setup-${{ matrix.sphinx }}.sh + - name: Setup source database run: | - sh tests/data/actions/libmysqlclient20.sh - sudo systemctl start mysql.service - mysql -uroot -proot -e 'ALTER USER "root"@"localhost" IDENTIFIED WITH mysql_native_password BY "root";FLUSH PRIVILEGES;' - mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' - mysql --default-character-set=utf8 -D yiitest -uroot -proot < tests/data/source.sql - - - name: Install sphinx - run: cd tests/data/actions && sh sphinx-setup.sh + sudo systemctl start mysql.service + mysql -uroot -proot -e 'ALTER USER "root"@"localhost" IDENTIFIED WITH mysql_native_password BY "root";FLUSH PRIVILEGES;' + mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' + mysql -D yiitest -uroot -proot < tests/data/source.sql - name: Run tests with phpunit if: matrix.php != '7.4' diff --git a/tests/data/actions/libmysqlclient20.sh b/tests/data/actions/libmysqlclient20.sh deleted file mode 100644 index 28c6de69..00000000 --- a/tests/data/actions/libmysqlclient20.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -# https://askubuntu.com/a/1337909 -echo 'deb http://security.ubuntu.com/ubuntu xenial-security main' | sudo tee /etc/apt/sources.list.d/xenial-security.list -sudo apt update -sudo apt install libmysqlclient20 diff --git a/tests/data/actions/sphinx-setup.sh b/tests/data/actions/sphinx-setup-2.2.11.sh similarity index 71% rename from tests/data/actions/sphinx-setup.sh rename to tests/data/actions/sphinx-setup-2.2.11.sh index 4e67fdb4..27382092 100644 --- a/tests/data/actions/sphinx-setup.sh +++ b/tests/data/actions/sphinx-setup-2.2.11.sh @@ -2,6 +2,11 @@ SCRIPT=$(readlink -f "$0") CWD=$(dirname "$SCRIPT") +# https://askubuntu.com/a/1337909 +echo 'deb http://security.ubuntu.com/ubuntu xenial-security main' | sudo tee /etc/apt/sources.list.d/xenial-security.list +sudo apt update +sudo apt install libmysqlclient20 + # install sphinx from https://sphinxsearch.com/downloads/release/ wget http://sphinxsearch.com/files/sphinxsearch_2.2.11-release-1~xenial_amd64.deb sudo dpkg -i sphinxsearch_2.2.11-release-1~xenial_amd64.deb From 763ee9f758b7144639c2721c5e4e2061e9eebe59 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 11:46:04 +0300 Subject: [PATCH 28/69] improve --- .github/workflows/build.yml | 5 +++++ tests/data/actions/sphinx-setup-2.2.11.sh | 8 +------- tests/data/{sphinx.conf => sphinx-2.2.11.conf} | 0 3 files changed, 6 insertions(+), 7 deletions(-) rename tests/data/{sphinx.conf => sphinx-2.2.11.conf} (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cda54f7e..f48f1905 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,6 +59,11 @@ jobs: mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql -D yiitest -uroot -proot < tests/data/source.sql + - name: Run sphinx + run: | + indexer --config tests/data/sphinx-${{ matrix.sphinx }}.conf --all + searchd --config tests/data/sphinx-${{ matrix.sphinx }}.conf + - name: Run tests with phpunit if: matrix.php != '7.4' run: vendor/bin/phpunit --colors=always diff --git a/tests/data/actions/sphinx-setup-2.2.11.sh b/tests/data/actions/sphinx-setup-2.2.11.sh index 27382092..ce370b7a 100644 --- a/tests/data/actions/sphinx-setup-2.2.11.sh +++ b/tests/data/actions/sphinx-setup-2.2.11.sh @@ -13,10 +13,4 @@ sudo dpkg -i sphinxsearch_2.2.11-release-1~xenial_amd64.deb # make dir that is used in sphinx config mkdir -p sphinx -sed -i s\~SPHINX_BASE_DIR~$PWD/sphinx~g $CWD/../sphinx.conf - -# setup test Sphinx indexes: -indexer --config $CWD/../sphinx.conf --all - -# run searchd: -searchd --config $CWD/../sphinx.conf +sed -i s\~SPHINX_BASE_DIR~$PWD/sphinx~g $CWD/../sphinx-2.2.11.conf diff --git a/tests/data/sphinx.conf b/tests/data/sphinx-2.2.11.conf similarity index 100% rename from tests/data/sphinx.conf rename to tests/data/sphinx-2.2.11.conf From a7dab7baa0f6367b22d852114e47793c7c9d17ab Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 11:52:16 +0300 Subject: [PATCH 29/69] try 3.5.1 --- .github/workflows/build.yml | 2 +- tests/data/actions/sphinx-setup-3.5.1.sh | 13 +++ tests/data/sphinx-3.5.1.conf | 120 +++++++++++++++++++++++ 3 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 tests/data/actions/sphinx-setup-3.5.1.sh create mode 100644 tests/data/sphinx-3.5.1.conf diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f48f1905..1a822c86 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: php: - "7.2" sphinx: - - "2.2.11" + - "3.5.1" steps: - name: Checkout diff --git a/tests/data/actions/sphinx-setup-3.5.1.sh b/tests/data/actions/sphinx-setup-3.5.1.sh new file mode 100644 index 00000000..eb5a064f --- /dev/null +++ b/tests/data/actions/sphinx-setup-3.5.1.sh @@ -0,0 +1,13 @@ +#!/bin/sh -e +SCRIPT=$(readlink -f "$0") +CWD=$(dirname "$SCRIPT") + +wget https://sphinxsearch.com/files/sphinx-3.5.1-82c60cb-linux-amd64.tar.gz -O /tmp/sphinxsearch.tar.gz \ + && mkdir /opt/sphinx \ + && cd /opt/sphinx \ + && tar -zxf /tmp/sphinxsearch.tar.gz \ + && rm /tmp/sphinxsearch.tar.gz + +# make dir that is used in sphinx config +mkdir -p sphinx +sed -i s\~SPHINX_BASE_DIR~$PWD/sphinx~g $CWD/../sphinx-3.5.1.conf diff --git a/tests/data/sphinx-3.5.1.conf b/tests/data/sphinx-3.5.1.conf new file mode 100644 index 00000000..53234ccb --- /dev/null +++ b/tests/data/sphinx-3.5.1.conf @@ -0,0 +1,120 @@ +# Sphinx configuration for the unit tests +# +# Setup test environment: +# - initialize test database source: +# mysql -D yiitest -u test < /path/to/yii/tests/unit/data/sphinx/source.sql +# - setup test Sphinx indexes: +# indexer --config /path/to/yii/tests/unit/data/sphinx/sphinx.conf --all [--rotate] +# - run the "searchd" daemon: +# searchd --config /path/to/yii/tests/unit/data/sphinx/sphinx.conf + + +source yii2_test_article_src +{ + type = mysql + + sql_host = localhost + sql_user = root + sql_pass = root + sql_db = yiitest + sql_port = 3306 # optional, default is 3306 + + sql_query = \ + SELECT *, UNIX_TIMESTAMP(create_date) AS add_date \ + FROM yii2_test_article + + sql_attr_uint = id + sql_attr_uint = author_id + sql_attr_timestamp = add_date + sql_attr_multi = uint tag from query; SELECT article_id AS id, tag_id AS tag FROM yii2_test_article_tag +} + + +source yii2_test_item_src +{ + type = mysql + + sql_host = localhost + sql_user = root + sql_pass = root + sql_db = yiitest + sql_port = 3306 # optional, default is 3306 + + sql_query = \ + SELECT *, CURRENT_TIMESTAMP() AS add_date \ + FROM yii2_test_item \ + WHERE id <= 100 + + sql_attr_uint = id + sql_attr_uint = category_id + sql_attr_float = price + sql_attr_timestamp = add_date +} + + +source yii2_test_item_delta_src : yii2_test_item_src +{ + sql_query = \ + SELECT *, CURRENT_TIMESTAMP() AS add_date \ + FROM yii2_test_item \ + WHERE id > 100 +} + + +index yii2_test_article_index +{ + source = yii2_test_article_src + docinfo = extern +} + + +index yii2_test_item_index +{ + source = yii2_test_item_src + docinfo = extern +} + + +index yii2_test_item_delta_index : yii2_test_item_index +{ + source = yii2_test_item_delta_src +} + + +index yii2_test_rt_index +{ + type = rt + rt_field = title + rt_attr_string = title + rt_field = content + rt_attr_uint = type_id + rt_attr_multi = category +} + + +index yii2_test_distributed +{ + type = distributed + local = yii2_test_article_index +} + +common { + datadir = SPHINX_BASE_DIR +} + +indexer +{ + mem_limit = 32M +} + +searchd +{ + #listen = 127.0.0.1:9312 + listen = 19306:mysql41 + read_timeout = 5 + max_children = 30 + seamless_rotate = 1 + preopen_indexes = 1 + unlink_old = 1 + workers = threads # for RT to work +} From 488affb6baa521a7966e3c6b1099196fd21375e3 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 11:54:49 +0300 Subject: [PATCH 30/69] fix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1a822c86..71a11dcd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ name: build jobs: tests: - name: PHP ${{ matrix.php }}-${{ matrix.os }} + name: PHP ${{ matrix.php }}-${{ matrix.sphinx }}-${{ matrix.os }} env: extensions: pdo, pdo_mysql From f5ec11fed4d84fef65df6f4ff450d56cd00caa3f Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:00:59 +0300 Subject: [PATCH 31/69] fix --- .github/workflows/build.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 71a11dcd..e878e69b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ name: build jobs: tests: - name: PHP ${{ matrix.php }}-${{ matrix.sphinx }}-${{ matrix.os }} + name: PHP ${{ matrix.php }}-sphinx-${{ matrix.sphinx }}-${{ matrix.os }} env: extensions: pdo, pdo_mysql @@ -59,11 +59,18 @@ jobs: mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql -D yiitest -uroot -proot < tests/data/source.sql - - name: Run sphinx + - name: Run sphinx 2.2.11 + if: matrix.sphinx == '2.2.11' run: | indexer --config tests/data/sphinx-${{ matrix.sphinx }}.conf --all searchd --config tests/data/sphinx-${{ matrix.sphinx }}.conf + - name: Run sphinx 3 + if: matrix.sphinx != '2.2.11' + run: | + /opt/sphinx/indexer --config tests/data/sphinx-${{ matrix.sphinx }}.conf --all + /opt/sphinx/searchd --config tests/data/sphinx-${{ matrix.sphinx }}.conf + - name: Run tests with phpunit if: matrix.php != '7.4' run: vendor/bin/phpunit --colors=always From b05e4c8a62141a90640b4d3dc123922616868a51 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:02:47 +0300 Subject: [PATCH 32/69] fix --- tests/data/actions/sphinx-setup-3.5.1.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/data/actions/sphinx-setup-3.5.1.sh b/tests/data/actions/sphinx-setup-3.5.1.sh index eb5a064f..ecb469e0 100644 --- a/tests/data/actions/sphinx-setup-3.5.1.sh +++ b/tests/data/actions/sphinx-setup-3.5.1.sh @@ -2,11 +2,10 @@ SCRIPT=$(readlink -f "$0") CWD=$(dirname "$SCRIPT") -wget https://sphinxsearch.com/files/sphinx-3.5.1-82c60cb-linux-amd64.tar.gz -O /tmp/sphinxsearch.tar.gz \ - && mkdir /opt/sphinx \ - && cd /opt/sphinx \ - && tar -zxf /tmp/sphinxsearch.tar.gz \ - && rm /tmp/sphinxsearch.tar.gz +wget https://sphinxsearch.com/files/sphinx-3.5.1-82c60cb-linux-amd64.tar.gz -O /tmp/sphinxsearch.tar.gz +mkdir /opt/sphinx +cd /opt/sphinx && tar -zxf /tmp/sphinxsearch.tar.gz +rm /tmp/sphinxsearch.tar.gz # make dir that is used in sphinx config mkdir -p sphinx From 3ae84b56e7bb4099aa0fb2568e0ddb99c6dbd703 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:05:38 +0300 Subject: [PATCH 33/69] fix --- tests/data/actions/sphinx-setup-3.5.1.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/data/actions/sphinx-setup-3.5.1.sh b/tests/data/actions/sphinx-setup-3.5.1.sh index ecb469e0..fe97708b 100644 --- a/tests/data/actions/sphinx-setup-3.5.1.sh +++ b/tests/data/actions/sphinx-setup-3.5.1.sh @@ -3,8 +3,8 @@ SCRIPT=$(readlink -f "$0") CWD=$(dirname "$SCRIPT") wget https://sphinxsearch.com/files/sphinx-3.5.1-82c60cb-linux-amd64.tar.gz -O /tmp/sphinxsearch.tar.gz -mkdir /opt/sphinx -cd /opt/sphinx && tar -zxf /tmp/sphinxsearch.tar.gz +sudo mkdir /opt/sphinx +cd /opt/sphinx && sudo tar -zxf /tmp/sphinxsearch.tar.gz rm /tmp/sphinxsearch.tar.gz # make dir that is used in sphinx config From eefa742db6fee943a33f9938d43cbfce2c1d6e8a Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:06:42 +0300 Subject: [PATCH 34/69] fix --- tests/data/actions/sphinx-setup-3.5.1.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/data/actions/sphinx-setup-3.5.1.sh b/tests/data/actions/sphinx-setup-3.5.1.sh index fe97708b..2456bdd0 100644 --- a/tests/data/actions/sphinx-setup-3.5.1.sh +++ b/tests/data/actions/sphinx-setup-3.5.1.sh @@ -2,11 +2,12 @@ SCRIPT=$(readlink -f "$0") CWD=$(dirname "$SCRIPT") -wget https://sphinxsearch.com/files/sphinx-3.5.1-82c60cb-linux-amd64.tar.gz -O /tmp/sphinxsearch.tar.gz -sudo mkdir /opt/sphinx -cd /opt/sphinx && sudo tar -zxf /tmp/sphinxsearch.tar.gz -rm /tmp/sphinxsearch.tar.gz +wget https://sphinxsearch.com/files/sphinx-3.5.1-82c60cb-linux-amd64.tar.gz -O /tmp/sphinxsearch.tar.gz \ + && mkdir /opt/sphinx \ + && cd /opt/sphinx \ + && tar -zxf /tmp/sphinxsearch.tar.gz \ + && rm /tmp/sphinxsearch.tar.gz # make dir that is used in sphinx config -mkdir -p sphinx +mkdir -p $PWD/sphinx sed -i s\~SPHINX_BASE_DIR~$PWD/sphinx~g $CWD/../sphinx-3.5.1.conf From 6de8523dd77878036331f453963ecb97fcbb6646 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:07:59 +0300 Subject: [PATCH 35/69] fix --- tests/data/actions/sphinx-setup-3.5.1.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/data/actions/sphinx-setup-3.5.1.sh b/tests/data/actions/sphinx-setup-3.5.1.sh index 2456bdd0..d9c51bca 100644 --- a/tests/data/actions/sphinx-setup-3.5.1.sh +++ b/tests/data/actions/sphinx-setup-3.5.1.sh @@ -8,6 +8,8 @@ wget https://sphinxsearch.com/files/sphinx-3.5.1-82c60cb-linux-amd64.tar.gz -O / && tar -zxf /tmp/sphinxsearch.tar.gz \ && rm /tmp/sphinxsearch.tar.gz +echo "test" + # make dir that is used in sphinx config mkdir -p $PWD/sphinx sed -i s\~SPHINX_BASE_DIR~$PWD/sphinx~g $CWD/../sphinx-3.5.1.conf From b8da18c7a65f061fbe52096b1f46928acd1d3fac Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:09:34 +0300 Subject: [PATCH 36/69] fix --- tests/data/actions/sphinx-setup-3.5.1.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/data/actions/sphinx-setup-3.5.1.sh b/tests/data/actions/sphinx-setup-3.5.1.sh index d9c51bca..77cb09e2 100644 --- a/tests/data/actions/sphinx-setup-3.5.1.sh +++ b/tests/data/actions/sphinx-setup-3.5.1.sh @@ -2,13 +2,10 @@ SCRIPT=$(readlink -f "$0") CWD=$(dirname "$SCRIPT") -wget https://sphinxsearch.com/files/sphinx-3.5.1-82c60cb-linux-amd64.tar.gz -O /tmp/sphinxsearch.tar.gz \ - && mkdir /opt/sphinx \ - && cd /opt/sphinx \ - && tar -zxf /tmp/sphinxsearch.tar.gz \ - && rm /tmp/sphinxsearch.tar.gz - -echo "test" +wget https://sphinxsearch.com/files/sphinx-3.5.1-82c60cb-linux-amd64.tar.gz -O /tmp/sphinxsearch.tar.gz +sudo mkdir /opt/sphinx +sudo cd /opt/sphinx && tar -zxf /tmp/sphinxsearch.tar.gz +rm /tmp/sphinxsearch.tar.gz # make dir that is used in sphinx config mkdir -p $PWD/sphinx From 9755659168c84f3ee203453fd550a8c369aaaa52 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:10:33 +0300 Subject: [PATCH 37/69] fix --- tests/data/actions/sphinx-setup-3.5.1.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/actions/sphinx-setup-3.5.1.sh b/tests/data/actions/sphinx-setup-3.5.1.sh index 77cb09e2..1632cf9c 100644 --- a/tests/data/actions/sphinx-setup-3.5.1.sh +++ b/tests/data/actions/sphinx-setup-3.5.1.sh @@ -4,7 +4,7 @@ CWD=$(dirname "$SCRIPT") wget https://sphinxsearch.com/files/sphinx-3.5.1-82c60cb-linux-amd64.tar.gz -O /tmp/sphinxsearch.tar.gz sudo mkdir /opt/sphinx -sudo cd /opt/sphinx && tar -zxf /tmp/sphinxsearch.tar.gz +cd /opt/sphinx && sudo tar -zxf /tmp/sphinxsearch.tar.gz rm /tmp/sphinxsearch.tar.gz # make dir that is used in sphinx config From f22deae1cd4ad16b38123642ce5036e06cc5f6c0 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:12:12 +0300 Subject: [PATCH 38/69] fix --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e878e69b..d10980d8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,8 +68,8 @@ jobs: - name: Run sphinx 3 if: matrix.sphinx != '2.2.11' run: | - /opt/sphinx/indexer --config tests/data/sphinx-${{ matrix.sphinx }}.conf --all - /opt/sphinx/searchd --config tests/data/sphinx-${{ matrix.sphinx }}.conf + /opt/sphinx/sphinx-${{ matrix.sphinx }}/bin/indexer --config tests/data/sphinx-${{ matrix.sphinx }}.conf --all + /opt/sphinx/sphinx-${{ matrix.sphinx }}/bin/searchd --config tests/data/sphinx-${{ matrix.sphinx }}.conf - name: Run tests with phpunit if: matrix.php != '7.4' From 3b15e3d6a9d50c8f59727cc36a22c18dfd6b0523 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:14:57 +0300 Subject: [PATCH 39/69] fix --- tests/data/sphinx-3.5.1.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/data/sphinx-3.5.1.conf b/tests/data/sphinx-3.5.1.conf index 53234ccb..ffb34ccb 100644 --- a/tests/data/sphinx-3.5.1.conf +++ b/tests/data/sphinx-3.5.1.conf @@ -25,7 +25,7 @@ source yii2_test_article_src sql_attr_uint = id sql_attr_uint = author_id - sql_attr_timestamp = add_date + sql_attr_uint = add_date sql_attr_multi = uint tag from query; SELECT article_id AS id, tag_id AS tag FROM yii2_test_article_tag } @@ -48,7 +48,7 @@ source yii2_test_item_src sql_attr_uint = id sql_attr_uint = category_id sql_attr_float = price - sql_attr_timestamp = add_date + sql_attr_uint = add_date } From 9d0c49c71f86fe3986cf7e289cb80000673e100d Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:16:15 +0300 Subject: [PATCH 40/69] fix --- tests/data/sphinx-3.5.1.conf | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/data/sphinx-3.5.1.conf b/tests/data/sphinx-3.5.1.conf index ffb34ccb..8068a207 100644 --- a/tests/data/sphinx-3.5.1.conf +++ b/tests/data/sphinx-3.5.1.conf @@ -48,7 +48,7 @@ source yii2_test_item_src sql_attr_uint = id sql_attr_uint = category_id sql_attr_float = price - sql_attr_uint = add_date + sql_attr_uint = add_date } @@ -64,14 +64,12 @@ source yii2_test_item_delta_src : yii2_test_item_src index yii2_test_article_index { source = yii2_test_article_src - docinfo = extern } index yii2_test_item_index { source = yii2_test_item_src - docinfo = extern } From 00bfb8a8c64230386f515a7fdfe000ab46b1e6bb Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:19:48 +0300 Subject: [PATCH 41/69] fix --- tests/data/sphinx-3.5.1.conf | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/data/sphinx-3.5.1.conf b/tests/data/sphinx-3.5.1.conf index 8068a207..c1123e52 100644 --- a/tests/data/sphinx-3.5.1.conf +++ b/tests/data/sphinx-3.5.1.conf @@ -23,7 +23,6 @@ source yii2_test_article_src SELECT *, UNIX_TIMESTAMP(create_date) AS add_date \ FROM yii2_test_article - sql_attr_uint = id sql_attr_uint = author_id sql_attr_uint = add_date sql_attr_multi = uint tag from query; SELECT article_id AS id, tag_id AS tag FROM yii2_test_article_tag From e17f52bf1dc607ac69c5c16a70141a16081c2a46 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:21:07 +0300 Subject: [PATCH 42/69] fix --- tests/data/sphinx-3.5.1.conf | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/data/sphinx-3.5.1.conf b/tests/data/sphinx-3.5.1.conf index c1123e52..f757a0ad 100644 --- a/tests/data/sphinx-3.5.1.conf +++ b/tests/data/sphinx-3.5.1.conf @@ -44,7 +44,6 @@ source yii2_test_item_src FROM yii2_test_item \ WHERE id <= 100 - sql_attr_uint = id sql_attr_uint = category_id sql_attr_float = price sql_attr_uint = add_date From 7943f7a63f34be56bd1394c700578aef6b8d7be2 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:23:18 +0300 Subject: [PATCH 43/69] fix --- src/Schema.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Schema.php b/src/Schema.php index f5450eea..c5ba68d2 100644 --- a/src/Schema.php +++ b/src/Schema.php @@ -76,6 +76,7 @@ class Schema extends BaseObject 'bool' => self::TYPE_BOOLEAN, 'float' => self::TYPE_FLOAT, 'mva' => self::TYPE_INTEGER, + 'uint_set' => self::TYPE_INTEGER, ]; /** From 8ffcf01c434b347dd1533000be50047ab89f1f78 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:24:16 +0300 Subject: [PATCH 44/69] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d08849a1..0422cd8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Yii Framework 2 sphinx extension Change Log 2.0.16 under development ------------------------ -- no changes in this release. +- Enh #144: Add `UINT_SET` attribute type support (@vjik) 2.0.15 November 18, 2022 From 873bc93f8dd909061b002c06150abb4c2ffa5f9f Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:31:53 +0300 Subject: [PATCH 45/69] fix --- tests/data/sphinx-3.5.1.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/sphinx-3.5.1.conf b/tests/data/sphinx-3.5.1.conf index f757a0ad..8b325511 100644 --- a/tests/data/sphinx-3.5.1.conf +++ b/tests/data/sphinx-3.5.1.conf @@ -25,7 +25,7 @@ source yii2_test_article_src sql_attr_uint = author_id sql_attr_uint = add_date - sql_attr_multi = uint tag from query; SELECT article_id AS id, tag_id AS tag FROM yii2_test_article_tag + attr_uint_set = tag: SELECT article_id AS id, tag_id AS tag FROM yii2_test_article_tag } From 31da9f354c96f7d313f757a4b35a3530e0d76b3f Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:36:05 +0300 Subject: [PATCH 46/69] fix --- tests/data/sphinx-3.5.1.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/sphinx-3.5.1.conf b/tests/data/sphinx-3.5.1.conf index 8b325511..f757a0ad 100644 --- a/tests/data/sphinx-3.5.1.conf +++ b/tests/data/sphinx-3.5.1.conf @@ -25,7 +25,7 @@ source yii2_test_article_src sql_attr_uint = author_id sql_attr_uint = add_date - attr_uint_set = tag: SELECT article_id AS id, tag_id AS tag FROM yii2_test_article_tag + sql_attr_multi = uint tag from query; SELECT article_id AS id, tag_id AS tag FROM yii2_test_article_tag } From f9ec77d9be64222433d9459a5a1901e83c62b234 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:41:51 +0300 Subject: [PATCH 47/69] fix --- src/Schema.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Schema.php b/src/Schema.php index c5ba68d2..ab4797f8 100644 --- a/src/Schema.php +++ b/src/Schema.php @@ -289,6 +289,10 @@ public function getPdoType($data) ]; $type = gettype($data); + if (!isset($typeMap[$type])) { + var_dump($type); + } + return isset($typeMap[$type]) ? $typeMap[$type] : \PDO::PARAM_STR; } From a7127127d08cdfb672e2cf82ce24867d192b7987 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:45:52 +0300 Subject: [PATCH 48/69] fix --- src/Schema.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Schema.php b/src/Schema.php index ab4797f8..a1dd76ad 100644 --- a/src/Schema.php +++ b/src/Schema.php @@ -289,10 +289,6 @@ public function getPdoType($data) ]; $type = gettype($data); - if (!isset($typeMap[$type])) { - var_dump($type); - } - return isset($typeMap[$type]) ? $typeMap[$type] : \PDO::PARAM_STR; } @@ -543,7 +539,7 @@ protected function loadColumnSchema($info) $column->isField = ($type === 'field'); $column->isAttribute = !$column->isField; - $column->isMva = ($type === 'mva'); + $column->isMva = $type === 'mva' || $type === 'uint_set'; $column->phpType = $this->getColumnPhpType($column); From 26396e90314046d4c95c1343978c2df7c1656140 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:49:24 +0300 Subject: [PATCH 49/69] fix --- tests/QueryTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/QueryTest.php b/tests/QueryTest.php index 3c9363d7..969357a7 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -483,9 +483,10 @@ public function testFacets() $query = new Query(); $results = $query->from('yii2_test_article_index') ->match('about') + ->select(new Expression('INTERVAL(author_id,200,400,600,800) AS range')) ->facets([ 'range' => [ - 'select' => 'INTERVAL(author_id,200,400,600,800) AS range', + 'select' => 'range', ], 'authorId' => [ 'select' => [new Expression('author_id AS authorId')], From 0bd135f0e9eb727bbc1f73ebb6a8b94a9ae35b76 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 12:50:36 +0300 Subject: [PATCH 50/69] improve --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d10980d8..1de5146f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,6 +23,7 @@ jobs: php: - "7.2" sphinx: + - "2.2.11" - "3.5.1" steps: From 4aea790adbb89b092b765f481ea8eee1b04b5851 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:07:50 +0300 Subject: [PATCH 51/69] fix --- tests/QueryTest.php | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/tests/QueryTest.php b/tests/QueryTest.php index 969357a7..81828961 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -458,6 +458,8 @@ public function testFacets() { $connection = $this->getConnection(); + $sphinxVersion = $connection->createCommand("SHOW GLOBAL VARIABLES LIKE 'version'")->queryOne()['Value']; + $query = new Query(); $results = $query->from('yii2_test_article_index') ->match('about') @@ -480,19 +482,33 @@ public function testFacets() $this->assertNotEmpty($results['hits'], 'Unable to query with complex facet'); $this->assertNotEmpty($results['facets']['author_id'], 'Unable to fill up complex facet'); - $query = new Query(); - $results = $query->from('yii2_test_article_index') - ->match('about') - ->select(new Expression('INTERVAL(author_id,200,400,600,800) AS range')) - ->facets([ - 'range' => [ - 'select' => 'range', - ], - 'authorId' => [ - 'select' => [new Expression('author_id AS authorId')], - ], - ]) - ->search($connection); + $query = (new Query()) + ->from('yii2_test_article_index') + ->match('about'); + + if (strpos($sphinxVersion, '2.') === 0) { + $query = $query + ->facets([ + 'range' => [ + 'select' => 'INTERVAL(author_id,200,400,600,800) AS range', + ], + 'authorId' => [ + 'select' => [new Expression('author_id AS authorId')], + ], + ]); + } else { + $query = $query + ->select(new Expression('INTERVAL(author_id,200,400,600,800) AS range')) + ->facets([ + 'range' => [ + 'select' => 'range', + ], + 'authorId' => [ + 'select' => [new Expression('author_id AS authorId')], + ], + ]); + } + $results = $query->search($connection); $this->assertNotEmpty($results['hits'], 'Unable to query with facet using custom select'); $this->assertNotEmpty($results['facets']['range'], 'Unable to fill up facet using function in select'); $this->assertNotEmpty($results['facets']['authorId'], 'Unable to fill up facet using `Expression` in select'); From 9884aaad318b3cf4c37100ad832e38004f702914 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:09:30 +0300 Subject: [PATCH 52/69] fix --- tests/QueryTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/QueryTest.php b/tests/QueryTest.php index 81828961..79ed0e7b 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -459,7 +459,7 @@ public function testFacets() $connection = $this->getConnection(); $sphinxVersion = $connection->createCommand("SHOW GLOBAL VARIABLES LIKE 'version'")->queryOne()['Value']; - +var_dump($sphinxVersion); $query = new Query(); $results = $query->from('yii2_test_article_index') ->match('about') From 8472f5098d40280d272afb680714a26a32d2ea5c Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:12:19 +0300 Subject: [PATCH 53/69] fix --- tests/QueryTest.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/QueryTest.php b/tests/QueryTest.php index 79ed0e7b..67cc3a08 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -458,8 +458,6 @@ public function testFacets() { $connection = $this->getConnection(); - $sphinxVersion = $connection->createCommand("SHOW GLOBAL VARIABLES LIKE 'version'")->queryOne()['Value']; -var_dump($sphinxVersion); $query = new Query(); $results = $query->from('yii2_test_article_index') ->match('about') @@ -486,22 +484,24 @@ public function testFacets() ->from('yii2_test_article_index') ->match('about'); - if (strpos($sphinxVersion, '2.') === 0) { + try { + // Sphinx ^3 $query = $query + ->select(new Expression('INTERVAL(author_id,200,400,600,800) AS range')) ->facets([ 'range' => [ - 'select' => 'INTERVAL(author_id,200,400,600,800) AS range', + 'select' => 'range', ], 'authorId' => [ 'select' => [new Expression('author_id AS authorId')], ], ]); - } else { + } catch (\PDOException $e) { + // Sphinx ^2 $query = $query - ->select(new Expression('INTERVAL(author_id,200,400,600,800) AS range')) ->facets([ 'range' => [ - 'select' => 'range', + 'select' => 'INTERVAL(author_id,200,400,600,800) AS range', ], 'authorId' => [ 'select' => [new Expression('author_id AS authorId')], From 0a1c598ef4606399e31cf2a49565b903955fd9b8 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:18:17 +0300 Subject: [PATCH 54/69] fix --- .github/workflows/build.yml | 7 +++++++ tests/QueryTest.php | 11 ++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1de5146f..8857f14f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,14 @@ jobs: os: - ubuntu-20.04 php: + - "5.4" + - "5.5" + - "5.6" + - "7.0" + - "7.1" - "7.2" + - "7.3" + - "7.4" sphinx: - "2.2.11" - "3.5.1" diff --git a/tests/QueryTest.php b/tests/QueryTest.php index 67cc3a08..da2440f9 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -486,7 +486,7 @@ public function testFacets() try { // Sphinx ^3 - $query = $query + $results = $query ->select(new Expression('INTERVAL(author_id,200,400,600,800) AS range')) ->facets([ 'range' => [ @@ -495,10 +495,11 @@ public function testFacets() 'authorId' => [ 'select' => [new Expression('author_id AS authorId')], ], - ]); + ]) + ->search($connection); } catch (\PDOException $e) { // Sphinx ^2 - $query = $query + $results = $query ->facets([ 'range' => [ 'select' => 'INTERVAL(author_id,200,400,600,800) AS range', @@ -506,9 +507,9 @@ public function testFacets() 'authorId' => [ 'select' => [new Expression('author_id AS authorId')], ], - ]); + ]) + ->search($connection); } - $results = $query->search($connection); $this->assertNotEmpty($results['hits'], 'Unable to query with facet using custom select'); $this->assertNotEmpty($results['facets']['range'], 'Unable to fill up facet using function in select'); $this->assertNotEmpty($results['facets']['authorId'], 'Unable to fill up facet using `Expression` in select'); From c8483de7adf62fd5da1a68acb9e143a7e05d10e9 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:21:04 +0300 Subject: [PATCH 55/69] fix --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8857f14f..d75e18cf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,9 +21,9 @@ jobs: os: - ubuntu-20.04 php: - - "5.4" - - "5.5" - - "5.6" + # - "5.4" + # - "5.5" + # - "5.6" - "7.0" - "7.1" - "7.2" From ed1a9f8a0f9eff0c18970ae32a242241aa75bb9f Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:24:10 +0300 Subject: [PATCH 56/69] fix --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d75e18cf..809c9829 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,10 +25,10 @@ jobs: # - "5.5" # - "5.6" - "7.0" - - "7.1" - - "7.2" - - "7.3" - - "7.4" + # - "7.1" + # - "7.2" + # - "7.3" + # - "7.4" sphinx: - "2.2.11" - "3.5.1" From 8b98ca87674f0920941af47a087e8cf24389f6da Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:26:13 +0300 Subject: [PATCH 57/69] fix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 809c9829..66948044 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,7 +63,7 @@ jobs: - name: Setup source database run: | sudo systemctl start mysql.service - mysql -uroot -proot -e 'ALTER USER "root"@"localhost" IDENTIFIED WITH mysql_native_password BY "root";FLUSH PRIVILEGES;' + mysql -uroot -proot -e 'USE mysql;ALTER USER "root"@"localhost" IDENTIFIED WITH mysql_native_password BY "root";FLUSH PRIVILEGES;' mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql -D yiitest -uroot -proot < tests/data/source.sql From 585c13040082a2494cf2a5c527335b2b71f47549 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:31:20 +0300 Subject: [PATCH 58/69] fix --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 66948044..6a916fa3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,7 @@ jobs: # - "7.3" # - "7.4" sphinx: - - "2.2.11" + # - "2.2.11" - "3.5.1" steps: @@ -63,7 +63,8 @@ jobs: - name: Setup source database run: | sudo systemctl start mysql.service - mysql -uroot -proot -e 'USE mysql;ALTER USER "root"@"localhost" IDENTIFIED WITH mysql_native_password BY "root";FLUSH PRIVILEGES;' + mysql -uroot -proot -e 'ALTER USER "root"@"localhost" IDENTIFIED WITH mysql_native_password BY "root";' + mysql -uroot -proot -e 'FLUSH PRIVILEGES;;' mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql -D yiitest -uroot -proot < tests/data/source.sql From 18630302e69342dc24628f52a677ccbba1d9c582 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:38:37 +0300 Subject: [PATCH 59/69] fix --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a916fa3..0d6a9e81 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,8 +63,7 @@ jobs: - name: Setup source database run: | sudo systemctl start mysql.service - mysql -uroot -proot -e 'ALTER USER "root"@"localhost" IDENTIFIED WITH mysql_native_password BY "root";' - mysql -uroot -proot -e 'FLUSH PRIVILEGES;;' + mysql -uroot -proot -e 'ALTER USER root@localhost IDENTIFIED WITH mysql_native_password BY root;FLUSH PRIVILEGES;' mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql -D yiitest -uroot -proot < tests/data/source.sql From 2208e0bbad22ab09b07b746dce92b6893d4f9ec3 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:40:20 +0300 Subject: [PATCH 60/69] fix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0d6a9e81..83ce615a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,7 +63,7 @@ jobs: - name: Setup source database run: | sudo systemctl start mysql.service - mysql -uroot -proot -e 'ALTER USER root@localhost IDENTIFIED WITH mysql_native_password BY root;FLUSH PRIVILEGES;' + mysql -uroot -proot -e 'ALTER USER "root@localhost" IDENTIFIED WITH mysql_native_password BY "root";FLUSH PRIVILEGES;' mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql -D yiitest -uroot -proot < tests/data/source.sql From d5320ee007c3d06ebc3873364fc670e9d9377b41 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:42:57 +0300 Subject: [PATCH 61/69] fix --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 83ce615a..3542878b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,7 +63,8 @@ jobs: - name: Setup source database run: | sudo systemctl start mysql.service - mysql -uroot -proot -e 'ALTER USER "root@localhost" IDENTIFIED WITH mysql_native_password BY "root";FLUSH PRIVILEGES;' + echo -e '[mysqld]\ndefault_authentication_plugin=mysql_native_password' > "$HOME/.my.cnf" + mysql -uroot -proot -e 'ALTER USER "root"@"localhost" IDENTIFIED WITH mysql_native_password BY "root";FLUSH PRIVILEGES;' mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql -D yiitest -uroot -proot < tests/data/source.sql From 85f9c19a24f48c32d252b9ef14e2c14cfae973ef Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:46:39 +0300 Subject: [PATCH 62/69] fix --- .github/workflows/build.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3542878b..fb5fab02 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,6 +33,15 @@ jobs: # - "2.2.11" - "3.5.1" + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: yiitest + ports: + - 3306:3306 + steps: - name: Checkout uses: actions/checkout@v2.3.4 @@ -62,9 +71,6 @@ jobs: - name: Setup source database run: | - sudo systemctl start mysql.service - echo -e '[mysqld]\ndefault_authentication_plugin=mysql_native_password' > "$HOME/.my.cnf" - mysql -uroot -proot -e 'ALTER USER "root"@"localhost" IDENTIFIED WITH mysql_native_password BY "root";FLUSH PRIVILEGES;' mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql -D yiitest -uroot -proot < tests/data/source.sql From 616cce10d8b81054de90ab60b04c9b6b42d94dbe Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:48:18 +0300 Subject: [PATCH 63/69] fix --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fb5fab02..dace812f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,8 +71,8 @@ jobs: - name: Setup source database run: | - mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' - mysql -D yiitest -uroot -proot < tests/data/source.sql + mysql -h127.0.0.1 -uroot -proot -e 'CREATE DATABASE `yiitest`;' + mysql -h127.0.0.1 -D yiitest -uroot -proot < tests/data/source.sql - name: Run sphinx 2.2.11 if: matrix.sphinx == '2.2.11' From f854199b38d26415c1bec74c3a39450dc0be4cbe Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:49:37 +0300 Subject: [PATCH 64/69] fix --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dace812f..b4373c2a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,7 +71,6 @@ jobs: - name: Setup source database run: | - mysql -h127.0.0.1 -uroot -proot -e 'CREATE DATABASE `yiitest`;' mysql -h127.0.0.1 -D yiitest -uroot -proot < tests/data/source.sql - name: Run sphinx 2.2.11 From 73198860358c20d5fc6ee25370fdfd943a52a5b7 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:51:34 +0300 Subject: [PATCH 65/69] fix --- tests/data/sphinx-2.2.11.conf | 4 ++-- tests/data/sphinx-3.5.1.conf | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/data/sphinx-2.2.11.conf b/tests/data/sphinx-2.2.11.conf index 4a9ed53f..377dcd97 100644 --- a/tests/data/sphinx-2.2.11.conf +++ b/tests/data/sphinx-2.2.11.conf @@ -13,7 +13,7 @@ source yii2_test_article_src { type = mysql - sql_host = localhost + sql_host = 127.0.0.1 sql_user = root sql_pass = root sql_db = yiitest @@ -34,7 +34,7 @@ source yii2_test_item_src { type = mysql - sql_host = localhost + sql_host = 127.0.0.1 sql_user = root sql_pass = root sql_db = yiitest diff --git a/tests/data/sphinx-3.5.1.conf b/tests/data/sphinx-3.5.1.conf index f757a0ad..6f304e5f 100644 --- a/tests/data/sphinx-3.5.1.conf +++ b/tests/data/sphinx-3.5.1.conf @@ -13,7 +13,7 @@ source yii2_test_article_src { type = mysql - sql_host = localhost + sql_host = 127.0.0.1 sql_user = root sql_pass = root sql_db = yiitest @@ -33,7 +33,7 @@ source yii2_test_item_src { type = mysql - sql_host = localhost + sql_host = 127.0.0.1 sql_user = root sql_pass = root sql_db = yiitest From 200f91342627e26764e3bd47195364b93040485e Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:52:57 +0300 Subject: [PATCH 66/69] fix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b4373c2a..4dd1188e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,7 @@ jobs: # - "7.3" # - "7.4" sphinx: - # - "2.2.11" + - "2.2.11" - "3.5.1" services: From 97f04aa653b3f794169957e75141eed7b0f5d126 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:57:12 +0300 Subject: [PATCH 67/69] fix --- tests/QueryTest.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/QueryTest.php b/tests/QueryTest.php index da2440f9..f7697fc4 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -458,6 +458,8 @@ public function testFacets() { $connection = $this->getConnection(); + $sphinxVersion = $connection->createCommand("SHOW GLOBAL VARIABLES LIKE 'version'")->queryOne()['Value'] ?? ''; + $query = new Query(); $results = $query->from('yii2_test_article_index') ->match('about') @@ -484,9 +486,8 @@ public function testFacets() ->from('yii2_test_article_index') ->match('about'); - try { - // Sphinx ^3 - $results = $query + if (strpos($sphinxVersion, '3.') === 0) { + $query = $query ->select(new Expression('INTERVAL(author_id,200,400,600,800) AS range')) ->facets([ 'range' => [ @@ -495,11 +496,9 @@ public function testFacets() 'authorId' => [ 'select' => [new Expression('author_id AS authorId')], ], - ]) - ->search($connection); - } catch (\PDOException $e) { - // Sphinx ^2 - $results = $query + ]); + } else { + $query = $query ->facets([ 'range' => [ 'select' => 'INTERVAL(author_id,200,400,600,800) AS range', @@ -507,9 +506,9 @@ public function testFacets() 'authorId' => [ 'select' => [new Expression('author_id AS authorId')], ], - ]) - ->search($connection); + ]); } + $results = $query->search($connection); $this->assertNotEmpty($results['hits'], 'Unable to query with facet using custom select'); $this->assertNotEmpty($results['facets']['range'], 'Unable to fill up facet using function in select'); $this->assertNotEmpty($results['facets']['authorId'], 'Unable to fill up facet using `Expression` in select'); From b064d355c24a15406766de29b1222ff4a4b11083 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 13:59:04 +0300 Subject: [PATCH 68/69] improve --- .github/workflows/build.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4dd1188e..dc146ca1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,14 +21,14 @@ jobs: os: - ubuntu-20.04 php: - # - "5.4" - # - "5.5" - # - "5.6" + - "5.4" + - "5.5" + - "5.6" - "7.0" - # - "7.1" - # - "7.2" - # - "7.3" - # - "7.4" + - "7.1" + - "7.2" + - "7.3" + - "7.4" sphinx: - "2.2.11" - "3.5.1" From 9113b4ac02011b55a611b6f9f88f682d79148d4a Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 20 Mar 2024 14:01:45 +0300 Subject: [PATCH 69/69] fix --- tests/QueryTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/QueryTest.php b/tests/QueryTest.php index f7697fc4..1a502757 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -458,7 +458,8 @@ public function testFacets() { $connection = $this->getConnection(); - $sphinxVersion = $connection->createCommand("SHOW GLOBAL VARIABLES LIKE 'version'")->queryOne()['Value'] ?? ''; + $rawSphinxVersion = $connection->createCommand("SHOW GLOBAL VARIABLES LIKE 'version'")->queryOne(); + $sphinxVersion = isset($rawSphinxVersion['Value']) ? $rawSphinxVersion['Value'] : ''; $query = new Query(); $results = $query->from('yii2_test_article_index')