Last modified: 2014-03-24 14:25:14 UTC
Sometimes it's desired that a special page be indexed or followed. E.g. some special pages have not just page metadata but actual content, such as a dictionary (e.g. http://childwiki.net/wiki/Special:Dictionary ), that does not exist in that particular format elsewhere on the wiki, and that the wiki owner might wish to have show up in search results. Therefore, I propose to enable SpecialPage::setHeaders() to set a different robot policy besides "noindex,nofollow". I guess the best way to do this would be to add a $policy argument: function setHeaders( $policy = "noindex,nofollow" ) { ... $out->setRobotPolicy( $policy ); ... }
Another option, of course, would be for the function to override setHeaders(), but that involves more code duplication.
Change 98255 had a related patch set uploaded by Parent5446: Add $robotPolicy parameter to SpecialPage::setHeaders() https://gerrit.wikimedia.org/r/98255
Change 98255 merged by jenkins-bot: Add $robotPolicy parameter to SpecialPage::setHeaders() https://gerrit.wikimedia.org/r/98255
(In reply to comment #3) > Change 98255 merged by jenkins-bot: > Add $robotPolicy parameter to SpecialPage::setHeaders() > > https://gerrit.wikimedia.org/r/98255 Was reverted, caused php warnings. See bug 57883
Question: is there some reason you can't just call $this->getOutput()->setRobotPolicy( $robotPolicy ) after calling $this->setHeaders(), as Brian Wolff mentioned? If not, this might be a WONTFIX...
(In reply to comment #5) > Question: is there some reason you can't just call > $this->getOutput()->setRobotPolicy( $robotPolicy ) after calling > $this->setHeaders(), as Brian Wolff mentioned? > > If not, this might be a WONTFIX... Alternative fix for this would be to create a new method of SpecialPage, call it getRobotPolicy(), that returns the robot setting, which is called in the default implementation of setHeaders(). That would probably be a cleaner solution anyways than the previous fix.
(In reply to comment #6) > (In reply to comment #5) > > Question: is there some reason you can't just call > > $this->getOutput()->setRobotPolicy( $robotPolicy ) after calling > > $this->setHeaders(), as Brian Wolff mentioned? > > > > If not, this might be a WONTFIX... > > Alternative fix for this would be to create a new method of SpecialPage, call > it getRobotPolicy(), that returns the robot setting, which is called in the > default implementation of setHeaders(). > > That would probably be a cleaner solution anyways than the previous fix. Comments 5 and 6 both present workable solutions. I take it the latter has an advantage over the former? So, I guess there should be also created an OutputPage::getIndexPolicy(), OutputPage::getFollowPolicy(), and an OutputPage::getRobotPolicy() that returns an array of the index and follow policies. SpecialPage::setRobotPolicy() then would look like: public function getRobotPolicy() { return $this->getOutput()->getRobotPolicy(); }
I was more thinking that SpecialPage::setHeaders() becomes: function setHeaders() { $out = $this->getOutput(); $out->setArticleRelated( false ); $out->setRobotPolicy( $this->getRobotPolicy() ); $out->setPageTitle( $this->getDescription() ); } and then a new method of SpecialPage function getRobotPolicy() { return "noindex,nofollow"; } and if people wanted to change what getRobotPolicy was, they would override in a subclass.
Change 117832 had a related patch set uploaded by Siebrand: Add getRobotPolicy() https://gerrit.wikimedia.org/r/117832
(In reply to Bawolff (Brian Wolff) from comment #8) > function getRobotPolicy() { Brian, is there a reason getRobotPolicy() should be public? Addshore says it should be protected. Thanks.
Change 117832 merged by jenkins-bot: Add getRobotPolicy() https://gerrit.wikimedia.org/r/117832