diff --git a/thinkphp/convention.php b/thinkphp/convention.php index 6373e5064..6675a57a9 100644 --- a/thinkphp/convention.php +++ b/thinkphp/convention.php @@ -84,7 +84,7 @@ return [ // HTTPS代理标识 'https_agent_name' => '', // IP代理获取标识 - 'http_agent_ip' => 'X-REAL-IP', + 'http_agent_ip' => 'HTTP_X_REAL_IP', // URL伪静态后缀 'url_html_suffix' => 'html', // 域名根,如thinkphp.cn diff --git a/thinkphp/library/think/Model.php b/thinkphp/library/think/Model.php index c0dc9a3de..828894d00 100644 --- a/thinkphp/library/think/Model.php +++ b/thinkphp/library/think/Model.php @@ -354,6 +354,16 @@ abstract class Model implements \JsonSerializable, \ArrayAccess return $this; } + /** + * 判断force + * @access public + * @return bool + */ + public function isForce() + { + return $this->force; + } + /** * 新增数据是否使用Replace * @access public @@ -367,7 +377,18 @@ abstract class Model implements \JsonSerializable, \ArrayAccess } /** - * 新增数据是否使用Replace + * 设置数据是否存在 + * @access public + * @param bool $exists + * @return void + */ + public function exists($exists) + { + $this->exists = $exists; + } + + /** + * 判断数据是否存在数据库 * @access public * @return bool */ diff --git a/thinkphp/library/think/Request.php b/thinkphp/library/think/Request.php index 60d22d763..2be157af4 100644 --- a/thinkphp/library/think/Request.php +++ b/thinkphp/library/think/Request.php @@ -35,7 +35,7 @@ class Request // HTTPS代理标识 'https_agent_name' => '', // IP代理获取标识 - 'http_agent_ip' => 'X-REAL-IP', + 'http_agent_ip' => 'HTTP_X_REAL_IP', // URL伪静态后缀 'url_html_suffix' => 'html', ]; @@ -593,7 +593,6 @@ class Request */ public function setRoot($url = null) { - $this->root = $url; return $this; } @@ -902,7 +901,8 @@ class Request } // 当前请求参数和URL地址中的参数合并 - $this->param = array_merge($this->param, $this->get(false), $vars, $this->route(false)); + $this->param = array_merge($this->param, $this->get(false), $vars, $this->route(false)); + $this->mergeParam = true; } @@ -969,12 +969,7 @@ class Request public function post($name = '', $default = null, $filter = '') { if (empty($this->post)) { - $content = $this->input; - if (empty($_POST) && false !== strpos($this->contentType(), 'application/json')) { - $this->post = (array) json_decode($content, true); - } else { - $this->post = $_POST; - } + $this->post = !empty($_POST) ? $_POST : $this->getJsonInputData($this->input); } return $this->input($this->post, $name, $default, $filter); @@ -991,17 +986,27 @@ class Request public function put($name = '', $default = null, $filter = '') { if (is_null($this->put)) { - $content = $this->input; - if (false !== strpos($this->contentType(), 'application/json')) { - $this->put = (array) json_decode($content, true); + $data = $this->getJsonInputData($this->input); + + if (!empty($data)) { + $this->put = $data; } else { - parse_str($content, $this->put); + parse_str($this->input, $this->put); } } return $this->input($this->put, $name, $default, $filter); } + protected function getJsonInputData($content) + { + if (false !== strpos($this->contentType(), 'application/json')) { + return (array) json_decode($content, true); + } + + return []; + } + /** * 获取DELETE参数 * @access public diff --git a/thinkphp/library/think/model/concern/SoftDelete.php b/thinkphp/library/think/model/concern/SoftDelete.php index 3ffb3d6ba..fa052945a 100644 --- a/thinkphp/library/think/model/concern/SoftDelete.php +++ b/thinkphp/library/think/model/concern/SoftDelete.php @@ -71,18 +71,17 @@ trait SoftDelete /** * 删除当前的记录 * @access public - * @param bool $force 是否强制删除 * @return bool */ - public function delete($force = false) + public function delete() { - if (!$this->exists || false === $this->trigger('before_delete', $this)) { + if (!$this->isExists() || false === $this->trigger('before_delete', $this)) { return false; } $name = $this->getDeleteTimeField(); - if ($name && !$force) { + if ($name && !$this->isForce()) { // 软删除 $this->data($name, $this->autoWriteTimestamp($name)); @@ -104,7 +103,7 @@ trait SoftDelete $this->trigger('after_delete', $this); - $this->exists = false; + $this->exists(false); return true; } @@ -135,7 +134,7 @@ trait SoftDelete if ($resultSet) { foreach ($resultSet as $data) { - $data->delete($force); + $data->force($force)->delete(); } } @@ -146,35 +145,35 @@ trait SoftDelete * 恢复被软删除的记录 * @access public * @param array $where 更新条件 - * @return integer + * @return bool */ public function restore($where = []) { $name = $this->getDeleteTimeField(); - if (empty($where)) { - $pk = $this->getPk(); - - $where[] = [$pk, '=', $this->getData($pk)]; - } - if ($name) { if (false === $this->trigger('before_restore')) { return false; } + if (empty($where)) { + $pk = $this->getPk(); + + $where[] = [$pk, '=', $this->getData($pk)]; + } + // 恢复删除 - $result = $this->db(false) + $this->db(false) ->where($where) ->useSoftDelete($name, $this->getWithTrashedExp()) ->update([$name => $this->defaultSoftDelete]); $this->trigger('after_restore'); - return $result; + return true; } - return 0; + return false; } /** diff --git a/vendor/autoload.php b/vendor/autoload.php index 1f1e0e8c0..897ca41e1 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit85ad62973eba00accc9df3b4f34e6aa5::getLoader(); +return ComposerAutoloaderInitff9f8e2c96d1ee582215ba137a47c4cb::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index df2c1a766..a1c96e155 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit85ad62973eba00accc9df3b4f34e6aa5 +class ComposerAutoloaderInitff9f8e2c96d1ee582215ba137a47c4cb { private static $loader; @@ -19,15 +19,15 @@ class ComposerAutoloaderInit85ad62973eba00accc9df3b4f34e6aa5 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit85ad62973eba00accc9df3b4f34e6aa5', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitff9f8e2c96d1ee582215ba137a47c4cb', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit85ad62973eba00accc9df3b4f34e6aa5', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitff9f8e2c96d1ee582215ba137a47c4cb', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit85ad62973eba00accc9df3b4f34e6aa5::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitff9f8e2c96d1ee582215ba137a47c4cb::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -48,19 +48,19 @@ class ComposerAutoloaderInit85ad62973eba00accc9df3b4f34e6aa5 $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit85ad62973eba00accc9df3b4f34e6aa5::$files; + $includeFiles = Composer\Autoload\ComposerStaticInitff9f8e2c96d1ee582215ba137a47c4cb::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire85ad62973eba00accc9df3b4f34e6aa5($fileIdentifier, $file); + composerRequireff9f8e2c96d1ee582215ba137a47c4cb($fileIdentifier, $file); } return $loader; } } -function composerRequire85ad62973eba00accc9df3b4f34e6aa5($fileIdentifier, $file) +function composerRequireff9f8e2c96d1ee582215ba137a47c4cb($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index f7354d2e0..68f82b148 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit85ad62973eba00accc9df3b4f34e6aa5 +class ComposerStaticInitff9f8e2c96d1ee582215ba137a47c4cb { public static $files = array ( '1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php', @@ -303,9 +303,9 @@ class ComposerStaticInit85ad62973eba00accc9df3b4f34e6aa5 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit85ad62973eba00accc9df3b4f34e6aa5::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit85ad62973eba00accc9df3b4f34e6aa5::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit85ad62973eba00accc9df3b4f34e6aa5::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitff9f8e2c96d1ee582215ba137a47c4cb::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitff9f8e2c96d1ee582215ba137a47c4cb::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitff9f8e2c96d1ee582215ba137a47c4cb::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index bf4ff7d30..27dd97d65 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -196,12 +196,12 @@ "source": { "type": "git", "url": "https://github.com/top-think/framework.git", - "reference": "94c66cfb5b8a570a7624e06c2f98fb087c222ad5" + "reference": "e0a8bdc52957a8f9774353fbfa0b9fd6ee206188" }, "dist": { "type": "zip", - "url": "https://files.phpcomposer.com/files/top-think/framework/94c66cfb5b8a570a7624e06c2f98fb087c222ad5.zip", - "reference": "94c66cfb5b8a570a7624e06c2f98fb087c222ad5", + "url": "https://files.phpcomposer.com/files/top-think/framework/e0a8bdc52957a8f9774353fbfa0b9fd6ee206188.zip", + "reference": "e0a8bdc52957a8f9774353fbfa0b9fd6ee206188", "shasum": "" }, "require": { @@ -217,7 +217,7 @@ "sebastian/phpcpd": "2.*", "squizlabs/php_codesniffer": "2.*" }, - "time": "2018-06-07T07:34:34+00:00", + "time": "2018-06-08T04:10:59+00:00", "type": "think-framework", "installation-source": "dist", "notification-url": "https://packagist.org/downloads/",