Fix notices in upgrade functions, chines tokenizer, and summarizer, a=chris
Fix notices in upgrade functions, chines tokenizer, and summarizer, a=chris
diff --git a/src/library/UpgradeFunctions.php b/src/library/UpgradeFunctions.php
index 9e8b62980..cfbbbec0b 100644
--- a/src/library/UpgradeFunctions.php
+++ b/src/library/UpgradeFunctions.php
@@ -107,9 +107,10 @@ function upgradePublicHelpWiki(&$db)
foreach ($locale_pages as $page_name => $page_content) {
$page_info = $group_model->getPageInfoByName(C\PUBLIC_GROUP_ID,
$page_name, $locale_tag, "edit");
- if ($page_content != $page_info['PAGE'] &&
- (in_array($page_info['EDIT_COMMENT'], ['upgrade', 'create']) ||
- !empty($page_info['PUBDATE']) &&
+ if (empty($page_info) ||
+ ($page_content != $page_info['PAGE'] &&
+ (in_array($page_info['EDIT_COMMENT'], ['upgrade', 'create'])))||
+ (!empty($page_info['PUBDATE']) &&
$page_info['PUBDATE'] < 1555802108) ) {
$group_model->setPageName(C\ROOT_ID, C\PUBLIC_GROUP_ID,
$page_name, $page_content, $locale_tag, "upgrade",
diff --git a/src/library/summarizers/Summarizer.php b/src/library/summarizers/Summarizer.php
index 032c23b2b..4d40cb758 100644
--- a/src/library/summarizers/Summarizer.php
+++ b/src/library/summarizers/Summarizer.php
@@ -202,9 +202,11 @@ class Summarizer
*/
public static function removePunctuation($sentences)
{
- foreach ($sentences as $key => $sentence) {
- $sentences[$key] = trim(preg_replace('/[' . C\PUNCT . ']+/iu', ' ',
- $sentence));
+ if (is_array($sentences)) {
+ foreach ($sentences as $key => $sentence) {
+ $sentences[$key] = trim(preg_replace('/[' . C\PUNCT . ']+/iu',
+ ' ', $sentence));
+ }
}
return $sentences;
}
diff --git a/src/locale/zh_CN/resources/Tokenizer.php b/src/locale/zh_CN/resources/Tokenizer.php
index 0daf63e11..aade93e7f 100755
--- a/src/locale/zh_CN/resources/Tokenizer.php
+++ b/src/locale/zh_CN/resources/Tokenizer.php
@@ -404,7 +404,11 @@ class Tokenizer
self::$traditional_simplified_map =
unserialize(gzdecode(file_get_contents($path)));
}
- $chars = preg_split('//u', $text, null, PREG_SPLIT_NO_EMPTY);
+ if (is_string($text)) {
+ $chars = preg_split('//u', $text, null, PREG_SPLIT_NO_EMPTY);
+ } else {
+ return $text;
+ }
$num_chars = count($chars);
for($i = 0; $i < $num_chars; $i++) {
if (isset(self::$traditional_simplified_map[$chars[$i]])) {