-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize applySlug #1684
Optimize applySlug #1684
Conversation
var/Widget/Base/Contents.php
Outdated
{ | ||
if ($cid instanceof Query) { | ||
$cid = $this->db->fetchObject($cid->select('cid') | ||
->from('table.contents')->limit(1))->cid; | ||
} | ||
|
||
if ($slug === null && $title !== '') { | ||
$title = str_replace(' ', '-', trim($title)); | ||
$pattern = "/^[\w" . preg_quote('_-') . "]+$/"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不需要preg_quote
var/Widget/Contents/EditTrait.php
Outdated
@@ -577,7 +577,7 @@ protected function publish(array $contents, bool $hasMetas = true) | |||
$realId = 0; | |||
|
|||
/** 是否是从草稿状态发布 */ | |||
$isDraftToPublish = preg_match("/_draft$/", $this->type); | |||
$isDraftToPublish = !empty($this->type) ? preg_match("/_draft$/", $this->type) : false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的用意需要解释
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新发布文章的时候有个错误preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /var/Widget/Contents/EditTrait.php on line 580
我提交了一些更严谨的判断 |
fix #263