リビジョン | b7804ac62807c21d568ec39d04f6ad3b3f03432a (tree) |
---|---|
日時 | 2017-09-13 00:07:19 |
作者 | umorigu <umorigu@gmai...> |
コミッター | umorigu |
BugTrack/2432 Ignore page readable or not on AutoLink processing
Simplify page name search by links_do_search_page() added
@@ -99,15 +99,14 @@ function links_update($page) | ||
99 | 99 | links_add($page, array_diff($rel_new, $rel_old), $rel_auto); |
100 | 100 | links_delete($page, array_diff($rel_old, $rel_new)); |
101 | 101 | |
102 | - global $WikiName, $autolink, $nowikiname, $search_non_list; | |
102 | + global $WikiName, $autolink, $nowikiname; | |
103 | 103 | |
104 | 104 | // $pageが新規作成されたページで、AutoLinkの対象となり得る場合 |
105 | 105 | if ($time && ! $rel_file_exist && $autolink |
106 | 106 | && (preg_match("/^$WikiName$/", $page) ? $nowikiname : strlen($page) >= $autolink)) |
107 | 107 | { |
108 | 108 | // $pageを参照していそうなページを一斉更新する(おい) |
109 | - $search_non_list = 1; | |
110 | - $pages = do_search($page, 'AND', TRUE); | |
109 | + $pages = links_do_search_page($page); | |
111 | 110 | foreach ($pages as $_page) { |
112 | 111 | if ($_page !== $page) |
113 | 112 | links_update($_page); |
@@ -245,3 +244,34 @@ function & links_get_objects($page, $refresh = FALSE) | ||
245 | 244 | $result = $obj->get_objects(join('', preg_grep('/^(?!\/\/|\s)./', get_source($page))), $page); |
246 | 245 | return $result; |
247 | 246 | } |
247 | + | |
248 | +/** | |
249 | + * Search function for AutoLink updating | |
250 | + * | |
251 | + * @param $word page name | |
252 | + * @return list of page name that contains $word | |
253 | + */ | |
254 | +function links_do_search_page($word) | |
255 | +{ | |
256 | + global $whatsnew; | |
257 | + | |
258 | + $keys = get_search_words(preg_split('/\s+/', $word, -1, PREG_SPLIT_NO_EMPTY)); | |
259 | + foreach ($keys as $key=>$value) | |
260 | + $keys[$key] = '/' . $value . '/S'; | |
261 | + $pages = get_existpages(); | |
262 | + $pages = array_flip($pages); | |
263 | + unset($pages[$whatsnew]); | |
264 | + $count = count($pages); | |
265 | + foreach (array_keys($pages) as $page) { | |
266 | + $b_match = FALSE; | |
267 | + // Search for page contents | |
268 | + foreach ($keys as $key) { | |
269 | + $lines = remove_author_lines(get_source($page, TRUE, FALSE)); | |
270 | + $b_match = preg_match($key, join('', $lines)); | |
271 | + if (! $b_match) break; // OR | |
272 | + } | |
273 | + if ($b_match) continue; | |
274 | + unset($pages[$page]); // Miss | |
275 | + } | |
276 | + return array_keys($pages); | |
277 | +} |