Extension talk:DeletePagePermanently


 * Hi, it works fine on Mediawiki 1.15.0 Thanks for this extension! Enzo

Using with Vector Skin
In order for the action to show properly on the vector skin, you must add a new hook. The hook definition is as follows:

$wgHooks['SkinTemplateNavigation'][] = array ( &$this,  'AddVectorHook' );

function AddVectorHook(&$sktemplate, &$links) { global $wgRequest, $wgRequest, $wgTitle, $wgUser, $wgDeletePagePermanentlyNamespaces;

if (!$wgUser->isAllowed('deleteperm')) return false;

$action = $wgRequest->getText('action');

#Special pages can not be deleted (special pages have no article id anyway). if ($wgTitle->getArticleID != 0 && $wgDeletePagePermanentlyNamespaces[$wgTitle->getNamespace] == true && $wgTitle->getNamespace != NS_SPECIAL) { wfLoadExtensionMessages('DeletePagePermanently');

$links['actions']['ask_delete_permanently'] = array (           'class' => $action == 'ask_delete_permanently' ? 'selected' : false,            'text' => wfMsg('delete_permanently'),            'href' => $wgTitle->getLocalUrl('action=ask_delete_permanently')        ); }

return true; }

&action=delete_permanently
I had to replace the $action for "delete_permanently" in my environment to make it work if ($action == 'ask_delete_permanently' ) { // Before : // $action = $wgArticle->getTitle->escapeLocalUrl."&action=delete_permanently"; // Now : $action = $wgArticle->getTitle->getLocalUrl('action=delete_permanently'); // index.php/TestPage&action=delete_permanently // become index.php?title=TestPage&action=delete_permanently $wgOut->addHTML(" ...

Hallo together,

I got the same problem, but I solved it in an other way. I am using MW (1.15.4), SMW (1.5.0), SMWHalo (1.5.0), PHP (5.2.10), MySQL (5.1.37) with  (2.1). The User LeLorrain (00:19, 29 December 2009 (UTC)) posted in "manque onglet ?", that he changed line 120 (v 2.1) from [1]    $action = $wgArticle->getTitle->escapeLocalUrl."?action=delete_permanently"; into [2]    $action = $wgArticle->getTitle->escapeLocalUrl."&action=delete_permanently"; . I changed it back into the old solution with "?". But there is another posibility to do so: [3]    $action = "?title=".$wgArticle->getTitle."&action=delete_permanently"; .

It is necessary to know how mediawiki uses the line: The address of the page (SITENAME) which should be deleted, looks like this: http://myurl.com/mediawiki/index.php/SITENAME If you wanna delete this page permanently, the ask-page comes with this address: http://myurl.com/mediawiki/index.php?title=SITENAME&action=ask_delete_permanently After clicking on OK there comes this address (old version) [1]: http://myurl.com/mediawiki/index.php/SITENAME?action=delete_permanently This works!!!

But in version (2.1) there is no "?", there is an "&" and so the address is [2]: http://myurl.com/mediawiki/index.php/SITENAME&action=delete_permanently This could not work!!!

My line produses this address [3]: http://myurl.com/mediawiki/index.php?title=SITENAME&action=delete_permanently This works!!!

Posibility [4] from top works also fine. The address which is shown is: http://myurl.com/mediawiki/index.php?title=SITENAME&action=delete_permanently So it works too!!!

Benor 17:10, 22 June 2010 (UTC)

Undefined offset:
If you try to open a page with namespace not defined in $wgDeletePagePermanentlyNamespaces (like Special:SpecialPages) I've got the following error: Undefined offset: -1 in /xxx/xxx/extensions/DeletePagePermanently/DeletePagePermanently.php on line ~ 86 You have: if ( $wgTitle->getArticleID != 0 & $wgDeletePagePermanentlyNamespaces[$wgTitle->getNamespace] == true & $wgTitle->getNamespace != NS_SPECIAL ) { Obviously the $wgDeletePagePermanentlyNamespaces[$wgTitle->getNamespace won't return boolen if the namespace is not defined in $wgDeletePagePermanentlyNamespaces. It will return -1. Probably you have to check if is in array first and then the value. One way of doing it is to just add @ before the expression like @$wgDeletePagePermanentlyNamespaces[$wgTitle->getNamespace] == true But I guess this could be done in a more elegant way. Rocco08

Fix
One way to fix it is to add an isset conditional before the check. This works because the entire expression will short circuit and the offending conditional will never evaluate.

if ($wgTitle->getArticleID != 0    && isset($wgDeletePagePermanentlyNamespaces[$wgTitle->getNamespace])     && $wgDeletePagePermanentlyNamespaces[$wgTitle->getNamespace] == true     && $wgTitle->getNamespace != NS_SPECIAL)

Also for those of you using the vector skin fix above you'll need to make this change a few lines below as well. --Spt5007 19:02, 2 July 2010 (UTC)

Caveat for copying/pasting code
This isn't specific to this extension, but I spent a bit figuring it out. After I "installed" this extension, my wiki's browser search ($IP/opensearch_desc.php) was broken. Turns out I'd pasted an extra line or two at the end of the file; it was breaking the XML that's supposed to get sent. So, watch out you don't add any empty lines to the end of the file! Miken32 21:52, 2 April 2009 (UTC)

Translation string errors
I got an error in the .i18n.php messages file, after installation. It appears the French translation contains extra ' in two strings. After quoting these strings with double quotes i.s.o, single quotes the problem is gone.
 * You need only to escape the extra quote with a backslash (\). The source code is updated. --LeLorrain 00:13, 29 December 2009 (UTC)

manque onglet ?
j'ai installer l'extension sur la version 1.15.1

je n'ai pas de message d'erreur mais je n'ai pas l'onglet "DeletePagePermanently" qui permet la suppression de la page.

que faire? merci :) --Voice 15:40, 27 September 2009 (UTC)


 * I hope you understand english because i can't speak french and translated you post with google ^^


 * There are 2 reasons why you can't see the tab: either you don't have the rights or the namespace you are in, is not configured for the extensions.


 * Check the configuration of  (for the userrights) and look, if the namespace is in   (to enable deleting of articles in the namespace) array. (For non-standard namespaces use the numbers you chosen in the   array)
 * --W.stoettinger 12:51, 28 September 2009 (UTC)

I grieve also translated with google;) I just add lines of code in the LocalSettings.php. as indicated:

it is this right?

I have not included for: (For non-standard namespaces use the numbers you chosen in the $wgExtraNamespaces array) ?

thank you --Voice 20:02, 28 September 2009 (UTC)

This isn't working in 1.15, just takes me to a page saying that the page 'insertpagenamehere?action=delete permanently' is empty and to create it.


 * Hi there, we fixed this behaviour by changing line 115 from:
 * to
 * Though we are no PHP-Programmers, this is only a temporary workarround.
 * The source code is updated. Thanks! --LeLorrain 00:19, 29 December 2009 (UTC)
 * Though we are no PHP-Programmers, this is only a temporary workarround.
 * The source code is updated. Thanks! --LeLorrain 00:19, 29 December 2009 (UTC)

j'ai trouver la solution pour le manque d'onglet utile à savoir si vous utilisez d'autres extensions qui jouent sur les droit d'utilisateur. pour ma part j'avais installer l'extension ipbwiki du coups mon compte est passé de sysop à Admin il suffis donc d'ajouter cette ligne dans le fichier LocalSettings.php:

voila :) --Voice 20:23, 11 October 2009 (UTC)

Category count update
Hi, I noticed that the DeletePagePermanently extension does not update category count. Here is a patch generated by git, I started from version 2.1.1 found on the extension page.

$ cat 0001--fix-category-count-on-deletion.patch [...] DeletePagePermanently.php |   9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/DeletePagePermanently.php b/DeletePagePermanently.php index 884e719..d161cf7 100644 --- a/DeletePagePermanently.php +++ b/DeletePagePermanently.php @@ -177,6 +177,15 @@ class DeletePagePermanently # Delete page Links $dbw->delete( 'pagelinks', array ( 'pl_from' => $id ), __METHOD__ ); +       # update categories count before removing category links +       $cat = array; +       $res = $dbw->select( 'categorylinks', 'cl_to', array( 'cl_from' => $id ), __METHOD__ ); +       foreach( $res as $row ) { +           $cat[]= $row->cl_to; +       } +        $article = new Article( $title ); +       $article->updateCategoryCounts(array, $cat); +        # delete category links $dbw->delete( 'categorylinks', array( 'cl_from' => $id ), __METHOD__);

Now the count should be correct after a page deletion. You can mail me at sberder@gmail.com for informations.
 * The problem is corrected and the source code updated. Thanks! --LeLorrain 00:06, 29 December 2009 (UTC)

&lt;delete_permanently&gt;
In other langages than english, the tab shows « &lt;delete_permanently&gt; ». Marc 15:39, 3 March 2010 (UTC)

Fixes for MW 1.16
I rewrote parts of the code to make the extension compatible with MW 1.16. The main reason for this is that the code given in the "Mediawiki 1.16.x" section does not work with MW 1.16: the "delete permanently" tab is displayed without any label. The method "$wgMessageCache->addMessage" is deprecated in MW 1.16, and no longer supported. I removed it and changed some little things to make the extension work properly. Please feel free to put this code on the main page if you wish to. Alvinos 12:00, 9 March 2010 (UTC)

");				return false;			}			# Perform actual deletion			elseif ($action == 'delete_permanently') {				$ns = $wgArticle->mTitle->getNamespace;				$t = $wgArticle->mTitle->getDBkey;				$id = $wgArticle->mTitle->getArticleID;				if ($t == '' || $id == 0 || $wgDeletePagePermanentlyNamespaces[$ns] != true || $ns == NS_SPECIAL) {					$wgOut->addHTML(wfMsgHtml('del_impossible'));					return false;				}				$this->deletePermanently($wgArticle->mTitle);				$wgOut->addHTML(wfMsgHtml('del_done'));				return false;			}			//$wgOut->addHTML(wfMsgHtml('del_not_done'));			return true;		}		function deletePermanently($title) {			global $wgOut;			$ns = $title->getNamespace;			$t = $title->getDBkey;			$id = $title->getArticleID;			$cats = $title->getParentCategories;			$dbw = wfGetDB(DB_MASTER);			$dbw->begin;			####			## First delete entries, which are in direct relation with the page:			####

# delete redirect... $dbw->delete('redirect', array ('rd_from' => $id), __METHOD__); # delete external link... $dbw->delete('externallinks', array ('el_from' => $id), __METHOD__); # delete language link... $dbw->delete('langlinks', array ('ll_from' => $id), __METHOD__); # delete search index... $dbw->delete('searchindex', array ('si_page' => $id), __METHOD__); # Delete restrictions for the page $dbw->delete('page_restrictions', array ('pr_page' => $id), __METHOD__); # Delete page Links $dbw->delete('pagelinks', array ('pl_from' => $id), __METHOD__); # delete category links $dbw->delete('categorylinks', array ('cl_from' => $id), __METHOD__); # delete template links $dbw->delete('templatelinks', array ('tl_from' => $id), __METHOD__); # read text entries for all revisions and delete them. $res = $dbw->select('revision', 'rev_text_id', "rev_page=$id"); while ($row = $dbw->fetchObject($res)) { $value = $row->rev_text_id; $dbw->delete('text', array ('old_id' => $value), __METHOD__); }			# In the table 'revision' : Delete all the revision of the page where 'rev_page' = $id $dbw->delete('revision', array ('rev_page' => $id), __METHOD__); # delete image links $dbw->delete('imagelinks', array ('il_from' => $id), __METHOD__); ####			## then delete entries which are not in direct relation with the page: ####

# Clean up recentchanges entries... $dbw->delete('recentchanges', array ( 'rc_namespace' => $ns, 'rc_title' => $t ), __METHOD__); # read text entries for all archived pages and delete them. $res = $dbw->select('archive', 'ar_text_id', array ( 'ar_namespace' => $ns, 'ar_title' => $t ));			while ($row = $dbw->fetchObject($res)) { $value = $row->ar_text_id; $dbw->delete('text', array ('old_id' => $value), __METHOD__); }			# Clean archive entries... $dbw->delete('archive', array ( 'ar_namespace' => $ns, 'ar_title' => $t ), __METHOD__); # Clean up log entries... $dbw->delete('logging', array ( 'log_namespace' => $ns, 'log_title' => $t ), __METHOD__); # Clean up watchlist... $dbw->delete('watchlist', array ( 'wl_namespace' => $ns, 'wl_title' => $t ), __METHOD__); # In the table 'page' : Delete the page entry $dbw->delete('page', array ('page_id' => $id), __METHOD__); ####			## If the article belongs to a category, update category counts ####			if (!empty($cats)) { foreach ($cats as $parentcat => $currentarticle) { $catname = split(':', $parentcat, 2); $cat = Category::newFromName($catname[1]); $cat->refreshCounts; }			}			####			## If an image is beeing deleted, some extra work needs to be done ####			if ($ns == NS_IMAGE) { $file = wfFindFile($t); if ($file) { # Get all filenames of old versions: $fields = OldLocalFile::selectFields; $res = $dbw->select('oldimage', $fields, array ('oi_name' => $t)); while ($row = $dbw->fetchObject($res)) { $oldLocalFile = OldLocalFile::newFromRow($row, $file->repo); $path = $oldLocalFile->getArchivePath. '/' . $oldLocalFile->getArchiveName; try { @unlink($path); } catch (Exception $e) { $wgOut->addHTML($e->getMessage); } }					$path = $file->getPath; try { $file->purgeThumbnails; @unlink($path); } catch (Exception $e) { $wgOut->addHTML($e->getMessage); } }				# clean the filearchive for the given filename: $dbw->delete('filearchive', array ('fa_name' => $t), __METHOD__); # Delete old db entries of the image: $dbw->delete('oldimage', array ('oi_name' => $t), __METHOD__); # Delete archive entries of the image: $dbw->delete('filearchive', array ('fa_name' => $t), __METHOD__); # Delete image entry: $dbw->delete('image', array ('img_name' => $t), __METHOD__); $dbw->commit; $linkCache = LinkCache::singleton; $linkCache->clear; }		}	}

new DeletePagePermanently; return true; } ?>

Permanently delete already deleted pages
Hi. This extension is great. Thanks for your hard work. I'd also like to use it to delete pages which have already been marked as deleted. But that's not possible right now since the tab isn't showing on deleted pages. How can I change that ?

Problems with SMW(SemanticMediaWiki) Annotations/Properties
Problem: We use the extension together with the SemanticMediaWiki(SMW) and we noticed that pages that are indexed with the (SMW) still appear in their queries.

Current Solution What happen is this we delete pages that include semantic properties and ones their are delete their are still appear the SMW query list (even after a purge, no backlogs of update jobs). As for the moment what we did was that we had to create the page again without the SMW annotations and then delete the page again. This can be only a short-term solution since we are using SMW extensively. Would be nice to have a better solution for this.

System Environment MediaWiki	1.16.0beta2, PHP	5.2.9-1 (cgi-fcgi), MySQL	5.0.77-community-nt LightTPD 1.4.22, SphinxSearch (Version 0.7.0), Semantic MediaWiki (Version 1.5.1)

Thanks, --MWJames 10:21, 15 June 2010 (UTC)

Don't working with Postgre
Why?

''relation searchindex does not exist ... FROM searchindex.''

Manual:Searchindex_table

Solution

Comment out the line 195 in DeletePagePermanently.php:
 * 1) $dbw->delete( 'searchindex', array( 'si_page' => $id ), __METHOD__);

Is it correct solution?

Thanks, --Tshr 13:17, 9 July 2010 (UTC)