Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: intel352/ActiveDocument
base: f232ab4169
...
head fork: intel352/ActiveDocument
compare: d7ca3967c7
Checking mergeability… Don't worry, you can still create the pull request.
  • 6 commits
  • 4 files changed
  • 0 commit comments
  • 2 contributors
Showing with 60 additions and 21 deletions.
  1. +1 −1  .hgsubstate
  2. +23 −12 Document.php
  3. +20 −4 Form.php
  4. +16 −4 drivers/riak/Adapter.php
View
2  .hgsubstate
@@ -1,2 +1,2 @@
bb787e3b7479db787a8842188d65dac6be937533 docs
-12690602f08cd666d88a33c24fc340d775e1fb32 vendors/riiak
+e248a594e86034d0c4502ee4d28b84fb7ad784f6 vendors/riiak
View
35 Document.php
@@ -220,7 +220,7 @@ public function setIsNewRecord($value) {
* @return boolean True if the object has been modified.
*/
public function getIsModified() {
- return !empty($this->_modifiedAttributes);
+ return $this->getModifiedAttributes()!==array();
}
/**
@@ -231,7 +231,7 @@ public function getIsModified() {
* @return boolean True if $attr has been modified.
*/
public function isAttributeModified($attr) {
- return in_array($attr, $this->_modifiedAttributes);
+ return in_array($attr, $this->getModifiedAttributes());
}
/**
@@ -240,7 +240,16 @@ public function isAttributeModified($attr) {
* @return array A unique list of the modified attribute names for this object.
*/
public function getModifiedAttributes() {
- return array_unique($this->_modifiedAttributes);
+ return array_unique(
+ array_merge(
+ $this->_modifiedAttributes, array_keys(
+ array_diff_assoc(
+ array_intersect_key($this->getObject()->data, $this->getMetaData()->getAttributes(true)),
+ $this->getAttributes()
+ )
+ )
+ )
+ );
}
/**
@@ -263,6 +272,7 @@ public function resetModified($attr = null) {
/**
* @param bool $createIfNull
+ *
* @return Criteria
*/
public function getCriteria($createIfNull = true) {
@@ -275,6 +285,7 @@ public function getCriteria($createIfNull = true) {
/**
* @param Criteria $criteria
+ *
* @return Document
*/
public function setCriteria($criteria) {
@@ -1123,8 +1134,8 @@ protected function saveInternal(array $attributes = null, array &$modelRelations
/**
* Ensure $related is saved, so we have current PK
*/
- if (!in_array($related, $modelRelations, true) && $related->isModified)
- $related->saveInternal(null, $modelRelations, $this);
+ if ($related->getIsNewRecord() || (!in_array($related, $modelRelations, true) && $related->isModified))
+ $related->saveInternal(null, $modelRelations);
$this->appendRelation($related, $name);
}
else
@@ -1186,8 +1197,8 @@ protected function saveInternal(array $attributes = null, array &$modelRelations
continue;
}
- if (!in_array($model, $modelRelations, true) && $model->isModified)
- $model->saveInternal(null, $modelRelations, $this);
+ if ($model->getIsNewRecord() || (!in_array($model, $modelRelations, true) && $model->isModified))
+ $model->saveInternal(null, $modelRelations);
Yii::trace('Saving a relation "' . $name . '" of type ' . get_class($relations[$name]) . ' in ' . get_class($this) . '.saveInternal()', 'ext.activedocument.Document');
$this->appendRelation($model, $name);
@@ -1227,8 +1238,8 @@ protected function saveInternal(array $attributes = null, array &$modelRelations
continue;
}
- if (!in_array($related, $modelRelations, true) && $related->isModified)
- $related->saveInternal(null, $modelRelations, $this);
+ if ($related->getIsNewRecord() || (!in_array($related, $modelRelations, true) && $related->isModified))
+ $related->saveInternal(null, $modelRelations);
Yii::trace('Saving a relation "' . $name . '" of type ' . get_class($relations[$name]) . ' in ' . get_class($this) . '.saveInternal()', 'ext.activedocument.Document');
$this->appendRelation($related, $name);
@@ -1704,11 +1715,11 @@ protected function query(Criteria $criteria, $all = false, array $keys = array()
/**
* @todo This is temporary fix for issue where empty object is returned...
*/
- $objects = array_filter($objects, function(\ext\activedocument\Object $obj){
- return !($obj->data===null || $obj->data===array());
+ $objects = array_filter($objects, function(\ext\activedocument\Object $obj) {
+ return !($obj->data === null || $obj->data === array());
});
- if ($objects===array())
+ if ($objects === array())
return $all ? array() : null;
return $all ? $this->populateDocuments($objects) : $this->populateDocument(array_shift($objects));
View
24 Form.php
@@ -2,12 +2,28 @@
namespace ext\activedocument;
-use \CActiveForm,
- \CHtml;
+use CHtml, Yii;
-class Form extends CActiveForm {
+/**
+ * @todo Make this more dynamic, so that other form classes could be specified for Form to extend from
+ */
+Yii::registerAutoloader(function($class) {
+ if (strcasecmp($class, 'ext\activedocument\FakeInheritForm') === 0) {
+ if (Yii::getPathOfAlias('bootstrap.widgets.BootActiveForm')
+ && Yii::import('bootstrap.widgets.BootActiveForm', true) && class_exists('BootActiveForm')
+ ) {
+ class_alias('BootActiveForm', 'ext\activedocument\FakeInheritForm');
+ } else {
+ class_alias('CActiveForm', 'ext\activedocument\FakeInheritForm');
+ }
+ }
+});
+
+/** @noinspection PhpUndefinedClassInspection */
+/** @noinspection PhpUndefinedNamespaceInspection */
+class Form extends \ext\activedocument\FakeInheritForm {
- public function error($model, $attribute, $htmlOptions=array(), $enableAjaxValidation=true, $enableClientValidation=true) {
+ public function error($model, $attribute, $htmlOptions = array(), $enableAjaxValidation = true, $enableClientValidation = true) {
/**
* Determine input id
*/
View
20 drivers/riak/Adapter.php
@@ -62,8 +62,15 @@ public function getMapReduce($reset = false) {
protected function countInternal(\ext\activedocument\Criteria $criteria) {
$mr = $this->applySearchFilters($criteria);
- $mr->map('function(){return [1];}');
- $mr->reduce('Riak.reduceSum');
+ $mr->reduce('function(values){
+ if (values.length > 0) {
+ return [values.length];
+ }
+ else {
+ return [0];
+ }
+ }', array('arg'=>array('reduce_phase_only_1' => true)));
+
$result = $mr->run();
$result = array_shift($result);
return $result;
@@ -112,8 +119,6 @@ public function getObjectsData($data) {
protected function findInternal(\ext\activedocument\Criteria $criteria) {
$mr = $this->applySearchFilters($criteria);
- $mr->map('function(value){return [value];}');
-
/**
* Apply default sorting
*/
@@ -307,6 +312,13 @@ function(value){
}
}
+ $mr->map('function(value){
+ if(!value.not_found && !value.values[0].metadata["X-Riak-Deleted"]) {
+ return [value];
+ }
+ return [];
+ }');
+
return $mr;
}

No commit comments for this range

Something went wrong with that request. Please try again.