PDA

View Full Version : P99 wiki bug


steme08
08-25-2017, 12:21 AM
Has anyone tried using the p99 wiki for butcherblock mountains recently? It is all messed up. https://wiki.project1999.com/Butcherblock_Mountains

loramin
08-25-2017, 01:00 AM
Yeah that happens from time to time. You might try messaging Rhavin; I'm not sure but I think he might be able to fix it.

OR someone could give me wiki admin access and then I could fix it ... just saying ...

Rygar
08-25-2017, 07:36 AM
Yeah that happens from time to time. You might try messaging Rhavin; I'm not sure but I think he might be able to fix it.

OR someone could give me wiki admin access and then I could fix it ... just saying ...

I had messaged Ravihn about this recently, he told me to check out the custom extensions here for the PHP which includes the Dynamic Zone List and he can incorporate any changes. I need to brush up on my PHP before I dive into this, but you seem pretty knowledgeable.

Here's the link (its just the page add utility, never noticed the 'Custom Extensions Source' link before on it):

http://wiki.project1999.com/utils/wikiUtils.php

Lotxi
08-25-2017, 11:05 AM
Grobb page has a similar issue

Gumbo
08-25-2017, 01:43 PM
A few of the zone pages are bugged out like the BB zone page...

loramin
08-25-2017, 02:08 PM
I had messaged Ravihn about this recently, he told me to check out the custom extensions here for the PHP which includes the Dynamic Zone List and he can incorporate any changes. I need to brush up on my PHP before I dive into this, but you seem pretty knowledgeable.

Here's the link (its just the page add utility, never noticed the 'Custom Extensions Source' link before on it):

http://wiki.project1999.com/utils/wikiUtils.php

Sweet! Yeah, I'd seen that page before too, but also never noticed that link.

PHP is like my least favorite language (would have taken Node.js, Python, Java or even Ruby over it), but I have used it in the past, so I'll take a look at the code and see if I can find anything. No promises though since it's a lot harder to debug something when you can't actually test the possible fixes.

loramin
08-25-2017, 03:43 PM
Ok, here's what I have so far.

Let's start with the NPC list part, as I'm pretty sure I understand what's happening in it now (just not why). The way the "dynamic zone list" code works is it asks the database for all NPC "articles" related to the zone:

$catNames = array($zoneName,"NPCs");
$NPCs = DynamicZoneList::getCatIntersection($db,$parser,$c atNames);
Then, it parses them:

$rowVals = DynamicZoneList::parseNPCPage($templateText);

But before it does, it grabs the article's title, and uses that to set the title in the table (ie. it doesn't look in the article's contents to find the title). This explains why all of the NPC names are still working in the list when the rest is broken: the problem is with the article's content but it's DB title still works fine.

Now "parseNPCPage" in turn uses another function, which is used to parse both items and NPCs:

$parms = DynamicZoneList::parseTemplateParameters($template Text);

When I look at that function ... well it's a bit low-level but I'm pretty sure it's trying to split all the lines in the NPC article that look like:

| name = a decaying dwarf skeleton
| race = Skeleton New
| class = [[Warrior]]

into separate array items ("parameters"). Then "parseNPCPage" iterates through those parameters, and here's where things get interesting. Inside that loop it tries to extract the parameters that get used in the dynamic list (name, race, class, etc.). Here's the part where it extracts the class:

if ( strpos($parm,"class") === 0) {
$ePos = strpos($parm,"=");
$class = trim(substr($parm,$ePos+1));
}

So in other words, when it finds a line like:
| class = [[Warrior]]

it's supposed to use the part after the "=" (ie. "[[Warrior]]").

But it's not doing that. If you look at the Butcherblock page it has:

NPC Name Race Class ...
A Decaying Dwarf Skeleton "zoneTopTable" ! Level of Monsters:

As I said before the name is coming from the DB, so that makes sense, but it couldn't find a Race, and when it tried to find the class it found ""zoneTopTable" ! Level of Monsters:". Now "zoneTopTable" doesn't even exist in the code, so where is that coming from?

Let's look at the top of a zone (not NPC) page:

{|
|rowspan="6" valign="top" width="160"| <div style='float:left;'>__TOC__</div>
|valign="top"|
{| class="zoneTopTable"
! ''' Level of Monsters: '''

Doesn't that last part look familiar?

So here's my theory on what's going wrong: the code is trying to grab the NPC pages and parse their content so it can use them in the zone page's dynamic zone list ... but something is going wrong and it's grabbing the zone page (can't tell which zone page it's grabbing, but I'd guess it's the same page the dynamic list is on). When it goes to parse that zone page it doesn't find the (NPC) bits its looking for, but it does find one bit that looks the same as NPC bit ... only it's not the NPC's class, it's the class of the table of the zone page.

I need a break for now (all this PHP is draining ;)). But, if anyone can figure out why the extension is grabbing the wrong pages (I would guess the issue is somewhere in "getCatIntersection"?) I think we can come up with a fix ... and if no one else does I'll try and figure it out later.

Baler
08-25-2017, 03:55 PM
You rock Loramin! Glad to finally see something proactive being done about that problem that has blighted the wiki for too long.

http://i.imgur.com/aHkiEUo.gif

loramin
08-26-2017, 03:26 PM
TLDR
I need help to fix this. Just give me one of the following:

1) have someone with access log the variables I mention below, then visit the BB page, then send me the log output
2) give me admin access so I can add those lines and see the output myself
3) give me a DB dump of the wiki (it doesn't have to be a recent one, as long as it has this issue) and I can debug locally

Wall of Text
Good news/bad news time. The good news is that my theory seems to be correct. If you look at Grobb (also broken) you will see that it has a slightly different text for its NPCs' class:

"zoneTopTable" ! width="150"

and if you look at Grobb's code (at the top of the page) you'll see ...

{| class="zoneTopTable"
! width="150"

So it seems pretty clear that the NPCs at least (and probably the quests/items) are being pulled from the zone page, instead of from their actual pages.

The bad news is, I can't figure out why it's happening. The problem is definitely with the related pages (the quest/zones/items), because if you change a broken page to use the dynamic list of a working page (ie. change BB's page to use Erudin's list) it works just fine, but if you rename the page and don't change the list it remains broken. The list of broken pages I've found so far is:

Ak'Anon, Burning Wood, Butcherblock Mountains, Crushbone, Eastern Plains of Karana, Frontier Mountains, Grobb

but I don't see any connection between them. There are other (working) zones with apostrophes and spaces in their name, so it's not the zone name. There could be a single quest/item/npc with some bad wiki code that is causing the problem, but I don't see any mobs that share all (or even most) of those zones.

What would REALLY help is if I could get some debugging info. If I could get access, or if someone with access could add some code for me, what I'd really like to see is all of the values (both the query and the response) from this line in "getCatIntersection" when someone hits the Butcherblock page:

$res = $db->select( $aTables, $aFields, $aWhere, __METHOD__, $aOptions, $aJoin );

In particular I'd like to see "$aJoin", which should be the JOIN clauses of the SELECT, and should be something like:


INNER JOIN page_id = c{0}.cl_from AND c{0}.cl_to='Butcherblock_Mountains'
INNER JOIN page_id = c{1}.cl_from AND c{1}.cl_to='NPCs'


and then the results ("$res") of that SELECT, which should be:


page_namespace, page_title
'', 'A Decaying Dwarf Skeleton'
...


but I'm guessing it might actually be '', 'Butcherblock Mountains', and if that's the case the query variables should explain how we got it.

Now the actual fetching of the related pages happens elsewhere, in the assorted parse* methods, but they just fetch whatever title is given to them, and since that title comes from the above SELECT I strongly suspect the issue is happening in that SELECT, not when the code tries to lookup "a decaying skeleton" (or whatnot).

Why Trust a Random Forum Poster With Admin Access?

A) I <3 the wiki and have created several important pages on it: the (GM-requested) installation guide, the various hunting guides, etc. I would never do anything to break or harm it

B) I'm a web developer with 10+ years of experience. I've written a book on it (well, on a Javascript library, same diff), led multiple teams, chaired an industry technology group, etc. I may not be a PHP expert, but this won't be my first rodeo and I won't do anything stupid.

Alternatively if I could just get a DB dump, instead of getting access, I could setup a local media wiki installation (with the dynamic table stuff) and debug without touching the live wiki at all. The only reason I haven't done that yet is that I think that the problem is in the data, and it's not realistic for me to manually copy (page by page) all of the pages in the Butcherblock category.

Rygar
08-26-2017, 04:43 PM
You definitely would have my vote for an admin, you have proven yourself very worthy. I recommend sending Ravihn a PM here do he gets an email notification, he got back to me quick last time. Mention you think you have a fix for the dynamic zone list or something, and link this thread.

I haven't had any time to investigate your fixes, but I'm curious to see if there is a difference between the syntax of the zone pages, such as someone maybe adding a new line or something, same with first mob on each of those dynamic list pages. My plan was to try and see if I can break a list to figure out the problem, but I believe the list only refreshes weekly. Sometimes I have noticed people list the 'zone' field as {{:Kaladim}} which pulls the entire zone page into the npc page, so I fix to [[Kaladim]].

Recently Ravihn fixed the runnyeye dynamic list for me, he could offer you some technical insight as to what was causing the problem.

loramin
08-26-2017, 04:54 PM
I recommend sending Ravihn a PM

Good call.

My plan was to try and see if I can break a list to figure out the problem, but I believe the list only refreshes weekly.

Yeah, the caching is yet another factor that makes this whole thing difficult to debug. But I think the rest of what you said lines up with what I'm seeing (I even fixed a {{:something}} that shouldn't have been there, but it didn't help).

Ravhin
08-26-2017, 06:57 PM
Hi,

Thanks for the investigations - I looked again at this, but it seems still a mystery, i.e. not reproducible behavior. Some failure of the wiki I don't understand.

Anyways, I fixed it in the most hacky way possible, in keeping with the spirit of things!


if( time() - $cacheTime < $fCreated ) { // show file from cache if still valid
$output = file_get_contents($cacheFileName);

// check for corrupt cache, if so, discard and remake now
if (strpos($output, '"zoneTopTable"') === false)
{
$wgOut->addHTML( $output );
return;
}
}


If anyone can now see a page which is still broken, let me know.

Swish
08-26-2017, 07:30 PM
Lor-admin <3

loramin
08-26-2017, 07:35 PM
Hi,

Thanks for the investigations - I looked again at this, but it seems still a mystery, i.e. not reproducible behavior. Some failure of the wiki I don't understand.

Anyways, I fixed it in the most hacky way possible, in keeping with the spirit of things!


if( time() - $cacheTime < $fCreated ) { // show file from cache if still valid
$output = file_get_contents($cacheFileName);

// check for corrupt cache, if so, discard and remake now
if (strpos($output, '"zoneTopTable"') === false)
{
$wgOut->addHTML( $output );
return;
}
}


If anyone can now see a page which is still broken, let me know.

Woot! All hail Ravhin, master of the wiki and the accursed language known as PHP!

Seriously though, thanks a ton for taking the time to fix that: I'm sure I'm not the only who will really appreciate having those tables back.

However, I'm not giving up my quixotic quest for wiki admin access. Or even just ... let me send you a SQL file. With just a one-time batch of UPDATES I could add fashion categories to every (visible) item in the wiki. I have the entire (Lucy-powered) script written and working, I just don't have a way for it to input the results ... but if I did I could let people find items that have a particular look (ie. FashionQuest), which is impossible currently.

Or even if I could just somehow get access to edit a single Javascript file that's exposed on the wiki, I could add class-based filtering to the hunting guides, weighted and multiple stat-based sorting to item lists (eg. "show me helms with the most Str, HP, and Mana, but Mana is only half as important"), or make similar UI-only improvements.

I guess what I'm saying is, the wiki is awesome, but it could be even more awesome: put me in coach!

loramin
08-26-2017, 07:35 PM
Lor-admin <3

:D

Ravhin
08-27-2017, 04:32 AM
Hi Loramin you're already an admin, and for some time now :) Please feel free to make any JS type changes, reading:

* https://www.mediawiki.org/wiki/Manual:Interface/JavaScript
* https://www.mediawiki.org/wiki/Adding_HTML_to_wiki_pages

For bulk updates/edits the best possibility is:

* https://www.mediawiki.org/wiki/API:Main_page

See "wikiDoBulkEdit()" in "Scraper Source" for a working client and examples. Direct DB modifications are not a good idea in Mediawiki, too complex and easy to corrupt.

loramin
08-27-2017, 11:37 AM
Hi Loramin you're already an admin, and for some time now :) Please feel free to make any JS type changes, reading:

* https://www.mediawiki.org/wiki/Manual:Interface/JavaScript
* https://www.mediawiki.org/wiki/Adding_HTML_to_wiki_pages

For bulk updates/edits the best possibility is:

* https://www.mediawiki.org/wiki/API:Main_page

See "wikiDoBulkEdit()" in "Scraper Source" for a working client and examples. Direct DB modifications are not a good idea in Mediawiki, too complex and easy to corrupt.

Someone needs to tell me these things! ;)

https://i.imgur.com/SfHxegs.gif

https://i.imgur.com/meSX5o8.gif

https://i.imgur.com/DTTSLQQ.gif

https://i.imgur.com/ECUYThR.gif

Thank you! Big things inc ...

Lhancelot
08-27-2017, 11:48 AM
Thank you! Big things inc ...

Cool, I love the fashionquest things, so hopefully you are able to add to that area on wiki. :)

gwideon
08-28-2017, 03:59 PM
Gnomish Greetings!

Was edit ability removed from the masses? It says I am not authorized to update a mob description (and yes I am logged in).

Baler
08-28-2017, 04:28 PM
Grats Loramin, I may pm you as I come across issues on the wiki. Just a heads up.
ps. Your 'sandbox' project is pretty cool looking. Any plans to take that further?

Rygar
08-28-2017, 04:31 PM
Gnomish Greetings!

Was edit ability removed from the masses? It says I am not authorized to update a mob description (and yes I am logged in).

You need to hit the edit button at the top of the page, not the individual section! Confuses a lot of folks.

loramin
08-31-2017, 09:59 PM
Grats Loramin, I may pm you as I come across issues on the wiki. Just a heads up.
ps. Your 'sandbox' project is pretty cool looking. Any plans to take that further?

Totally, ask away. Of course, since it's a wiki you should always feel free to use your best judgement and make any change yourself, but I know that sometimes the scripts and such make that difficult.

As for this (http://wiki.project1999.com/User_talk:Loramin/sandbox), I kind of forgot about it, but it's so close to done that I should finish it. I'll add it to my mental to do list.

In retrospect I should have just started with this map, which has zone-connection lines drawn:
http://wiki.project1999.com/images/Map_antonica_zone_connection.jpg

but I didn't know about it at the time, and now I'm too lazy to redo all the coordinates of the links.

loramin
09-03-2017, 06:18 PM
As for this (http://wiki.project1999.com/User_talk:Loramin/sandbox), I kind of forgot about it, but it's so close to done that I should finish it. I'll add it to my mental to do list.

I finished it and added it here:

http://wiki.project1999.com/Zone_connection_map#Antonica_Clickable_Zone_Map

Someday I may add maps of the other continents, but for now I have bigger (fashion) fish to fry, so if anyone else would like to try adding the other continents I strongly encourage it. To make new maps all you have to do is copy the code for my existing one, and then just play around with changing the name, x/y coordinates (ie. "top" and "left") and width/height of the zones. For instance here's the code for Halas:

<span style="
background-color: white;
opacity:0.8;
width: 70px;
height: 15px;
line-height: 15px;
border: 1px dashed black;
position: absolute;
padding: 5px;
left: 180px;
top: 70px;
">[[Halas]]</span>

But by changing the bolded parts you can resize it, move it around, and change it to some other zone.

To change the map image itself, simple change the bold part in:

<div style="border: 1px solid black; padding: 20px; position:relative; height: 740px; width: 620px; text-align:center;">
[[file: Map_rav_antonica.jpg | 600px ]]
to any other map image on the wiki.