Skip to content

Commit

Permalink
Merge branch 'hotfix/0.21.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
garex committed Mar 19, 2018
2 parents 26d3cdf + 9cbc8a2 commit 57397fd
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ env:
matrix:
include:
- php: 7.0
env: WP_VERSION=
env: WP_VERSION= DB_CHARSET=utf8mb4
- php: 5.3
env: WP_VERSION=
- php: 5.4
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
## Changelog ##


### 0.21.10 ###

Improve database charset operations

* If your DB_CHARSET was set to utf8mb4, then you could have issues in plugin activation
* If your DB_CHARSET was set to latin1, then you could have issues with scales showing

To completely clear DB from wp-testing in case of activation issues you can use the script:

https://github.com/garex/wp-testing/blob/master/db/sql/drop-all.sql


This hotfix is mostly for those, who was having troubles with plugin activation.


### 0.21.9 ###

Update readme to latest plugin directory format.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

**Tested up to:** 4.9

**Stable tag:** 0.21.9
**Stable tag:** 0.21.10

**License:** GPLv3

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@
"source": {
"url": "https://github.com/garex/flourish-classes",
"type": "git",
"reference": "0a5b2536d9736b6fe12d8ab1b8f9ad341d2397bf"
"reference": "c826410c3edb9da885e70c6f05d714b357fb2a4a"
},
"dist": {
"url": "https://github.com/garex/flourish-classes/archive/0a5b2536d9736b6fe12d8ab1b8f9ad341d2397bf.zip",
"url": "https://github.com/garex/flourish-classes/archive/c826410c3edb9da885e70c6f05d714b357fb2a4a.zip",
"type": "zip"
}
}
Expand Down
18 changes: 9 additions & 9 deletions composer.lock.dist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions db/migrations/wp_testing/Base/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ abstract public function down();

public function execute($query)
{
$this->adaptee->get_adapter()->logger->log(trim($query, ';') . ';');

return $this->adaptee->execute($query);
}

Expand Down
42 changes: 19 additions & 23 deletions db/sql/drop-all.sql
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
-- SHOW TABLE STATUS;
-- All table names here use default table prefix "wp_"
-- It's defined in your wp-config.php by string like:
-- $table_prefix = 'wp_';
-- If your setting not default, then just replace in this script "wp_" onto your setting.

-- DROP SCHEMA IF EXISTS wp_testing2; CREATE SCHEMA wp_testing2;

-- USE wp_testing;
-- !!! WARNING !!!
-- This script will erase completely your's database part, related to wp-testing plugin.
-- So if you alerady has some tests/passings/scores, then you must not run this script.
-- !!! WARNING !!!

SET FOREIGN_KEY_CHECKS = 0;

DROP TABLE IF EXISTS wp_t_answers;
DROP TABLE IF EXISTS wp_t_answers_parameters;
DROP TABLE IF EXISTS wp_t_parameters;
DROP TABLE IF EXISTS wp_t_questions;
DROP TABLE IF EXISTS wp_t_scales;
DROP TABLE IF EXISTS wp_t_scales_tests;
DROP TABLE IF EXISTS wp_t_schema_migrations;
DROP TABLE IF EXISTS wp_t_tests;

DROP TABLE IF EXISTS wp_t_field_values;
DROP TABLE IF EXISTS wp_t_formulas;
DROP TABLE IF EXISTS wp_t_passing_answers;
DROP TABLE IF EXISTS wp_t_passings;
DROP TABLE IF EXISTS wp_t_scores;
DROP TABLE IF EXISTS wp_t_sections;
DROP TABLE IF EXISTS wp_t_answers;
DROP TABLE IF EXISTS wp_t_fields;
DROP TABLE IF EXISTS wp_t_questions;
DROP TABLE IF EXISTS wp_t_computed_variables;

SET FOREIGN_KEY_CHECKS = 1;

DELETE FROM wp_posts WHERE post_title LIKE '%EPI%';
DELETE FROM wp_terms WHERE term_id > 1;
DELETE FROM wp_postmeta WHERE post_id NOT IN (
SELECT ID FROM wp_posts
);

DELETE FROM wp_term_relationships WHERE object_id NOT IN (
SELECT ID FROM wp_posts
);
DELETE FROM wp_term_taxonomy where taxonomy like 'wpt\_%';

DELETE FROM wp_postmeta where meta_key like 'wpt_%';
DELETE FROM wp_posts WHERE post_type = 'wpt_test';
DELETE FROM wp_term_taxonomy where taxonomy like 'wpt_%';
DELETE FROM wp_term_relationships WHERE term_taxonomy_id NOT IN (SELECT term_taxonomy_id FROM wp_term_taxonomy);
DELETE FROM wp_terms WHERE term_id NOT IN (SELECT term_id FROM wp_term_taxonomy);
7 changes: 6 additions & 1 deletion src/Doer/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ private function setNetworkWide($value = null)

private function upgradeOnBlog()
{
$this->migrateDatabase(array(__FILE__, 'db:migrate'));
$this->migrateDatabase(array(__FILE__, 'db:setup', 'env=fixed-charset'));
$this->migrateDatabase(array(__FILE__, 'db:migrate', 'env=development'));
new WpTesting_Doer_WordPressEntitiesRegistrator($this->wp);
$this->flushRewrite();
}
Expand Down Expand Up @@ -183,11 +184,15 @@ private function migrateDatabase($argv)
'pluginPrefix' => $wptPrefix,
'schema_version_table_name' => $wptPrefix . 'schema_migrations',
),
'fixed-charset' => array(
'charset' => 'utf8',
),
),
'db_dir' => $databaseDirectory,
'migrations_dir' => array('default' => $databaseDirectory . '/migrations'),
'log_dir' => $this->wp->getTempDir() . 'wp_testing_' . md5(__FILE__),
);
$config['db']['fixed-charset'] = array_merge($config['db']['development'], $config['db']['fixed-charset']);

$runner = new Ruckusing_FrameworkRunner($config, $argv);
restore_error_handler();
Expand Down
12 changes: 11 additions & 1 deletion src/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,21 @@ public function setupORM()
// Extract port from host. See wpdb::db_connect
$port = null;
$host = $this->wp->getDbHost();
$m = array();
if (preg_match('/^(.+):(\d+)$/', trim($host), $m)) {
$host = $m[1];
$port = $m[2];
}
$database = new fDatabase('mysql', $this->wp->getDbName(), $this->wp->getDbUser(), $this->wp->getDbPassword(), $host, $port);
$database = new fDatabase(
'mysql',
$this->wp->getDbName(),
$this->wp->getDbUser(),
$this->wp->getDbPassword(),
$host,
$port,
null,
$this->wp->getDbCharset()
);
fORMDatabase::attach($database);

fORM::mapClassToTable('WpTesting_Model_Test', $wpPrefix . 'posts');
Expand Down
2 changes: 1 addition & 1 deletion tests/integration-environment/create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function install_wp {
log '.. patching wordpress'
patch -p0 < $WP_PATCH
fi
cp ../wp-config.php wp-config.php
cat ../wp-config.php | sed 's/utf8/'$DB_CHARSET'/' > wp-config.php
log '.. installing'
wget --quiet --output-document=- --post-data='weblog_title=wpti&user_name=wpti&admin_password=wpti&admin_password2=wpti&admin_email=wpti%40wpti.dev&blog_public=1' $WP_T_SERVER'/wp-admin/install.php?step=2' | grep installed
}
Expand Down
3 changes: 2 additions & 1 deletion tests/phpunit/Mock/WordPressFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getTablePrefix()

public function getDbCharset()
{
return 'utf-8';
return $this->db['charset'];
}

public function isMultisite()
Expand Down Expand Up @@ -154,6 +154,7 @@ public function getExtended($post)
// Version from 4.3

// Match the new style more links.
$matches = array();
if (preg_match('/<!--more(.*?)?-->/', $post, $matches)) {
list($main, $extended) = explode($matches[0], $post, 2);
$more_text = $matches[1];
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/Model/QuestionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ protected function tearDown()

public function testQuestionSavedInUtfEncoding()
{
$link = $this->db->getConnection();

$question = new WpTesting_Model_Question();
$question->setTitle('راهنمایی برای ایجاد آزمون های روانشناسی.')->setTestId(1);
$id = $question->store()->getId();
Expand Down
2 changes: 1 addition & 1 deletion wp-testing.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Wp-testing
* Plugin URI: http://wordpress.org/extend/plugins/wp-testing/
* Description: Helps to create psychological tests.
* Version: 0.21.9
* Version: 0.21.10
* Author: Alexander Ustimenko
* Author URI: http://ustimen.co
* License: GPL3
Expand Down

0 comments on commit 57397fd

Please sign in to comment.