SpecialDeadendPages.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * Implements Special:Deadenpages
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. * http://www.gnu.org/copyleft/gpl.html
  19. *
  20. * @file
  21. * @ingroup SpecialPage
  22. */
  23. use MediaWiki\MediaWikiServices;
  24. /**
  25. * A special page that list pages that contain no link to other pages
  26. *
  27. * @ingroup SpecialPage
  28. */
  29. class SpecialDeadendPages extends PageQueryPage {
  30. function __construct( $name = 'Deadendpages' ) {
  31. parent::__construct( $name );
  32. }
  33. function getPageHeader() {
  34. return $this->msg( 'deadendpagestext' )->parseAsBlock();
  35. }
  36. /**
  37. * LEFT JOIN is expensive
  38. *
  39. * @return bool
  40. */
  41. function isExpensive() {
  42. return true;
  43. }
  44. function isSyndicated() {
  45. return false;
  46. }
  47. /**
  48. * @return bool
  49. */
  50. function sortDescending() {
  51. return false;
  52. }
  53. function getQueryInfo() {
  54. return [
  55. 'tables' => [ 'page', 'pagelinks' ],
  56. 'fields' => [
  57. 'namespace' => 'page_namespace',
  58. 'title' => 'page_title',
  59. 'value' => 'page_title'
  60. ],
  61. 'conds' => [
  62. 'pl_from IS NULL',
  63. 'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()->
  64. getContentNamespaces(),
  65. 'page_is_redirect' => 0
  66. ],
  67. 'join_conds' => [
  68. 'pagelinks' => [
  69. 'LEFT JOIN',
  70. [ 'page_id=pl_from' ]
  71. ]
  72. ]
  73. ];
  74. }
  75. function getOrderFields() {
  76. // For some crazy reason ordering by a constant
  77. // causes a filesort
  78. if ( count( MediaWikiServices::getInstance()->getNamespaceInfo()->
  79. getContentNamespaces() ) > 1
  80. ) {
  81. return [ 'page_namespace', 'page_title' ];
  82. } else {
  83. return [ 'page_title' ];
  84. }
  85. }
  86. protected function getGroupName() {
  87. return 'maintenance';
  88. }
  89. }