迁移MediaWiki后如何更新所有外部链接 [英] How to update all external links after migrating a MediaWiki

查看:284
本文介绍了迁移MediaWiki后如何更新所有外部链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将MediaWiki从一种环境迁移到了另一种环境.一切正常,除了少数用户具有硬编码的外部链接(实际上链接到同一Wiki中的其他页面)的事实.例如,旧的Wiki位于://foo/wiki上,而新的Wiki位于://foo.com上.在迁移的Wiki的页面上,页面文本上有外部链接,例如://foo/wiki/somepage.因此,当他们单击迁移的Wiki上的链接时,它们将被带回到旧的Wiki并被定向到://foo/wiki/somepage -这不是正确的行为(应转到://foo.com/somepage).在MySQL的"externallinks"表中,我在单个链接上运行了这两个语句,以查看更改是否会更新该链接:

I have migrated a MediaWiki from one environment to another. Everything works fine, except for the fact that a few users have hard-coded external links (which actually link to other pages within the same wiki). For example, the old wiki was on ://foo/wiki and the new is at ://foo.com. On pages of the migrated wiki there are external links on the page text like ://foo/wiki/somepage. So when they click the link on the migrated wiki they get taken back to the old wiki and are directed to ://foo/wiki/somepage -- which is not the correct behavior (it should go to ://foo.com/somepage). In the "externallinks" table in MySQL I have run the two statements on a single link to see if the change would update the link:

UPDATE `foowiki`.`externallinks`
SET el_to = REPLACE(el_to, '://foo/wiki', '://www.foo.com')
WHERE el_to LIKE '%://foo/wiki/somepage%';

UPDATE `foowiki`.`externallinks`
SET el_index = REPLACE(el_index, '://foo./wiki', '://com.foo.www.')
WHERE el_index LIKE '%://foo./wiki/somepage%';

当我重新启动站点并转到带有我要更新的示例链接的页面时,该链接仍然相同(即,它链接到旧的Wiki环境).

When I restart the site and go to the page with the sample link I'm trying to update, the link is still the same (i.e., it links to the old wiki environment).

是否有一种快速简便的方法来用正确的前缀替换所有外部链接(在文本中)(即从://foo/wiki/somerandompage://foo.com/somerandompage)?也许有一种更干净的方法来执行此操作,而不是更新MySQL表中的所有记录,例如在LocalSettings.php中拦截HTTP请求并在其中执行单个子字符串替换?

Is there a quick and easy way to replace all external links (in the text) with the correct prefix (i.e. go from ://foo/wiki/somerandompage to ://foo.com/somerandompage)? Maybe there is an even cleaner way to do it, instead of updating all the records in a MySQL table, such as intercepting the HTTP requests in LocalSettings.php and doing a single substring replace there?

推荐答案

而不是尝试更改数据库(布局替换文字.它是稳定的,经过良好测试的,并且仅用于此类情况.

Rather than trying to alter the database (the layout is quite complex), I would try the extension Replace_Text. It is stable, well tested, and made just for situations like these.

顺便说一句,您在协议相对URL前面加了一个冒号.您可能是想写//www.foo.com.

BTW, you have a colon prepending you protocol relative URLs. You probably mean to write //www.foo.com.

如果您仍然想破解数据库,我相信它是您要查看的archivetext表.在这里完成工作后,您将必须重建基于以下内容的外部链接表那个.

If you still want to hack the DB, I believe it is the archive and text tables you want to look at. After doing your work there, you will have to rebuild the external links table based on that.

这篇关于迁移MediaWiki后如何更新所有外部链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆