remove logging function (polluting unit tests) & bugfix on model subscriber addToSegments
This commit is contained in:
@ -56,9 +56,6 @@ class Initializer {
|
|||||||
\ORM::configure('username', Env::$db_username);
|
\ORM::configure('username', Env::$db_username);
|
||||||
\ORM::configure('password', Env::$db_password);
|
\ORM::configure('password', Env::$db_password);
|
||||||
\ORM::configure('logging', WP_DEBUG);
|
\ORM::configure('logging', WP_DEBUG);
|
||||||
\ORM::configure('logger', function($query, $time) {
|
|
||||||
error_log("\n(Time: ".sprintf('%05f', $time).")".$query."\n");
|
|
||||||
});
|
|
||||||
|
|
||||||
\ORM::configure('driver_options', array(
|
\ORM::configure('driver_options', array(
|
||||||
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
|
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
|
||||||
|
@ -35,10 +35,15 @@ class Subscriber extends Model {
|
|||||||
function addToSegments(array $segment_ids = array()) {
|
function addToSegments(array $segment_ids = array()) {
|
||||||
$wp_users_segment = Segment::getWPUsers();
|
$wp_users_segment = Segment::getWPUsers();
|
||||||
|
|
||||||
|
if($wp_users_segment !== false) {
|
||||||
// delete all relations to segments except WP users
|
// delete all relations to segments except WP users
|
||||||
SubscriberSegment::where('subscriber_id', $this->id)
|
SubscriberSegment::where('subscriber_id', $this->id)
|
||||||
->whereNotEqual('segment_id', $wp_users_segment->id)
|
->whereNotEqual('segment_id', $wp_users_segment->id)
|
||||||
->deleteMany();
|
->deleteMany();
|
||||||
|
} else {
|
||||||
|
// delete all relations to segments
|
||||||
|
SubscriberSegment::where('subscriber_id', $this->id)->deleteMany();
|
||||||
|
}
|
||||||
|
|
||||||
if(!empty($segment_ids)) {
|
if(!empty($segment_ids)) {
|
||||||
$segments = Segment::whereIn('id', $segment_ids)->findMany();
|
$segments = Segment::whereIn('id', $segment_ids)->findMany();
|
||||||
|
Reference in New Issue
Block a user