手册:RefreshLinks.php

From mediawiki.org
This page is a translated version of the page Manual:RefreshLinks.php and the translation is 87% complete.

详情

refreshLinks.php文件是用于[重新]填充pagelinks categorylinks imagelinks 表的维护脚本。 如果您发现分类为空或没有显示所有相关页面,“链入页面”功能异常,或有其他与链接相关的问题,您应该运行它。 此外,此脚本还从下表中清除指向不存在的页面的链接: pagelinks, categorylinks, imagelinks, templatelinks , externallinks , iwlinks , langlinks , redirect , page_props

用法

基本

php maintenance/refreshLinks.php [starting_article]

例如,如果希望脚本以id为8,000的页面开始:

php maintenance/refreshLinks.php 8000

高级

php refreshLinks.php [--conf|--dbpass|--dbuser|--dfn-only|--e|--globals|--help|--m|--new-only|--old-redirects-only|--quiet|--redirects-only|--wiki] <start>

参数

选项/参数 描述
--dfn-only 仅从不存在的文章中删除链接
--new-only 仅影响只有一次编辑的文章
--redirects-only 只修复重定向,而不是所有链接
--old-redirects-only 仅修复没有重定向表项的重定向
--e <page_id> 要刷新的最后一个页面ID
--dfn-chunk-size 每个查询要检查的现有ID的最大数量,默认为100,000
--namespace 仅修复此命名空间中的页面。命名空间应为数字ID。
--category 仅修复此类别中的页面
--tracking-category 仅修复此跟踪类别中的页面
--m <max_lag> 最大复制延迟
--wiki 用于指定维基ID
--help 显示帮助文本
<start> 文章编号(Page_Id),起始位置
no parameters 将刷新所有文章

这也支持通用选项

示例输出

me@server:/var/www/htdocs/mw/w/maintenance$ php refreshLinks.php
Refreshing redirects table.
Starting from page_id 1 of 309.
100
200
300
Refreshing links tables.
Starting from page_id 1 of 309.
100         
200
300
Retrieving illegal entries from pagelinks... 0..0
Retrieving illegal entries from imagelinks... 0..0
Retrieving illegal entries from categorylinks... 0..0
Retrieving illegal entries from templatelinks... 0..0
Retrieving illegal entries from externallinks... 0..0
Retrieving illegal entries from iwlinks... 0..0
Retrieving illegal entries from langlinks... 0..0
Retrieving illegal entries from redirect... 0..0
Retrieving illegal entries from page_props... 0..0


避免内存问题

此脚本可能会遇到内存问题。为了避免这种情况,您可能希望将最后一个页面ID设置为刷新。

php refreshLinks.php --e 1500

要执行您输入的下一组page_id

php refreshLinks.php --e 3000 -- 1500

只需继续,直到您的维基中的所有页面ID都被刷新。

如果您忘记将最后一个page_id设置为刷新,并且脚本内存不足,只需使用最后一个输出page_id作为文章的开头重新运行它,例如

php refreshLinks.php -- 1600

Chunking refreshLinks.php to refresh all links without memory leak

Below is an example script to run refreshLinks.php against all pages but without having memory issues.

num_pages=$(php /path/to/mediawiki/maintenance/showSiteStats.php | grep "Total pages" | sed 's/[^0-9]*//g')
end_id=0
delta=2000

echo "Beginning refreshLinks.php script"
echo "  Total pages = $num_pages"
echo "  Doing it in $delta-page chunks to avoid memory leak"

while [ "$end_id" -lt "$num_pages" ]; do
start_id=$(($end_id + 1))
end_id=$(($end_id + $delta))
echo "Running refreshLinks.php from $start_id to $end_id"
php /path/to/mediawiki/maintenance/refreshLinks.php --e "$end_id" -- "$start_id"
done

# Just in case there are more IDs beyond the guess we made with showSiteStats, run 
# one more unbounded refreshLinks.php starting at the last ID previously done
start_id=$(($end_id + 1))
echo "Running final refreshLinks.php in case there are more pages beyond $num_pages"
php /path/to/mediawiki/maintenance/refreshLinks.php "$start_id"