Hey,
(You better write such mails to the MW list, which I cc'd now: wikitech-l@lists.wikimedia.org)
There indeed is a better way. MW provides a hook that gets fired on page creation. In this hook you can write the current timestamp to the page props table. Then just obtain that value when you need it. This will be cheaper then doing the query on the revision table.
Very easy to write up, but it might already be provided by some extension. (Which is why I'm cc'ing the MW list.)
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. --
On 30 July 2011 00:28, James Hong Kong jamesin.hongkong.1@gmail.com wrote:
Dear all,
Standard MW, allows to use {{REVISIONTIMESTAMP}} it for a property that stores the last edit. We were wondering about the creation date of an document but since their is no standard magic word available we found some php code[1] that would give us the creation time stamp of the page that uses our own created magic word {{CREATIONTIMESTAMP}}.
Our questions is now, does to code[1] below is the best possible way to that or is their a more efficient way to get the creation time stamp via a magic word.
[1] case MAG_CREATIONTIMESTAMP: $parser->disableCache(); $title = $parser->getTitle(); $dbr =& wfGetDB( DB_SLAVE ); $res = $dbr->query("SELECT rev_timestamp FROM revision WHERE rev_page=".$title->getArticleID()." ORDER BY rev_timestamp LIMIT 0,1"); $row = $dbr->fetchRow($res); $dbr->freeResult($res); $ret = $row[0]; return true;
Cheers,
MWJames
Got Input? Slashdot Needs You. Take our quick survey online. Come on, we don't ask for help often. Plus, you'll get a chance to win $100 to spend on ThinkGeek. http://p.sf.net/sfu/slashdot-survey _______________________________________________ Semediawiki-user mailing list Semediawiki-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-user
wikitech-l@lists.wikimedia.org