diff --git a/plugins/API/API.php b/plugins/API/API.php index 635840afda00b1ca72e014fca66d7d2f88ef7c59..34f0ad5bb54775d2a4af982e10338a4c59a155fe 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -161,11 +161,7 @@ class API extends \Piwik\Plugin\API 'segment' => 'userId', 'acceptedValues' => 'any non empty unique string identifying the user (such as an email address or a username).', 'sqlSegment' => 'log_visit.user_id', - 'sqlFilter' => array($this, 'checkSegmentMatchTypeIsValidForUser'), 'permission' => $isAuthenticatedWithViewAccess, - - // TODO specify that this segment is not compatible with some operators -// 'unsupportedOperators' = array(MATCH_CONTAINS, MATCH_DOES_NOT_CONTAIN), ); $segments[] = array( @@ -241,32 +237,6 @@ class API extends \Piwik\Plugin\API return $compare; } - /** - * Throw an exception if the User ID segment is used with an un-supported match type, - * - * @ignore - * @param $value - * @param $sqlSegment - * @param $matchType - * @param $name - * @return $value - * @throws \Exception - */ - public function checkSegmentMatchTypeIsValidForUser($value, $sqlSegment, $matchType, $name) - { - $acceptedMatches = array( - SegmentExpression::MATCH_EQUAL, - SegmentExpression::MATCH_IS_NOT_NULL_NOR_EMPTY, - SegmentExpression::MATCH_IS_NULL_OR_EMPTY, - SegmentExpression::MATCH_NOT_EQUAL, - ); - if (in_array($matchType, $acceptedMatches)) { - return $value; - } - $message = "Invalid Segment match type: try using 'userId' segment with one of the following match types: %s."; - throw new \Exception(sprintf($message, implode(", ", $acceptedMatches))); - } - /** * Returns the url to application logo (~280x110px) * diff --git a/tests/PHPUnit/System/UserIdAndVisitorIdTest.php b/tests/PHPUnit/System/UserIdAndVisitorIdTest.php index 3283fe54c154dcc21caf32120fe2651e14d5b061..7e3acbcf975169fbd12d8e9e4e48772c3a2698f8 100644 --- a/tests/PHPUnit/System/UserIdAndVisitorIdTest.php +++ b/tests/PHPUnit/System/UserIdAndVisitorIdTest.php @@ -75,16 +75,6 @@ class UserIdAndVisitorIdTest extends SystemTestCase 'testSuffix' => '_segmentUserId', )), - // Test invalid segment match type throws exception - array('VisitsSummary.get', - array('idSite' => self::$fixture->idSite, - 'date' => self::$fixture->dateTime, - 'periods' => 'day', - 'segment' => 'userId=@invalidSegment', - 'testSuffix' => '_invalidSegmentUserId', - )), - - // Testing userId segment matches both log_visits and log_conversion array('Goals.getItemsName', array('idSite' => self::$fixture->idSite, diff --git a/tests/PHPUnit/System/expected/test_UserId_VisitorId_invalidSegmentUserId__VisitsSummary.get_day.xml b/tests/PHPUnit/System/expected/test_UserId_VisitorId_invalidSegmentUserId__VisitsSummary.get_day.xml deleted file mode 100644 index 71903c4801a5c38bfa04c7cf486200ccfd27b465..0000000000000000000000000000000000000000 --- a/tests/PHPUnit/System/expected/test_UserId_VisitorId_invalidSegmentUserId__VisitsSummary.get_day.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<result> - <error message="Invalid Segment match type: try using 'userId' segment with one of the following match types: ==, ::NOT_NULL, ::NULL, !=. - - --> To temporarily debug this error further, set const PIWIK_PRINT_ERROR_BACKTRACE=true; in index.php" /> -</result> \ No newline at end of file