3 * User-requested page cache purging.
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.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 * User-requested page cache purging.
26 * For users with 'purge', this will directly trigger the cache purging and
27 * for users without that right, it will show a confirmation form.
31 class PurgeAction
extends FormAction
{
33 private $redirectParams;
35 public function getName() {
39 public function requiresUnblock() {
43 public function getDescription() {
47 public function onSubmit( $data ) {
48 return $this->page
->doPurge();
52 * purge is slightly weird because it can be either formed or formless depending
55 public function show() {
58 // This will throw exceptions if there's a problem
59 $this->checkCanExecute( $this->getUser() );
61 $user = $this->getUser();
63 if ( $user->pingLimiter( 'purge' ) ) {
64 // TODO: Display actionthrottledtext
68 if ( $user->isAllowed( 'purge' ) ) {
69 // This will update the database immediately, even on HTTP GET.
70 // Lots of uses may exist for this feature, so just ignore warnings.
71 Profiler
::instance()->getTransactionProfiler()->resetExpectations();
73 $this->redirectParams
= wfArrayToCgi( array_diff_key(
74 $this->getRequest()->getQueryValues(),
75 [ 'title' => null, 'action' => null ]
77 if ( $this->onSubmit( [] ) ) {
81 $this->redirectParams
= $this->getRequest()->getVal( 'redirectparams', '' );
82 $form = $this->getForm();
83 if ( $form->show() ) {
89 protected function alterForm( HTMLForm
$form ) {
90 $form->setSubmitTextMsg( 'confirm_purge_button' );
93 protected function preText() {
94 return $this->msg( 'confirm-purge-top' )->parse();
97 protected function postText() {
98 return $this->msg( 'confirm-purge-bottom' )->parse();
101 public function onSuccess() {
102 $this->getOutput()->redirect( $this->getTitle()->getFullURL( $this->redirectParams
) );
105 public function doesWrites() {