Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed issue adding same value twice if value was not initially an array on Document::setMultiValue call #1

Merged
merged 1 commit into from

2 participants

@picur

No description provided.

@Korotkin-Solutions Korotkin-Solutions merged commit 5366994 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 9, 2012
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 11 deletions.
  1. +14 −11 root_folder/classes/kosolr/document.php
View
25 root_folder/classes/kosolr/document.php
@@ -9,7 +9,7 @@
class KoSolr_Document
{
- private $_data=array();
+ private $_data = array();
/**
* Magic Getter
@@ -18,8 +18,7 @@ class KoSolr_Document
*/
public function __get($name)
{
- if (array_key_exists($name, $this->_data))
- {
+ if (array_key_exists($name, $this->_data)) {
return $this->_data[$name];
}
}
@@ -62,6 +61,8 @@ public function getArrayData()
public function setField($name, $value)
{
$this->__set($name, $value);
+
+ return $this;
}
/**
* Set multiple value always addes
@@ -70,15 +71,17 @@ public function setField($name, $value)
*/
public function setMultiValue($name, $value)
{
- if(!$this->__isset($name))
- $this->setField($name, $value);
-
- if(!is_array($this->_data[$name]))
- {
- $old = $this->__get($name);
- $this->setField($name, array($value));
+ if (!$this->__isset($name)) {
+ $this->setField($name, !is_array($value) ? array($value) : $value);
+ return $this;
+ }
+
+ if (!is_array($this->_data[$name])) {
+ $this->__set($name, array($this->_data[$name]));
}
-
+
$this->_data[$name][] = $value;
+
+ return $this;
}
}
Something went wrong with that request. Please try again.