Good to have:
- git cli
Required:
- apache2
- make
- mysql
On Ubuntu 18.04:
apt-get install mysql-server
apt-get install make
apt-get install apache2
-
Run setup-site.sh to set up the site after doing an initial checkout
-
Modify MediaWiki:Common.js so that it executes after things are loaded.
- Surround everything with
mw.loader.using( ['mediawiki.user'] ).done( function() { … // everything in MediaWiki:Common.js right now } );
- Change
addOnloadHook()
to$(document.ready(…))
. See Legacy removals for more information. For example, change
addOnloadHook(CustomizeModificationsOfSidebar);
to
$(document.ready( function() { CustomizeModificationsOfSidebar(); } );
- Instances of
wikipathways.username
should be replaced with a "proper" mwjs fetching of the user name. You can usemw.config.get("wgUserName")
.
tbd
tbd
For simple git actions across all submodules, the wpgit.sh
provides some handy commands, for example:
./wpgit.sh status #perform git status on all repos
tbd
Since I like to have a concrete target when I write, I'll document how I'm solving a problem that Egon found. This will demonstrate how I examine the code and give some idea of how to use the git submodules.
-
Once the page in the bug loads I confirm that clicking any author's name brings up their user page. Clicking “et al.” does not appear to work.
-
Checking the Javascript console, I see the following message:
ReferenceError: AuthorInfo is not defined
-
Mousing over “et al.” I see:
javascript:AuthorInfo.showAllAuthors()
-
Using
git submodule foreach
to invokegit grep
, we can search all the repositories in under a second. When we do, we find it:$ git submodule foreach 'git grep showAllAuthors || :' Entering 'extensions/BiblioPlus' Entering 'extensions/Cite' Entering 'extensions/CodeEditor' Entering 'extensions/ConfirmEdit' Entering 'extensions/ContributionScores' Entering 'extensions/EmbedVideo' Entering 'extensions/GPML' modules/AuthorInfo.js: html += ", <a href='javascript:AuthorInfo.showAllAuthors()' " + modules/AuthorInfo.js:AuthorInfo.showAllAuthors = function() { Entering 'extensions/GPMLConverter'
-
From here, we can see that the GPML extension should be loading
modules/AuthorInfo.js
in order to provide the function. It appears that this is missing.Also, since we know it is in the GPML extension's repository, we can narrow our work to that repository. Using
git grep
again, we check to make sure that the file is in the list of files available to ResourceLoader:$ cd extensions/GPML $ git grep -n AuthorInfo.js extension.json:64: "AuthorInfo.js"
-
To find the module for the AuthorInfo.js file, we examine the file
extension.json
in the GPML extension. From here, we can see that if ResourceLoader is told to load the wpi.AuthorInfo module, then it will send the AuthorInfo.js file:$ jq -c '.ResourceModules | to_entries[] | \ select( .value.scripts | index("AuthorInfo.js") )| \ .key' extensions/GPML/extension.json "wpi.AuthorInfo"
-
Using git grep only on the
GPML
extension, we find that thewpi.AuthorInfo
module is called just before we return fromWikiPathways\GPML\AuthorInfoList::render()
:$ cd extensions/GPML $ git grep -n wpi.AuthorInfo extension.json:62: "wpi.AuthorInfo": { src/AuthorInfoList.php:182: $parser->getOutput()->addModules( "wpi.AuthorInfo" ); src/Content.php:249: [ "wpi.AuthorInfo", "wpi.Pathway", "wpi.toggleButton", "wpi.PageEditor" ]
-
MediaWiki is told in
WikiPathways\GPML\Hook::onParserFirstCallInit()
to callWikiPathways\GPML\AuthorInfoList::render()
when it comes across the<AuthorInfo>
tag in wikitext:$ git grep -n B 2 AuthorInfoList::render src/Hook.php-54- public static function onParserFirstCallInit( Parser &$parser ) { src/Hook.php-55- $parser->setHook( src/Hook.php:56: "AuthorInfo", "WikiPathways\\GPML\\AuthorInfoList::render"
-
We can't find the
<AuthorInfo>
tag anywhere in GPML, so let's look in the other extensions:$ pwd …/new.wikipathways.org/extensions/GPML $ git grep ‘<AuthorInfo' $ cd .. $ git submodule foreach -q 'git grep "<AuthorInfo" || :' $
-
Since it isn't invoked anywhere (
<AuthorInfo>
is kept for backwards compatibility just in case anyone used it in wikitext somewhere), let's look at the other match back in step 7. There we saw that thewpi.AuthorInfo
module is also included inWikiPathways\GPML\Content::fillParserOutput()
but is this ever called?Let's do a brute force check:
$ curl https://vm1.wikipathways.org/Pathway:WP528?debug=true | grep wpi.AuthorInfo <script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.load(["wpi.PathwayLoader.js","wpi.openInPathVisio","wpi.Dropdown","wpi.CurationTags","wpi.AuthorInfo","wpi.XrefPanel","wpi.Pathway","wpi.toggleButton","wpi.PageEditor","mediawiki.action.view.postEdit","site","mediawiki.page.startup","mediawiki.user","mediawiki.hidpi","mediawiki.page.ready","jquery.tablesorter","mediawiki.searchSuggest","ext.biblioPlus.qtip.config","skins.vector.js"]);});</script>
(Note the use of
?debug=true
to keep MediaWiki from minimizing the output and allowing us to read it.)This shows us that it is at least referenced in the output.
-
Adding
?debug=true
to the url we want to check (like this) and then loading it in the browser forces each javascript file to be loaded seperately. When we do this, it looks clicking “et al.” works without a problem. -
We visit the page again without
?debug=true
and purge the cache. The problem re-appearsAt this point, we conclude that we found a bug in MediaWiki's handling of javascript files.
-
(2 days later) After having a chance to sleep on it, we remember that ResourceLoader is minifying the javascript and, in the process changing the global name
AuthorInfo
. Since we want to keep the old behavior (and we aren't JS natives), we consult the documentation for developers migrating to ResourceLoader, especially the bit on global scope and discover that we can fix this by looking forAuthorInfo
in our js file and replace it withdocument.AuthorInfo
.