From 1f1f32a77ef52e0138c9b0aba8dbed787f3ac348 Mon Sep 17 00:00:00 2001 From: sunhao Date: Mon, 24 Feb 2025 15:56:58 +0800 Subject: [PATCH] * [refac] fix doc->update not work in extensions. --- module/doc/control.php | 2 +- module/doc/model.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/module/doc/control.php b/module/doc/control.php index 75ddd6953c..dc5c3ea19c 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -640,7 +640,7 @@ class doc extends control ->removeIF($this->post->product === false, 'product') ->removeIF($this->post->execution === false, 'execution') ->get(); - $result = $this->doc->update($docID, $docData, $doc); + $result = $this->doc->update($docID, $docData); if(dao::isError()) { if(!empty(dao::$errors['lib']) || !empty(dao::$errors['keywords'])) return $this->send(array('result' => 'fail', 'message' => dao::getError(), 'callback' => "zui.Modal.open({id: 'modalBasicInfo'});")); diff --git a/module/doc/model.php b/module/doc/model.php index 9e1bc727ce..e8e75b3caa 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -1589,11 +1589,10 @@ class docModel extends model * * @param int $docID * @param object $doc - * @param object $oldDoc * @access public * @return array|string|bool */ - public function update(int $docID, object $doc, ?object $oldDoc = null): array|string|bool + public function update(int $docID, object $doc): array|string|bool { /* 检查必填项。 Check required fields. */ $requiredFields = $doc->status == 'draft' ? 'title' : $this->config->doc->edit->requiredFields; @@ -1606,7 +1605,7 @@ class docModel extends model $files = $this->loadModel('file')->saveUpload('doc', $docID); if(dao::isError()) return false; - $oldDoc = $oldDoc ? $oldDoc : $this->getByID($docID); + $oldDoc = $this->getByID($docID); $changes = common::createChanges($oldDoc, $doc); $oldRawContent = isset($oldDoc->rawContent) ? $oldDoc->rawContent : ''; $newRawContent = isset($doc->rawContent) ? $doc->rawContent : '';