本文介绍了如何使Topbar扩展与最新的MediaWiki一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行的MediaWiki网站使用。我最近将安装升级到MediaWiki主分支的最新版本:版本1.28.0-alpha(91e56cc)。

I run a MediaWiki site which uses the Topbar extension. I recently upgraded the installation to the bleeding edge version from MediaWiki's master branch: version 1.28.0-alpha (91e56cc).

之后,Topbar扩展不再有效:

Afterwards, the Topbar extension no longer works:


  • 通常情况下,根本没有插入topbar div。

  • 偶尔会出现topbar div但是链接不起作用。

后一个问题可能是我的CSS问题(我不知道),但间歇性行为问题我。所以第一项业务是确保每次都至少出现topbar div。

The latter issue may be a problem with my CSS (I do not know), but the intermittent behavior concerns me. So the first order of business is to make sure the topbar div at least appears every time.

这个扩展只是一个小的javascript,应该在页面加载时运行,在顶部附近添加一大块HTML(< div id =mw-writh-topbar...> )。它确实。

This extension is just a small javascript that is supposed to run when the page loads, to add a chunk of HTML near the top (<div id="mw-writh-topbar" ...>). It does so using a jQuery function.

不幸的是,我不是一个真正的网络开发人员,所以即使这个简单的例程也有点过头了。

Unfortunately, I am not really a web developer, so even this simple routine is a bit over my head.

以下是我所知道的:


  • 没有500个服务器错误,PHP没有明显的问题。

  • 在调查初期的某个时刻,开发人员控制台有时会抱怨未捕获的ReferenceError:jQuery未定义,但我现在无法重现它。研究可能是因为扩展程序没有使用新的ResourceLoader机制,所以我试图(通过 maintenance / convertExtensionToRegistration.php ,然后在 LocalSettings.php wfLoadExtension('Topbar')但它没有似乎有所不同。

  • 似乎调用了Topbar挂钩,因为 css / Topbar.css 被添加到页面中。但是我不知道 js / Topbar.js 是否曾经运行过,如果是的话,会发生什么。

  • There are no 500 server errors, no overt problem with the PHP.
  • At some point early in my investigation, the developer console sometimes complained about Uncaught ReferenceError: jQuery is not defined, but I cannot reproduce it anymore now. Research vaguely suggested it could be because the extension does not use the new ResourceLoader mechanism, so I tried to migrate Topbar to use the ResourceLoader mechanism (via maintenance/convertExtensionToRegistration.php, and then wfLoadExtension('Topbar') in LocalSettings.php) but it did not seem to make any difference.
  • The Topbar hooks seem to be called, because css/Topbar.css gets added to the page. But I have no clue whether js/Topbar.js ever runs, and if so, what happens.

那么:我该怎么调试呢?

So: how can I debug this?

推荐答案

你需要转换代码才能使用ResourceLoader - 目前,该扩展使用OutputPage的addScriptFile()添加代码,并假设jQuery在运行时可用。从MediaWiki 1.26开始,所有内容都异步加载,因此不起作用,因此需要将其转换为新系统。

You need to convert the code to use ResourceLoader - currently the extension adds the code using OutputPage's addScriptFile(), and just assumes jQuery will be available by the time it runs. Starting with MediaWiki 1.26, everything loads asynchronously, so this doesn't work, and thus the need to convert it to the new system.

这样做的说明如下:




  • https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_for_extension_developers
  • https://www.mediawiki.org/wiki/ResourceLoader/Developing_with_ResourceLoader#Registering

两个音符:


  1. 从MediaWiki 1.25开始,扩展应该使用所谓的而不是遵循上述手册,但这可能需要更多的工作和专业知识。

  2. û gly hack警告:你可以忽略所有这些,只需使用 RLQ.push(函数(){/ *这里的所有代码* /})将代码包装在JS文件中; 。这将它全部推送到ResourceLoader的队列中,因此它将在jQuery 可用之后加载。我不推荐这个,但为了完整起见,请在此处显示。

  1. Since MediaWiki 1.25, extensions are supposed to use the so-called "extension registration" instead of following the above manuals, but this might require more work and expertise.
  2. Ugly hack warning: you can ignore all of this, and simply wrap the code in the JS file using RLQ.push( function(){ /* All of the code here */ } );. This shoves it all into the ResourceLoader's queue, so it will load after jQuery is available. I do not recommend this, but show it here for completeness' sake.

这篇关于如何使Topbar扩展与最新的MediaWiki一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 00:34