Skip to content
This repository has been archived by the owner on Nov 12, 2017. It is now read-only.

random fixes #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions core/MY_Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ public function update_many($primary_values, $data, $skip_validation = FALSE)
$result = $this->{$this->_interface}
->where_in($this->primary_key, $this->_prep_primary($primary_values))
->set($data)
->update($this->_datasource);
->update_all($this->_datasource);
}

// Run registered callbacks
Expand Down Expand Up @@ -455,7 +455,7 @@ public function update_all($data)
{
$result = $this->{$this->_interface}
->set($data)
->update($this->_datasource);
->update_all($this->_datasource);
}

// Run registered callbacks
Expand Down Expand Up @@ -575,7 +575,7 @@ function dropdown()
public function count_by()
{
$where = func_get_args();
$this->_set_where($where);
// $this->_set_where($where);

return $this->_count($where);
}
Expand Down Expand Up @@ -734,7 +734,7 @@ private function _run_before_callbacks($type, $params = array())
{
foreach ($this->$name as $method)
{
$data = call_user_func_array(array($this, $method), $params);
$data = call_user_func_array(array($this, $method), array($data));
}
}

Expand All @@ -756,7 +756,7 @@ private function _run_after_callbacks($type, $params = array())
{
foreach ($this->$name as $method)
{
$data = call_user_func_array(array($this, $method), $params);
$data = call_user_func_array(array($this, $method), array($data));
}
}

Expand Down Expand Up @@ -855,7 +855,7 @@ private function _count($all = TRUE)
}

$count = $this->_mongodb
? count($this->mongo_db->get($this->_datasource))
? $this->mongo_db->count($this->_datasource)
: $this->db->$method($this->_datasource);

// Restore MongoDB buffered conditions
Expand Down Expand Up @@ -989,11 +989,15 @@ public function _prep_fields(&$fields, $update = FALSE)
foreach ($fields as $key => $value)
{
// Null-byte injection?
if (!isset($this->_fields[$key]))
{
unset($fields[$key]);
$keys = explode('.', $key);
$tmp = $this->_fields;
foreach ($keys as $key) {
if (!array_key_exists($key, $tmp)) {
unset($fields[reset($keys)]);
break;
}
$tmp = $tmp[$key];
}

// SQL-like injection?
// else
// {
Expand Down