我有一个“烘焙”的cakePHP-3.0.0页面,其中有一个字段定义为
date_of_birth date DEFAULT NULL
表users
中的。
当我点击提交add
功能时,我得到了
警告(2):preg_match()期望参数2为字符串,给定数组为[CORE \ src \ Validation \ Validation.php,第763行]
代码上下文
protected static function _check($check, $regex) { if (is_string($regex) && preg_match($regex, $check)) { $check = [ 'year' => '2014', 'month' => '01', 'day' => '01' ] $regex = '%^(?:(?:(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16| [2468][048]|[3579][26])00)))([- /.])(?:0?2\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\d)? \d{2})([- /.])(?:(?:(?:0?[13578]|1[02])\2(?:31))|(?:(?:0?[1,3-9]|1[0-2]) \2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\2(?:0?[1-9]|1\d|2[0-8]))))$%'
有关如何修复的任何建议?
堆栈跟踪是
preg_match - [internal], line ??
Cake\Validation\Validation::_check() - CORE\src\Validation\Validation.php, line 763
Cake\Validation\Validation::date() - CORE\src\Validation\Validation.php, line 346
Cake\Validation\RulesProvider::__call() - CORE\src\Validation\RulesProvider.php, line 53
Cake\Validation\RulesProvider::date() - CORE\src\Validation\ValidationRule.php, line 138
Cake\Validation\ValidationRule::process() - CORE\src\Validation\ValidationRule.php, line 138
Cake\Validation\Validator::_processRules() - CORE\src\Validation\Validator.php, line 554
Cake\Validation\Validator::errors() - CORE\src\Validation\Validator.php, line 128
Cake\ORM\Marshaller::_validate() - CORE\src\ORM\Marshaller.php, line 185
Cake\ORM\Marshaller::merge() - CORE\src\ORM\Marshaller.php, line 341
Cake\ORM\Table::patchEntity() - CORE\src\ORM\Table.php, line 1899
App\Controller\UsersController::add() - APP/Controller\UsersController.php, line 48
Cake\Controller\Controller::invokeAction() - CORE\src\Controller\Controller.php, line 406
Cake\Routing\Dispatcher::_invoke() - CORE\src\Routing\Dispatcher.php, line 114
Cake\Routing\Dispatcher::dispatch() - CORE\src\Routing\Dispatcher.php, line 87
答案 0 :(得分:0)
请阅读答案 https://github.com/cakephp/cakephp/issues/5611#issuecomment-69254634
问题已修复,请使用“composer update”更新您的cakephp版本。
请注意,您必须在编辑器中使用 dev-master
,直到标记了新版本。