bug fix, username is lost when edit the page

This commit is contained in:
Diego Najar 2018-08-28 19:32:15 +02:00
parent 2c5151c3ab
commit 78726b7c3a
1 changed files with 6 additions and 7 deletions

View File

@ -147,8 +147,11 @@ class Pages extends dbJSON {
public function edit($args, $climode=false) public function edit($args, $climode=false)
{ {
$row = array(); // Old key
// This variable is not belong to the database so is not defined in $row
$key = $args['key'];
$row = array();
// Check values on args or set default values // Check values on args or set default values
foreach ($this->dbFields as $field=>$value) { foreach ($this->dbFields as $field=>$value) {
if ($field=='tags') { if ($field=='tags') {
@ -161,8 +164,8 @@ class Pages extends dbJSON {
// Sanitize if will be stored on database // Sanitize if will be stored on database
$finalValue = Sanitize::html($args[$field]); $finalValue = Sanitize::html($args[$field]);
} else { } else {
// Default value for the field if not defined // Default value from the current
$finalValue = $value; $finalValue = $this->db[$key][$field];
} }
settype($finalValue, gettype($value)); settype($finalValue, gettype($value));
$row[$field] = $finalValue; $row[$field] = $finalValue;
@ -179,10 +182,6 @@ class Pages extends dbJSON {
$parent = $args['parent']; $parent = $args['parent'];
} }
// Old key
// This variable is not belong to the database so is not defined in $row
$key = $args['key'];
// Slug from the title or the content // Slug from the title or the content
// This variable is not belong to the database so is not defined in $row // This variable is not belong to the database so is not defined in $row
if (empty($args['slug'])) { if (empty($args['slug'])) {