Thanks Brian, this is all good stuff.

To avoid text overload, I, too have responded inline where I have more comments 
and questions.

> 
>> 2.  We currently make several database calls using the the select method of
>> the Database Object.  After some research, we realized that Mediawiki
>> provides some functions that do what we need without making these database
>> calls directly.  One of these needs is to acquire the oldid and timestamp of
>> the first revision of a page, which can be done using
>> Title->getFirstRevision()->getId() and
>> Title->getFirstRevision()->getTimestamp() methods.  Is there a way to get
>> the latest ID and latest timestamp?  I see I can do Title->getLatestRevID()
>> to get the latest revision ID; what is the best way to get the latest
>> timestamp?
> 
> Use existing wrapper functions around DB calls where you can, but if
> you need to its ok to query the db directly.
> 
> For the last part, probably something along the lines of
> WikiPage::factory( $titleObj )->getRevision()->getTimestamp()

That enormous sound you heard was my palm hitting my forehead.  Thanks for 
pointing that one out for me.

We'll be replacing our getFirstMemento and getLastMemento functions soon now 
that we have Mediawiki-esque solutions for them.

There are other instances in which we access the database:
* <= given Timestamp (this is what gets the old revision of the page)
* Time Map data (fetch the id and timestamp of the last 500 revisions)

I doubt there is something built into Mediawiki that already provides that 
capability.  If there is, please advise.  :)

> 
>> 3.  In order to create the correct headers for use with the Memento
>> protocol, we have to generate URIs.  To accomplish this, we use the
>> $wgServer global variable (through a layer of abstraction); how do we
>> correctly handle situations if it isn't set by the installation?  Is there
>> an alternative?  Is there a better way to construct URIs?
> 
> $wgServer is always filled out (Setup.php sets it if user doesn't).
> However you probably shouldn't be using it directly. What the most
> appropriate method to use depends on what sort of urls you want, but
> generally the Title class has methods like getFullURL for this sort of
> thing.

That makes me feel a little bit better about our dependencies.

Since our rewrite, we only use $wgServer (via abstraction) in two places now, 
and they both involve the TimeMap SpecialPage.

We actually have 3 different types of TimeMaps in the Memento Mediawiki 
Extension:
1. full (starter) - shows the latest 500 revisions
2. pivot descending - shows the last 500 (or less) revisions prior to a given 
timestamp pivot
3. pivot ascending - shows the next 500 (or less) revisions after a given 
timestamp pivot

The pivot ascending and pivot descending TimeMaps are what use the $wgServer 
URI.

They take the form of 
http://example.com/index.php/Special:TimeMap/20130720011113/1/Article for 
ascending and 
http://example.com/index.php/Special:TimeMap/20130720011113/-1/Page for 
descending.

The $wgServer variable is used (as $this->mwbaseurl) to construct the URIs like 
so:

        $timeMapPage['uri'] = $this->mwbaseurl . '/'
                        . SpecialPage::getTitleFor('TimeMap') . '/'
                        . $pivotTimestamp . '/-1/' . $title;

A similar statement exists for a pivot ascending TimeMap elsewhere in the code.

I've been trying to find a way to eliminate the use of $wgServer altogether, 
but need to construct these URIs for headers, TimeMap entries, etc.

Is there a better way?

>> 5.  Is there a way to get previous revisions of embedded content, like
>> images?  I tried using the ImageBeforeProduceHTML hook, but found that
>> setting the $time parameter didn't return a previous revision of an image.
>> Am I doing something wrong?  Is there a better way?
> 
> FlaggedRevisions manages to set old version of an image, so its
> possible. I think you might want to do something with the
> BeforeParserFetchFileAndTitle hook as well. For the time parameter,
> make sure the function you're using has the $time parameter marked as
> pass by reference. Also note: the time parameter is the timestamp that
> the image version was created, it does not denote get whatever image
> would be relavent at the time specified (I believe).

I'll have to experiment with that and get back.

Thanks again,

--Shawn



_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to