Index: trunk/phase3/maintenance/purgeList.php |
— | — | @@ -68,65 +68,64 @@ |
69 | 69 | |
70 | 70 | /** Purge a namespace given by --namespace */ |
71 | 71 | private function purgeNamespace() { |
72 | | - $dbr = wfGetDB( DB_SLAVE ); |
73 | | - $ns = $dbr->addQuotes( $this->getOption( 'namespace') ); |
| 72 | + $dbr = wfGetDB( DB_SLAVE ); |
| 73 | + $ns = $dbr->addQuotes( $this->getOption( 'namespace') ); |
74 | 74 | |
75 | | - $result = $dbr->select( |
76 | | - array( 'page' ), |
77 | | - array( 'page_namespace', 'page_title' ), |
78 | | - array( "page_namespace = $ns" ), |
79 | | - __METHOD__, |
80 | | - array( 'ORDER BY' => 'page_id' ) |
81 | | - ); |
| 75 | + $result = $dbr->select( |
| 76 | + array( 'page' ), |
| 77 | + array( 'page_namespace', 'page_title' ), |
| 78 | + array( "page_namespace = $ns" ), |
| 79 | + __METHOD__, |
| 80 | + array( 'ORDER BY' => 'page_id' ) |
| 81 | + ); |
82 | 82 | |
83 | | - $start = 0; |
84 | | - $end = $dbr->numRows( $result ); |
85 | | - $this->output( "Will purge $end pages from namespace $ns\n" ); |
| 83 | + $start = 0; |
| 84 | + $end = $dbr->numRows( $result ); |
| 85 | + $this->output( "Will purge $end pages from namespace $ns\n" ); |
86 | 86 | |
87 | | - # Do remaining chunk |
88 | | - $end += $this->mBatchSize - 1; |
89 | | - $blockStart = $start; |
90 | | - $blockEnd = $start + $this->mBatchSize - 1; |
| 87 | + # Do remaining chunk |
| 88 | + $end += $this->mBatchSize - 1; |
| 89 | + $blockStart = $start; |
| 90 | + $blockEnd = $start + $this->mBatchSize - 1; |
91 | 91 | |
92 | | - while( $blockEnd <= $end ) { |
93 | | - # Select pages we will purge: |
94 | | - $result = $dbr->select( |
95 | | - array( 'page' ), |
96 | | - array( 'page_namespace', 'page_title' ), |
97 | | - array( "page_namespace = $ns" ), |
98 | | - __METHOD__, |
99 | | - array( # conditions |
100 | | - 'ORDER BY' => 'page_id', |
101 | | - 'LIMIT' => $this->mBatchSize, |
102 | | - 'OFFSET' => $blockStart, |
103 | | - ) |
104 | | - ); |
105 | | - # Initialize/reset URLs to be purged |
106 | | - $urls = array(); |
107 | | - foreach( $result as $row ) { |
108 | | - $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
109 | | - $url = $title->getFullUrl(); |
110 | | - $urls[] = $url; |
111 | | - } |
| 92 | + while( $blockEnd <= $end ) { |
| 93 | + # Select pages we will purge: |
| 94 | + $result = $dbr->select( |
| 95 | + array( 'page' ), |
| 96 | + array( 'page_namespace', 'page_title' ), |
| 97 | + array( "page_namespace = $ns" ), |
| 98 | + __METHOD__, |
| 99 | + array( # conditions |
| 100 | + 'ORDER BY' => 'page_id', |
| 101 | + 'LIMIT' => $this->mBatchSize, |
| 102 | + 'OFFSET' => $blockStart, |
| 103 | + ) |
| 104 | + ); |
| 105 | + # Initialize/reset URLs to be purged |
| 106 | + $urls = array(); |
| 107 | + foreach( $result as $row ) { |
| 108 | + $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
| 109 | + $url = $title->getFullUrl(); |
| 110 | + $urls[] = $url; |
| 111 | + } |
112 | 112 | |
113 | | - $this->sendPurgeRequest( $urls ); |
| 113 | + $this->sendPurgeRequest( $urls ); |
114 | 114 | |
115 | | - $blockStart += $this->mBatchSize; |
116 | | - $blockEnd += $this->mBatchSize; |
117 | | - } |
118 | | - } |
| 115 | + $blockStart += $this->mBatchSize; |
| 116 | + $blockEnd += $this->mBatchSize; |
| 117 | + } |
| 118 | + } |
119 | 119 | |
120 | 120 | /** |
121 | 121 | * Helper to purge an array of $urls |
122 | 122 | * @param $urls array List of URLS to purge from squids |
123 | 123 | */ |
124 | | - private function sendPurgeRequest( $urls ) { |
125 | | - $this->output( "Purging " . count( $urls ). " urls\n" ); |
126 | | - $u = new SquidUpdate( $urls ); |
127 | | - $u->doUpdate(); |
128 | | - } |
| 124 | + private function sendPurgeRequest( $urls ) { |
| 125 | + $this->output( "Purging " . count( $urls ). " urls\n" ); |
| 126 | + $u = new SquidUpdate( $urls ); |
| 127 | + $u->doUpdate(); |
| 128 | + } |
129 | 129 | |
130 | | - |
131 | 130 | } |
132 | 131 | |
133 | 132 | $maintClass = "PurgeList"; |