Fix reading bool index setting & deprecate ElasticsearchException #1251

Merged
merged 5 commits into from Feb 20, 2017

Conversation

Projects
None yet
2 participants
@Tobion
Collaborator

Tobion commented Feb 16, 2017

  • Use the explicit getter Response::getStatus instead of the curl transfer info
  • Fix reading bool index setting, e.g. when it uses 'off' instead of '0' (where just casting to bool doesn't work)
  • Deprecate ElasticsearchException which is irrelevant since elasticsearch now exposes the errors as a structured array instead of a single string. So the whole purpose of the class is gone.
  • Add test to show #457 is solved by now
@@ -133,13 +126,7 @@ public function getFullError()
*/
public function getErrorMessage()
{
- $error = $this->getError();
-
- if (!is_string($error)) {

This comment has been minimized.

@Tobion

Tobion Feb 16, 2017

Collaborator

getError always returns string. So this is useless

@Tobion

Tobion Feb 16, 2017

Collaborator

getError always returns string. So this is useless

This comment has been minimized.

@ruflin

ruflin Feb 20, 2017

Owner

Not sure if we introduced this to make master "partially" compatible with 2.x. Happy to remove it now and lets readd it in case things break ...

@ruflin

ruflin Feb 20, 2017

Owner

Not sure if we introduced this to make master "partially" compatible with 2.x. Happy to remove it now and lets readd it in case things break ...

- *
- * @var bool Error
- */
- protected $_error = false;

This comment has been minimized.

@Tobion

Tobion Feb 16, 2017

Collaborator

Property that doesn't even have a getter and is not really used

@Tobion

Tobion Feb 16, 2017

Collaborator

Property that doesn't even have a getter and is not really used

@@ -185,13 +194,12 @@ public function setBlocksWrite($state = true)
*/
public function getBlocksMetadata()
{
- // TODO will have to be replace by block.metadata.write once https://github.com/elasticsearch/elasticsearch/pull/9203 has been fixed

This comment has been minimized.

@Tobion

Tobion Feb 16, 2017

Collaborator

This has been merged and makes it possible to use the correct read_only setting again which was changed in #738

@Tobion

Tobion Feb 16, 2017

Collaborator

This has been merged and makes it possible to use the correct read_only setting again which was changed in #738

- * @param int $code Error code
- * @param array $error Error object from elasticsearch
+ * @param int $code Error code
+ * @param string $error Error message from elasticsearch

This comment has been minimized.

@Tobion

Tobion Feb 17, 2017

Collaborator

This has been string before and is still receiving a string in https://github.com/ruflin/Elastica/pull/1251/files#diff-38e97e4d9ad047da8141046011e72f90R66

@Tobion

Tobion Feb 17, 2017

Collaborator

This has been string before and is still receiving a string in https://github.com/ruflin/Elastica/pull/1251/files#diff-38e97e4d9ad047da8141046011e72f90R66

@ruflin

ruflin approved these changes Feb 20, 2017

@@ -103,6 +103,25 @@ public function get($setting = '')
}
+ /**
+ * Returns a setting interpreted as a bool.

This comment has been minimized.

@ruflin

ruflin Feb 20, 2017

Owner

Nice addition. I hope that ES will also clean this up in the future and only have 1 option of returning bools.

@ruflin

ruflin Feb 20, 2017

Owner

Nice addition. I hope that ES will also clean this up in the future and only have 1 option of returning bools.

@@ -133,13 +126,7 @@ public function getFullError()
*/
public function getErrorMessage()
{
- $error = $this->getError();
-
- if (!is_string($error)) {

This comment has been minimized.

@ruflin

ruflin Feb 20, 2017

Owner

Not sure if we introduced this to make master "partially" compatible with 2.x. Happy to remove it now and lets readd it in case things break ...

@ruflin

ruflin Feb 20, 2017

Owner

Not sure if we introduced this to make master "partially" compatible with 2.x. Happy to remove it now and lets readd it in case things break ...

@ruflin ruflin merged commit cad28fd into ruflin:master Feb 20, 2017

1 of 3 checks passed

codecov/patch 77.77% of diff hit (target 84.55%)
Details
codecov/project 84.31% (-0.25%) compared to 07a7701
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Tobion Tobion deleted the Tobion:fix-error-handling branch Feb 20, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment