Extension talk:DeleteHistory

From MediaWiki.org
Jump to: navigation, search

Doesn't work on 1.16[edit]

FIXED in 0.2 version

Where do we find the DeleteHistory.php file?

The special page doesn't exist :

'Vous avez demandé une page spéciale qui n’existe pas.

Doesn't work on 1.16.

I'm having a similar problem (also 1.16). It doesn't seem to do anything; when I tell it to "simply check" and click the "Validate" button, the "Results:" box is empty. From looking at the php files, it appears that it's trying to call "php $pwd/maintenance/deleteOldRevisions.php". When I go into the "maintenance" directory and run that command manually, it complains about the LocalSettings.php file not being found. If I copy that file into the maintenance directory, then that works, but the extension still doesn't do anything. Does anyone know what needs to be changed (do I need to put LocalSettings.php somewhere else) to get this to work as intended? Bfunchess 17:18, 26 May 2011 (UTC)
You must rename the files after download
DeleteHistory_DeleteHistory.alias.php => DeleteHistory.alias.php
DeleteHistory_DeleteHistory.i18n.php => DeleteHistory.i18n.php
DeleteHistory_....
Lady Whistler 11:46, 14 June 2011 (UTC)

Link on the snapshot is broken. Unikum 06:44, 14 October 2011 (UTC)

No changes with Sysop and Administrator user[edit]

Mediawiki 1.14 : The Result section return nothing when I use the extension. Even if I use a sysop and administrator user.

Thanks for help.

Nepomuk (talk) 20:38, 25 March 2012 (UTC)

I have this same issue. It can optimize tables just fine, but actually deleting old revisions does not work and returns an empty result.
The line that should return a result is $out_logs = shell_exec(escapeshellcmd($command)); and this returns empty.
I have checked things and it is finding and trying to run the deleteOldRevisions.php command but nothing happens, and I have no idea why.

--Frug (talk) 21:30, 21 October 2013 (UTC)

You need to install php-cli to make it work

Same issue here. I have the extension installed and shows up in the Special pages, but when clicking the 'validate' it returns nothing. I checked with my host and php-cli is indeed installed (it's on a CentOS server) but not sure if the path/location of it is correct or not. If someone could let me know what needs to be where the in the file structure and/or what needs to be set up how and where to get this running it would be great. Running MediaWiki 1.20.2, PHP 5.3.28 (cgi-fcgi) Lestatdelc (talk) 19:07, 10 May 2014 (UTC)

Germany[edit]

Added in 0.6 version

For Germany language add:

to DeleteHistory.alias.php

/** German */
$aliases['de'] = array(
    'deletehistory' => array( 'DeleteHistory' ),
);

to DeleteHistory.i18n.php

/* *** German *** */
$messages['de'] = array(
	'deletehistory' => 'Delete History',
	'deletehistory-desc' => "Fügt eine spezielle Seite für Löschung der Versionsgeschichte hinzu ([http://www.deimos.fr/gitweb/?p=mediawiki_extensions.git;a=tree Git])",
	'what_to_do' => "Was wollen Sie tun",
	'check_only' => "Nur Überprüfung (Suche) löschbaren Versionsgeschichte",
	'del_hist' => "Versionsgeschichte löschen",
	'del_hist_opt' => "Versionsgeschichte löschen und Datenbank optimieren (bei großer Datenbank kann lange dauern)",
    'result' => 'Ergebnis',
    'db_size_old' => 'Größe der Datenbank vor Optimisierung',
    'db_size_new' => 'Größe der Datenbank nach Optimisierung',
    'db_space_won' => 'Gewonnerer Speicherplatz',
    'size' => 'Größe',
    'logs' => 'Logs',
    'opt_stat' => 'Status der Optimierung',
);

Then search in "DeleteHistory_body.php" for \"Validate\" and change it to \"Prüfen\"

Enjoy

Portuguese language[edit]

Added in 0.8 version

For Portuguese language add:

Patch #1 DeleteHistory.i18n.php

56a57,75
> 
> /* *** Brazilian Portuguese *** */
> $messages['pt-br'] = array(
>         'deletehistory' => 'Apagar Histórico',
>         'deletehistory-desc' => "Adiciona uma página especial para apagar históricos mais antigos (revisões) de artigos",
>         'what_to_do' => "Favor escolher qual ação você irá preferir",
>         'check_only' => "Apenas verifica se há o que ser apagado no histórico",
>         'del_hist' => "Apaga histórico",
>         'del_hist_opt' => "Apaga histórico e otimiza a base de dados (demora um pouco se a base de dados for muito grande)",
>     'validate' => 'Validar',
>     'result' => 'Resultado',
>     'db_size_old' => 'Tamanho da base de dados antes da otimização',
>     'db_size_new' => 'Tamanho da base de dados depois da otimização',
>     'db_space_won' => 'Tamanho da base de dados recuperado',
>     'size' => 'Tamanho',
>     'logs' => 'Logs',
>     'opt_stat' => 'Status da otimização',
> );
> 

and another patch

Patch #2 DeleteHistory_body.php

74c74
<                    <input type=\"submit\" value=\"Validate\">
---
>                    <input type=\"submit\" value=\"" . wfMsg('validate') . "\">
194c194
<                         <th>" . wfMsg('db_size_old') . "</th>
---
>                         <th>" . wfMsg('db_space_won') . "</th>

Bug detection[edit]

The extension say :

MediaWiki 1.20 requires at least PHP version 5.3.2, you are using PHP 4.4.9

I'm using : SetEnv REGISTER_GLOBALS 0 SetEnv ZEND_OPTIMIZER 1 SetEnv MAGIC_QUOTES 1 SetEnv PHP_VER 5_4

and Mediawiki 1.20.....

how to fix in MW 1.23 ?[edit]

I have installed V 0.8 for MW 1.23.3 but got this messages after using the DeleteHistory Special Page:

  • Warning: escapeshellcmd() has been disabled for security reasons in /www/htdocs/w00635e5/mediawiki/extensions/DeleteHistory/DeleteHistory_body.php on line 89
  • Warning: shell_exec() has been disabled for security reasons in /www/htdocs/w00635e5/mediawiki/extensions/DeleteHistory/DeleteHistory_body.php on line 89

Any idea to fix that? --Dg.de (talk) 09:55, 24 September 2014 (UTC)

Doesn't work on 1.27.0[edit]

Hello all.

I have updated my wiki to fresh 1.27.0 and the extension doesn't work! The message appears when I click to DeleteHistory at Special Page:

Fatal error: Call to undefined function wfMsg() in /var/www/admin/www/wikijournal.ru/extensions/DeleteHistory/DeleteHistory_body.php on line 64

Any ideas how to fix it?

JLTRY 17:30, 03 August 2016 (UTC)

You can replace wfMsg with wfMessage

You can also replace

$dbw =& wfGetDB( DB_MASTER );

with

$dbw = wfGetDB( DB_MASTER );

Still doesn't work[edit]

I tried to do so, but there are some other errors

For me the same and I also replace wfMsg with wfMessage as stated below with the example for 1.28, but it's giving me: [error] [7b57fb732798d949efd36bda] /tst/index.php/Special:DeleteHistory ErrorException from line 204 of /path_to/mediawiki/tst/extensions/added/DeleteHistory/DeleteHistory_body.php: PHP Notice: Undefined variable: out_opt

Talk_Pages MediaWiki 1.27.1[edit]

The extension doesn't detect the history of the Talk/Discussion pages. Could it be fixed?

MediaWiki 1.27.1 and DeleteHistory .08[edit]

Hi,

I use

  • MediaWiki 1.27.1
  • PHP 5.6.18
  • MySql 5.7.11
  • Icu 56.1
  • Extension:DeleteHistory .08
  • Langage : Français

It's a new wiki site.

I've installed Extension:DeleteHistory and i have this error Http://www.developpez.net/forums/attachments/p221768d1475500516/php/scripts/wiki/mediawiki-deletehistory/739634capture.jpg

I've changed

$dbw =& wfGetDB( DB_MASTER ); with $dbw = wfGetDB( DB_MASTER );

When I go on Pages_Spéciales and select DeleteHystory and "test" or "Suppression de l'historique", i have an error and this message :

Error : Missing one or more required components of PHP. You are missing a required extension to PHP that MediaWiki needs. Please Install :

  • mbstring

This wiki is local but I want to host it on Free.fr. What should I do to use this extension with my setup?

Merci par avance ... 8)

Something like a patch for MediaWiki 1.28.0[edit]

I have modified code of the extension, according to this manual: Help with replacing deprecated wfMsg* functions. Also I have added some code which allows the extension to be used with wiki family.

I'm not programmer and also I don't know PHP, so these changes could be done in more professional way, but at this state DeleteHistory extension works for me.

Modified file is $IP/extensions/DeleteHistory/DeleteHistory_body.php:

<?php
class DeleteHistory extends SpecialPage
{
    function __construct()
    {
        global $wgVersion;
        // Need to belong to Administor group
        parent::__construct( 'DeleteHistory', 'editinterface' );
        if ($wgVersion <= 1.16) {
            wfLoadExtensionMessages('DeleteHistory');
        }
    }

    function execute( $par )
    {
        // Get database size function
        function get_db_size()
        {
            global $wgRequest, $wgDBname;
            $dbw =& wfGetDB( DB_MASTER );

            $mw_dbname = $dbw->buildLike($wgDBname);
            $dbsize = $dbw->query( "select table_schema " . $mw_dbname . ", sum( data_length + index_length ) / 1024 / 1024 'DB sze in MB' from information_schema.TABLES where TABLE_SCHEMA " . $mw_dbname . " GROUP BY table_schema ;");
            while ($row = $dbw->fetchRow($dbsize))
            {
                $size = $row[1];
            }
            return $size;
        }

        // Get tables engine and collation
        function get_engine_col($table_name)
        {
            global $wgRequest, $wgDBname;
            $dbw =& wfGetDB( DB_MASTER );

            $engine_collation = $dbw->query( "select ENGINE,TABLE_COLLATION from information_schema.TABLES where TABLE_SCHEMA = '" . $wgDBname . "' and TABLE_NAME = '" . $table_name . "';");
            while ($row = $dbw->fetchRow($engine_collation))
            {
                $engine = $row[0];
                $collation = $row[1];
            }
            return array('engine' => $engine, 'collation' => $collation);
        }

        // Load required globals
        global $wgRequest, $wgOut, $wgUser, $wgDBname, $wgVersion;

        $this->setHeaders();

        // Check if user is Admin
        if ( !$this->userCanExecute($wgUser) )
        {
            $this->displayRestrictionError();
            return;
        }

        $dbw =& wfGetDB( DB_MASTER );

        // Get request data from, e.g.
        $param = $wgRequest->getText('param');

        // Localisation messages
        $check_only = wfMessage('check_only');
        $del_hist = wfMessage('del_hist');
        $del_hist_opt = wfMessage('del_hist_opt');

        // Escaping URI
        $current_uri = htmlentities($_SERVER['REQUEST_URI'], ENT_QUOTES, 'UTF-8');

        // User choice
        $wgOut->addWikiText(wfMessage('what_to_do') . ' :');
        $wgOut->addHTML("<form action=\"$current_uri\" method=\"post\">
            <input type=\"radio\" name=\"choice\" value=\"0\" checked>$check_only<br />
            <input type=\"radio\" name=\"choice\" value=\"1\">$del_hist<br />
            <input type=\"radio\" name=\"choice\" value=\"2\">$del_hist_opt (MySQL)<br /><br />
            <input type=\"submit\" value=\"" . wfMessage('validate') . "\">
            </form>
            ");

        // Choosen action choice
        $show_db_size=0;
        $pwd = getcwd();
        $command = 'php ' . $pwd . '/maintenance/deleteOldRevisions.php --delete' . ' --conf ' . $pwd . '/LocalSettings.php';

        if ((isset($_POST['choice'])) and ($_POST['choice'] == "0"))
        {
            $command = 'php ' . $pwd . '/maintenance/deleteOldRevisions.php' . ' --conf ' . $pwd . '/LocalSettings.php';
            $out_logs = shell_exec(escapeshellcmd($command));
        }
        elseif ((isset($_POST['choice'])) and ($_POST['choice'] == "1"))
        {
            $out_logs = shell_exec(escapeshellcmd($command));
        }
        elseif ((isset($_POST['choice'])) and ($_POST['choice'] == "2"))
        {
            $show_db_size=1;
            // Change deprecated function
            if ($wgVersion >= 1.18)
            {
                $dbw->begin();
            }
            else
            {
                $dbw->immediateBegin();
            }

            // Get actual database size
            $db_size_old = get_db_size( );

            // Delete old history
            $out_logs = shell_exec(escapeshellcmd($command));

            // Get all tables
            $alltables = $dbw->query( "SHOW TABLES" );

            // Show optimize status
            $out_opt="<table border=1 style='border-style: double;'>
                <tr>
                <th>Tables Names</th>
                <th>Engine</th>
                <th>Collation</th>
                <th>Status</th>
                </tr>
                ";

            while ($row = $dbw->fetchRow($alltables))
            {
                // Run and show output
                $out_opt .= "<tr>\n<td>";
                // Database name
                $out_opt .= $row[0] . "&nbsp;</td>\n<td>";
                // Get engine and collation
                extract(get_engine_col($row[0]));
                $out_opt .= $engine . "&nbsp;</td>\n<td>";
                $out_opt .= $collation . "&nbsp;</td>\n<td>";
                // Optimize
                $opt_res = $dbw->query("OPTIMIZE TABLE {$row[0]};");

                while ($res = $dbw->fetchRow( $opt_res ))
                {
                    // Set green color on OK and if table is already up to date
                    if (preg_match ("/OK/i", $res[3]))
                    {
                        $out_opt .= '<span style="font-weight: bold; color: green"> ' . $res[3] . '&nbsp;</span>';
                    }
                    elseif (preg_match ("/Table is already up to date/i", $res[3]))
                    {
                        $out_opt .= '<span style="color: green">' . $res[3] . '&nbsp;</span>';
                    }
                    else
                    {
                        $out_opt .= $res[3] . '&nbsp;';
                    }
                }
            }
            $out_opt.="</table>";

            // Get size after
            $db_size_new = get_db_size( );
        }

        // Fix display pre problem
        if ((isset($_POST['choice'])) and ($_POST['choice'] != ""))
        {
            $wgOut->addHTML("<br />");
            $wgOut->addWikiText('=' . wfMessage('result') . '=');

            // Show DB size if ask to optimize
            if ($show_db_size == 1)
            {
                function kb_or_mb($db_size_old,$db_size_new)
                {
                    $spacewon=($db_size_old - $db_size_new);
                    if ($spacewon < 1)
                    {
                        $spacewon = ($spacewon * 1024) . " KB";
                    }
                    else
                    {
                        $spacewon = $spacewon . " MB";
                    }
                    return $spacewon;
                }
                // Show result
                $wgOut->addHTML("<table border=1'>
                    <tr>
                    <td></td>
                    <th>" . wfMessage('size') . "</th>
                    </tr><tr>
                    <th>" . wfMessage('db_size_old') . "</th>
                    <td>$db_size_old MB</td>
                    </tr><tr>
                    <th>" . wfMessage('db_size_new') . "</th>
                    <td>$db_size_new MB</td>
                    </tr><tr>
                    <th>" . wfMessage('db_space_won') . "</th>
                    <td align='center'><b>" . kb_or_mb($db_size_old,$db_size_new) . "</b></td>
                    </tr></table><br />
                    ");
            }

            if ($out_opt)
            {
                $wgOut->addWikiText('=' . wfMessage('opt_stat') . '=');
                $wgOut->addHTML($out_opt . '<br />');
            }
            if ($out_logs)
            {
                if ($_POST['choice'] == "2")
                {
                    $wgOut->addWikiText('=' . wfMessage('logs') . '=');
                }
                $wgOut->addHTML("<pre>".$out_logs."</pre>");
            }
        }
        return true;
    }
}

Not work in MediaWiki v1.28.0[edit]

I wanted to try the extension, but it does not work.

I tried the patch made by Spas.Z.Spasov

Now it works, but it can not delete the single edit. But this is not what I was looking for.

Not work in MediaWiki v1.28.0 with the patch[edit]

I can not see the history, since the form, the validation of the choice of the form does not show anything.

The extension displays the selection form, but no response after the form is validated.

I look for that : If you don't see anything new, it's because you don't have the admin privileges.

My mediawiki user is an administrator, I gave him the rights.

How i can have the admin privileges ? ( Note that I use a shared server, not a dedicated server or VPS. )

The follow-up of my research in French : https://www.visionduweb.eu/wiki/index.php?title=Gerer_et_installer_des_extensions_avec_MediaWiki#DeleteHistory

Не работает в 1.28.1[edit]

(в том числе с патчем )

No solution for shared hosting[edit]

Still no solution for shared hosting, with php 7.0

1.28.2 1.29[edit]

Hello dear friends. DeleteHistory unfortunately does not work in 1.28.2 and 1.29. Please request the developer to repair the extension so that it works. Extension is very necessary and useful. Thank you.