Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
a5a462f8
Commit
a5a462f8
authored
Sep 10, 2015
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #360 from basdenooijer/develop
Improvements based on SensioLabs Insight analysis
parents
b473ccaa
ad6e9508
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
67 additions
and
47 deletions
+67
-47
library/Solarium/Client.php
library/Solarium/Client.php
+2
-2
library/Solarium/Core/Client/Client.php
library/Solarium/Core/Client/Client.php
+43
-26
library/Solarium/Core/Configurable.php
library/Solarium/Core/Configurable.php
+4
-4
library/Solarium/Core/Query/AbstractRequestBuilder.php
library/Solarium/Core/Query/AbstractRequestBuilder.php
+1
-1
library/Solarium/Plugin/Loadbalancer/Loadbalancer.php
library/Solarium/Plugin/Loadbalancer/Loadbalancer.php
+1
-1
library/Solarium/Plugin/Loadbalancer/WeightedRandomChoice.php
...ary/Solarium/Plugin/Loadbalancer/WeightedRandomChoice.php
+0
-1
library/Solarium/QueryType/Extract/RequestBuilder.php
library/Solarium/QueryType/Extract/RequestBuilder.php
+1
-1
library/Solarium/QueryType/MoreLikeThis/ResponseParser.php
library/Solarium/QueryType/MoreLikeThis/ResponseParser.php
+1
-1
library/Solarium/QueryType/MoreLikeThis/Result.php
library/Solarium/QueryType/MoreLikeThis/Result.php
+1
-1
library/Solarium/QueryType/Select/Query/Component/FacetSet.php
...ry/Solarium/QueryType/Select/Query/Component/FacetSet.php
+0
-1
library/Solarium/QueryType/Select/Query/Component/Stats/Stats.php
...Solarium/QueryType/Select/Query/Component/Stats/Stats.php
+0
-1
library/Solarium/QueryType/Select/Query/Query.php
library/Solarium/QueryType/Select/Query/Query.php
+1
-2
library/Solarium/QueryType/Update/Result.php
library/Solarium/QueryType/Update/Result.php
+2
-2
tests/Solarium/Tests/Core/Client/ClientTest.php
tests/Solarium/Tests/Core/Client/ClientTest.php
+10
-3
No files found.
library/Solarium/Client.php
View file @
a5a462f8
...
...
@@ -95,8 +95,8 @@ class Client extends CoreClient
* - 1.2.4 (higher)
*
*
*
@internal a
string compare is used instead of version_compare because
*
version_compare returns false for a compare of 1.0.0 with 1.0
*
A
string compare is used instead of version_compare because
* version_compare returns false for a compare of 1.0.0 with 1.0
*
* @param string $version
*
...
...
library/Solarium/Core/Client/Client.php
View file @
a5a462f8
...
...
@@ -217,6 +217,23 @@ class Client extends Configurable
*/
protected
$adapter
;
/**
* Constructor.
*
* If options are passed they will be merged with {@link $options} using
* the {@link setOptions()} method.
*
* If an EventDispatcher instance is provided this will be used instead of creating a new instance
*
* @param array|\Zend_Config $options
* @param EventDispatcher $eventDispatcher
*/
public
function
__construct
(
$options
=
null
,
$eventDispatcher
=
null
)
{
$this
->
eventDispatcher
=
$eventDispatcher
;
parent
::
__construct
(
$options
);
}
/**
* Create a endpoint instance.
*
...
...
@@ -243,7 +260,7 @@ class Client extends Configurable
if
(
$endpoint
->
getKey
()
!==
null
)
{
$this
->
addEndpoint
(
$endpoint
);
if
(
$setAsDefault
==
true
)
{
if
(
$setAsDefault
==
=
true
)
{
$this
->
setDefaultEndpoint
(
$endpoint
);
}
}
...
...
@@ -276,7 +293,6 @@ class Client extends Configurable
}
//double add calls for the same endpoint are ignored, but non-unique keys cause an exception
//@todo add trigger_error with a notice for double add calls?
if
(
array_key_exists
(
$key
,
$this
->
endpoints
)
&&
$this
->
endpoints
[
$key
]
!==
$endpoint
)
{
throw
new
InvalidArgumentException
(
'An endpoint must have a unique key'
);
}
else
{
...
...
@@ -799,6 +815,9 @@ class Client extends Configurable
/**
* Execute a ping query.
*
* This is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API.
*
* Example usage:
* <code>
* $client = new Solarium\Client;
...
...
@@ -808,9 +827,6 @@ class Client extends Configurable
*
* @see Solarium\QueryType\Ping
*
* @internal This is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API.
*
* @param QueryInterface|\Solarium\QueryType\Ping\Query $query
* @param Endpoint|string|null $endpoint
*
...
...
@@ -824,6 +840,9 @@ class Client extends Configurable
/**
* Execute an update query.
*
* This is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API.
*
* Example usage:
* <code>
* $client = new Solarium\Client;
...
...
@@ -835,9 +854,6 @@ class Client extends Configurable
* @see Solarium\QueryType\Update
* @see Solarium\Result\Update
*
* @internal This is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API.
*
* @param QueryInterface|\Solarium\QueryType\Update\Query\Query $query
* @param Endpoint|string|null $endpoint
*
...
...
@@ -851,6 +867,9 @@ class Client extends Configurable
/**
* Execute a select query.
*
* This is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API.
*
* Example usage:
* <code>
* $client = new Solarium\Client;
...
...
@@ -861,9 +880,6 @@ class Client extends Configurable
* @see Solarium\QueryType\Select
* @see Solarium\Result\Select
*
* @internal This is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API.
*
* @param QueryInterface|\Solarium\QueryType\Select\Query\Query $query
* @param Endpoint|string|null $endpoint
*
...
...
@@ -877,6 +893,9 @@ class Client extends Configurable
/**
* Execute a MoreLikeThis query.
*
* This is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API.
*
* Example usage:
* <code>
* $client = new Solarium\Client;
...
...
@@ -887,9 +906,6 @@ class Client extends Configurable
* @see Solarium\QueryType\MoreLikeThis
* @see Solarium\Result\MoreLikeThis
*
* @internal This is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API.
*
* @param QueryInterface|\Solarium\QueryType\MoreLikeThis\Query $query
* @param Endpoint|string|null $endpoint
*
...
...
@@ -903,8 +919,8 @@ class Client extends Configurable
/**
* Execute an analysis query.
*
*
@internal
This is a convenience method that forwards the query to the
*
execute method, thus allowing for an easy to use and clean API.
* This is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API.
*
* @param QueryInterface|\Solarium\QueryType\Analysis\Query\Document|\Solarium\QueryType\Analysis\Query\Field $query
* @param Endpoint|string|null $endpoint
...
...
@@ -919,8 +935,8 @@ class Client extends Configurable
/**
* Execute a terms query.
*
*
@internal
This is a convenience method that forwards the query to the
*
execute method, thus allowing for an easy to use and clean API.
* This is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API.
*
* @param QueryInterface|\Solarium\QueryType\Terms\Query $query
* @param Endpoint|string|null $endpoint
...
...
@@ -935,8 +951,8 @@ class Client extends Configurable
/**
* Execute a suggester query.
*
*
@internal
This is a convenience method that forwards the query to the
*
execute method, thus allowing for an easy to use and clean API.
* This is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API.
*
* @param QueryInterface|\Solarium\QueryType\Suggester\Query $query
* @param Endpoint|string|null $endpoint
...
...
@@ -951,8 +967,8 @@ class Client extends Configurable
/**
* Execute an extract query.
*
*
@internal
This is a convenience method that forwards the query to the
*
execute method, thus allowing for an easy to use and clean API.
* This is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API.
*
* @param QueryInterface|\Solarium\QueryType\Extract\Query $query
* @param Endpoint|string|null $endpoint
...
...
@@ -967,8 +983,8 @@ class Client extends Configurable
/**
* Execute a RealtimeGet query.
*
*
@internal
This is a convenience method that forwards the query to the
*
execute method, thus allowing for an easy to use and clean API.
* This is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API.
*
* @param QueryInterface|\Solarium\QueryType\RealtimeGet\Query $query
* @param Endpoint|string|null $endpoint
...
...
@@ -1144,8 +1160,9 @@ class Client extends Configurable
*/
protected
function
init
()
{
//@todo use injection
$this
->
eventDispatcher
=
new
EventDispatcher
();
if
(
$this
->
eventDispatcher
===
null
)
{
$this
->
eventDispatcher
=
new
EventDispatcher
();
}
foreach
(
$this
->
options
as
$name
=>
$value
)
{
switch
(
$name
)
{
...
...
library/Solarium/Core/Configurable.php
View file @
a5a462f8
...
...
@@ -108,7 +108,7 @@ class Configurable implements ConfigurableInterface
}
}
if
(
true
==
$overwrite
)
{
if
(
true
==
=
$overwrite
)
{
$this
->
options
=
$options
;
}
else
{
$this
->
options
=
array_merge
(
$this
->
options
,
$options
);
...
...
@@ -157,9 +157,9 @@ class Configurable implements ConfigurableInterface
* This hook is called by the constructor after saving the constructor
* arguments in {@link $options}
*
*
@internal
This empty implementation can optionally be implemented in
*
descending classes. It's not an abstract method on purpose, there are
*
many cases where no initialization is needed.
* This empty implementation can optionally be implemented in
* descending classes. It's not an abstract method on purpose, there are
* many cases where no initialization is needed.
*/
protected
function
init
()
{
...
...
library/Solarium/Core/Query/AbstractRequestBuilder.php
View file @
a5a462f8
...
...
@@ -118,7 +118,7 @@ abstract class AbstractRequestBuilder implements RequestBuilderInterface
public
function
boolAttrib
(
$name
,
$value
)
{
if
(
null
!==
$value
)
{
$value
=
(
true
==
$value
)
?
'true'
:
'false'
;
$value
=
(
true
==
=
(
bool
)
$value
)
?
'true'
:
'false'
;
return
$this
->
attrib
(
$name
,
$value
);
}
else
{
...
...
library/Solarium/Plugin/Loadbalancer/Loadbalancer.php
View file @
a5a462f8
...
...
@@ -469,7 +469,7 @@ class Loadbalancer extends AbstractPlugin
$this
->
endpointExcludes
=
array
();
// reset for each query
$adapter
=
$this
->
client
->
getAdapter
();
if
(
$this
->
getFailoverEnabled
()
==
true
)
{
if
(
$this
->
getFailoverEnabled
()
==
=
true
)
{
$maxRetries
=
$this
->
getFailoverMaxRetries
();
for
(
$i
=
0
;
$i
<=
$maxRetries
;
$i
++
)
{
$endpoint
=
$this
->
getRandomEndpoint
();
...
...
library/Solarium/Plugin/Loadbalancer/WeightedRandomChoice.php
View file @
a5a462f8
...
...
@@ -110,7 +110,6 @@ class WeightedRandomChoice
}
// continue until a non-excluded value is found
// @todo optimize?
$result
=
null
;
while
(
1
)
{
$result
=
$this
->
values
[
$this
->
getKey
()];
...
...
library/Solarium/QueryType/Extract/RequestBuilder.php
View file @
a5a462f8
...
...
@@ -80,7 +80,7 @@ class RequestBuilder extends BaseRequestBuilder
}
// add document settings to request
if
((
$doc
=
$query
->
getDocument
())
!=
null
)
{
if
((
$doc
=
$query
->
getDocument
())
!=
=
null
)
{
if
(
$doc
->
getBoost
()
!==
null
)
{
throw
new
RuntimeException
(
'Extract does not support document-level boosts, use field boosts instead.'
);
}
...
...
library/Solarium/QueryType/MoreLikeThis/ResponseParser.php
View file @
a5a462f8
...
...
@@ -71,7 +71,7 @@ class ResponseParser extends SelectResponseParser
$parseResult
[
'interestingTerms'
]
=
$terms
;
}
if
(
isset
(
$data
[
'match'
][
'docs'
][
0
])
&&
true
==
$query
->
getMatchInclude
())
{
if
(
isset
(
$data
[
'match'
][
'docs'
][
0
])
&&
true
==
=
$query
->
getMatchInclude
())
{
$matchData
=
$data
[
'match'
][
'docs'
][
0
];
$documentClass
=
$query
->
getOption
(
'documentclass'
);
...
...
library/Solarium/QueryType/MoreLikeThis/Result.php
View file @
a5a462f8
...
...
@@ -119,7 +119,7 @@ class Result extends SelectResult
public
function
getMatch
()
{
$query
=
$this
->
getQuery
();
if
(
true
!=
$query
->
getMatchInclude
())
{
if
(
true
!=
=
$query
->
getMatchInclude
())
{
throw
new
UnexpectedValueException
(
'matchinclude was disabled in the MLT query'
);
}
$this
->
parseResponse
();
...
...
library/Solarium/QueryType/Select/Query/Component/FacetSet.php
View file @
a5a462f8
...
...
@@ -319,7 +319,6 @@ class FacetSet extends AbstractComponent
}
//double add calls for the same facet are ignored, but non-unique keys cause an exception
//@todo add trigger_error with a notice for double add calls?
if
(
array_key_exists
(
$key
,
$this
->
facets
)
&&
$this
->
facets
[
$key
]
!==
$facet
)
{
throw
new
InvalidArgumentException
(
'A facet must have a unique key value within a query'
);
}
else
{
...
...
library/Solarium/QueryType/Select/Query/Component/Stats/Stats.php
View file @
a5a462f8
...
...
@@ -152,7 +152,6 @@ class Stats extends AbstractComponent
}
//double add calls for the same field are ignored, but non-unique keys cause an exception
//@todo add trigger_error with a notice for double add calls?
if
(
array_key_exists
(
$key
,
$this
->
fields
)
&&
$this
->
fields
[
$key
]
!==
$field
)
{
throw
new
InvalidArgumentException
(
'A field must have a unique key value'
);
}
else
{
...
...
library/Solarium/QueryType/Select/Query/Query.php
View file @
a5a462f8
...
...
@@ -634,7 +634,6 @@ class Query extends BaseQuery
}
//double add calls for the same FQ are ignored, but non-unique keys cause an exception
//@todo add trigger_error with a notice for double add calls?
if
(
array_key_exists
(
$key
,
$this
->
filterQueries
)
&&
$this
->
filterQueries
[
$key
]
!==
$filterQuery
)
{
throw
new
InvalidArgumentException
(
'A filterquery must have a unique key value within a query'
);
}
else
{
...
...
@@ -792,7 +791,7 @@ class Query extends BaseQuery
if
(
isset
(
$this
->
components
[
$key
]))
{
return
$this
->
components
[
$key
];
}
else
{
if
(
$autoload
==
true
)
{
if
(
$autoload
==
=
true
)
{
if
(
!
isset
(
$this
->
componentTypes
[
$key
]))
{
throw
new
OutOfBoundsException
(
'Cannot autoload unknown component: '
.
$key
);
}
...
...
library/Solarium/QueryType/Update/Result.php
View file @
a5a462f8
...
...
@@ -48,8 +48,8 @@ use Solarium\Core\Query\Result\QueryType as BaseResult;
* An update query only returns a query time and status. Both are accessible
* using the methods provided by {@link Solarium\Result\Query}.
*
*
@internal
For now this class only exists to distinguish the different result
*
types. It might get some extra behaviour in the future.
* For now this class only exists to distinguish the different result
* types. It might get some extra behaviour in the future.
*/
class
Result
extends
BaseResult
{
...
...
tests/Solarium/Tests/Core/Client/ClientTest.php
View file @
a5a462f8
...
...
@@ -121,9 +121,16 @@ class ClientTest extends \PHPUnit_Framework_TestCase
*/
public
function
testGetEventDispatcher
()
{
$this
->
assertInstanceOf
(
'\Symfony\Component\EventDispatcher\EventDispatcherInterface'
,
$this
->
client
->
getEventDispatcher
());
$event_dispatcher
=
$this
->
getMock
(
'\Symfony\Component\EventDispatcher\EventDispatcherInterface'
);
$this
->
client
->
setEventDispatcher
(
$event_dispatcher
);
$this
->
assertSame
(
$event_dispatcher
,
$this
->
client
->
getEventDispatcher
());
$eventDispatcher
=
$this
->
getMock
(
'\Symfony\Component\EventDispatcher\EventDispatcherInterface'
);
$this
->
client
->
setEventDispatcher
(
$eventDispatcher
);
$this
->
assertSame
(
$eventDispatcher
,
$this
->
client
->
getEventDispatcher
());
}
public
function
testEventDispatcherInjection
()
{
$eventDispatcher
=
$this
->
getMock
(
'\Symfony\Component\EventDispatcher\EventDispatcherInterface'
);
$client
=
new
Client
(
null
,
$eventDispatcher
);
$this
->
assertSame
(
$eventDispatcher
,
$client
->
getEventDispatcher
());
}
public
function
testConfigModeWithoutKeys
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment