Skip to content
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

Merged
merged 5 commits into from
Jan 5, 2024
Merged

Optimize applySlug #1684

merged 5 commits into from
Jan 5, 2024

Conversation

sy-records
Copy link
Member

fix #263

{
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('_-') . "]+$/";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不需要preg_quote

@@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的用意需要解释

Copy link
Member Author

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

@joyqi
Copy link
Member

joyqi commented Jan 5, 2024

我提交了一些更严谨的判断

@joyqi joyqi merged commit 9635a7a into master Jan 5, 2024
5 checks passed
@joyqi joyqi deleted the optimize/slug branch January 5, 2024 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

标题默认生成的slug有问题
2 participants