Open main menu

Extension talk:EditWarning

Contents

2007Edit

Fatal error: Cannot redeclare fneditwarning()Edit

I get this error:

Fatal error: Cannot redeclare fneditwarning() (previously declared 
in D:\Server\mediawiki-1.10.0\extensions\EditWarning\EditWarning.php:42) 
in D:\Server\mediawiki-1.10.0\extensions\EditWarning\EditWarning.php on line 50

how can I solve this problem? --84.59.136.197 23:32, 25 November 2007 (UTC)

Hi! Sorry for the late response. This was just a little bug which is fixed now. Just grab the updated tar.gz from server. --Nemphis 14:27, 30 November 2007 (UTC)

French translationEdit

Hi, this extension is very good. So I translate it into french. You can get the files here. I hope it could be usefull for anybody.--Add 18:09, 17 December 2007 (UTC)

Two questionsEdit

  • Can the extension be changed to recognize anonymous edits, too? --Nemphis 19:55, 24 January 2008 (UTC)
    • I think that's not possible. The problem is, that the extension needs to identify every user, which is editing the page. That's a bit difficult with anonymous users. --Nemphis 19:55, 24 January 2008 (UTC)
      • Anonymous page edits are ignored. Instead of User-ID the IP might be used. Do you think this is a nice solution? --Jostar 17:25, 20 September 2011 (UTC)
  • If the edit lock is implemented, can it be turned off on a project that uses the extension? Omegatron 14:05, 23 January 2008 (UTC)
    • Yes. The lock will be optional. --Nemphis 19:55, 24 January 2008 (UTC)

2008Edit

BugEdit

I love the extension but it seems to have a little bug. It seems that if the first editor cancels out of editing the page, the extension still thinks the person is editing it. Can someone help solve this? I really like this extension. Also, is there a time-out? Can a person hold the page for days? --Ed (February 2, 2008)

This is a known problem. If any editor cancels the editing, the entry in the database will not be deleted. But the regular timeout of 10 minutes prevents holding a page over days. I try to fix this behavior soon. --Nemphis 09:28, 3 February 2008 (UTC)

EditWarning 0.3 betaEdit

The new version is out! It should look nicer and work better. Grab it while it's hot!

Plans for the future:

  • Support more templates.
  • Improve recognation of editing aborts.
  • Page lock.
  • Basic handling of anonymous users.

--Nemphis 17:25, 30 March 2008 (UTC)

Great job Nemphis! Thank you for updating the extension. Very useful! --Ed D (May 6, 2008)

SidebarEdit

I installed this extension on a 1.10.1 installation. When I edit a page my sidebar and other supporting content fails to appear. All that shows is the Editing area along with the buttons below. Is this a known problem? or Is it simply some conflict with my heavily extended installation. --IP 13 June 2008

Does it look like that: Media:EditWarning_editing.png? --87.179.199.94 17:24, 13 June 2008 (UTC)
Yeah, anyone got a fix for this? I have fresh installation of 1.12.0 and I too have the same problem so I suppose this isn't a conflict with other extensions 212.160.172.70 14:19, 18 June 2008 (UTC)
Hi! This is not a bug, it's a feature! :) The extension hides everything except the editor area to make the user clicking on the "Cancel" button. If you don't like this behavior, just change the file article_edit.css from:
    @media all
    {
	#siteSub,
	#footer,
	.portlet { display:none; }
    }
to:
    /* @media all
    {
	#siteSub,
	#footer,
	.portlet { display:none; }
    }*/
--Nemphis 20:22, 18 June 2008 (UTC)

Error when rolling back recent changesEdit

Hi everybody! When rolling back recent changes, I'm getting this error:

Warning: Missing argument 9 for fnEditWarning_save() in [my_wiki_folder]/extensions/EditWarning/EditWarning.php on line 143

Any ideas how to avoid this error? Thanks! --89.12.5.60 15:12, 26 June 2008 (UTC)

Thanks for your report! I fixed this problem with the 0.3.2 release. --Nemphis 15:39, 13 July 2008 (UTC)

Fatal error: Call to undefined function bcdiv()Edit

Hi, I get this error:

Fatal error: Call to undefined function bcdiv() in [Wiki Folder]/extensions/EditWarning/EditWarning.php on line 105

Can someone help? -- Thi. 10 July 2008

You have to compile php with bcmath --IP 22 July 2008
hi, i'm also getting this error. How to compile php with bcmath? Thanks! --LizK 09:25, 25 August 2008 (UTC)
Add this to the beginning of EditWarning.php:
       if( !function_exists( "bcdiv" ) )
       {
           function bcdiv( $first, $second, $scale = 0 )
           {
               $res = $first / $second;
               return round( $res, $scale );
           }
       }
--IP 18 September 2008

Some bugsEdit

1. If the default page is not called index.php, tpl_(notice|warning).html include wrong files (or 404 error).

Thanks for your report! This behavior is fixed with the 0.3.2 release. --Nemphis 15:44, 13 July 2008 (UTC)

2. Not possible to lock individual sections.

I solved the first by just modifying the tpl*.html files manually (ereg_replace could be used to fix it permanently). I will have a look at locking by sections, if at all possible, will do something to enable it eventually...
Great work, thanks for your code. --IP 11 July 2008

The possibility to lock individual sections is planned for the 0.4 release I'm currently working on. Stay tuned! --Nemphis 15:44, 13 July 2008 (UTC)

Blank screenEdit

3. I just get a blank screen when I want to edit a page that's already been edited by someone else. Im using version 0.3.2 and mediawiki version 1.13.2. --IP 17 November 2008

Fixed, I put on errors for mediawiki and changed DEBUG to 'DEBUG' on line 370 in EditWarning.class.php. --IP 17 November 2008

Editing in different sectionsEdit

Alice wants to edit Section "foo" at page "FooBar". Now Bob wants edit Section "bar" at the same page (FooBar) too. He gets a warning message that says Alice is currently editing the page. Is it possible to disable this message in the case that Alice and Bob are editing different Sections? --IP 26 September 2008

The extension doesn't care about sections currently. But the next version will support sections. Then two users won't get a warning message if they work on different sections. --Nemphis 15:32, 26 September 2008 (UTC)

Downloading the latest versionEdit

I'm having trouble downloading the file. The tar file gives me "Error reading header after processing 0 files". Is there an alternate link? Is there a way around this problem? --Ed D (Sept 28, 2008)

It works for me. Which application do you use to unpack it? --Nemphis 14:19, 28 September 2008 (UTC)
I was using Winzip. I downloaded and tried it with TUGZip...and it worked. Thank you. --Ed D 29 September 2008

PostgreSQLEdit

I've tested this extension with a PostgreSQL database and it seems not to work.

Is it planned to work with it in the future ?

I think the "`" character in the SQL requests is not supported. --IP 17 October 2008

Ok, thanks for your bugreport! I try to fix it soon. --Nemphis 2 March 2009

2009Edit

french version for internationalisationEdit

Please find the following code :

// French
$messages['fr'] = array(
 'notice'        => "Jusqu'au {{{DATE}}} a {{{TIME}}}, les autres utilisateurs auront un message leur indiquant que vous modifiez cette page. Vous pouvez prolonger cette duree en cliquant sur Previsualiser.",
 'warning'       => "L'utilisateur {{{USERNAME}}} a ouvert cette page pour la modifier le {{{DATE}}} à {{{TIME}}}. Vous devriez eviter de faire des modifications jusqu'au {{{TIMEOUT}}} {{{MINSEC}}}, afin d'eviter des conflits de version.",
 'cancel'        => "Vous pouvez quitter cette page en cliquant sur le bouton Annuler.",
 'canceled'      => "Modification interrompue.",
 'minute'        => "minute",
 'minutes'       => "minutes",
 'seconds'       => "secondes",
 'button_cancel' => "Annuler"
);

BTW, I am getting some strange notice when using it : "Notice: Undefined index: etc.....". I am using UTF-8 for user names, I already had to change the table settings in the database. And the sidebar disappears during editing ! Could it be affected inside the script ? Best regards, --Rmatt 00:43, 2 March 2009 (UTC)

Thank you very much for the translation! The notice issue sounds strange, but I'll look where the problem is. As mentioned above (1) the disappearing of the sidebar is a intended behaviour. Just comment out the contents of article_edit.css if you don't like it. Cheers, Nemphis 09:28, 2 March 2009 (UTC)

EditWarning 0.3.3 releaseEdit

Changes:

  • Fixing SQL queries to make the extension work with PostgreSQL.
  • Added french translation by Rmatt.
  • Using language setting from user profile.

--Nemphis 4 March 2009

EditWarning 0.3.4 releaseEdit

Changes to previous version:

  • New config value: If you don't want that the extension shows only the editor area, add $EditWarning_OnlyEditor = "false" to your LocalSettings.php
  • License change: I change the license of the extension to GPL v2, because AGPL v3 isn't compatible with GPL v2 used by MediaWiki.

--Nemphis 2 April 2009

0.4-alpha releaseEdit

After a long time it is finally here and it supports section editing now. See Extension:EditWarning/0.4. --Nemphis 7 April 2009

0.3.4 Download ErrorEdit

The link to the download of version 0.3.4 yields a 403 Access Forbidden error. --IP 7 May 2009

Oh, sorry! Download should work again. --Nemphis 20:45, 7 May 2009 (UTC)

PHP NoticesEdit

I keep receiving a 500 Internal Server Error when using the extension and trying to edit a page. Sometimes the error will disappear and the edit page will load after refreshing the page, other times it won't.

The error is always a PHP notice referring to a undefined index in $IP\extensions\EditWarning\EditWarning.class.php. It has stated that the undefined index is among others: active on line 353 and WikiSysop on line 395.

Any ideas on how to prevent these errors from ever appearing? I have working on a wiki on a WAMP server, but it won't work on my wiki on an IIS 7 server. --Ejohns 1 July 2009

per namespaceEdit

is there a way to restrict the notices per namespace? --IP 5 August 2009

No, currently the extension has no functionality to do this. --Nemphis 15:57, 5 August 2009 (UTC)

Formal GermanEdit

Because you don't use the native translation methods, German users with "de-formal" set see English translations. The fix to this is simply to copy $messages['de'] into $messages['de-formal']. The translation of 'de' into informal, I will leave to a native speaker ;) --Cm 09:12, 29 October 2009 (UTC)

in fact it was formal german. Here are the both translations:
// German
$messages['de'] = array(
  'notice'        => "Bis <strong>{{{DATE}}} {{{TIME}}}</strong> erhalten andere Benutzer die Warnung, dass du die Seite bearbeitest. Mit <em>Vorschau zeigen</em>, kannst du den Zeitraum verl&auml;ngern.",
  'warning'       => "Der Benutzer <strong>{{{USERNAME}}}</strong> &ouml;ffnete diese Seite am <strong>{{{DATE}}} um {{{TIME}}}</strong> zum Bearbeiten. Du solltest f&uuml;r die n&auml;chsten <strong>{{{TIMEOUT}}} {{{MINSEC}}}</strong> keine &Auml;nderungen vornehmen, um Bearbeitungskonflikte zu vermeiden.",
  'cancel'        => "Du kannst diese Seite &uuml;ber den Button <em>Abbrechen</em> verlassen.",
  'canceled'      => "Bearbeitung abgebrochen.",
  'minute'        => "Minute",
  'minutes'       => "Minuten",
  'seconds'       => "Sekunden",
  'button_cancel' => "Abbrechen",
);

// German formal
$messages['de-formal'] = array(
  'notice'        => "Bis <strong>{{{DATE}}} {{{TIME}}}</strong> erhalten andere Benutzer die Warnung, dass Sie die Seite bearbeiten. Mit <em>Vorschau zeigen</em>, k&ouml;nnen Sie den Zeitraum verl&auml;ngern.",
  'warning'       => "Der Benutzer <strong>{{{USERNAME}}}</strong> &ouml;ffnete diese Seite am <strong>{{{DATE}}} um {{{TIME}}}</strong> zum Bearbeiten. Sie sollten f&uuml;r die n&auml;chsten <strong>{{{TIMEOUT}}} {{{MINSEC}}}</strong> keine &Auml;nderungen vornehmen, um Bearbeitungskonflikte zu vermeiden.",
  'cancel'        => "Sie k&ouml;nnen diese Seite &uuml;ber den Button <em>Abbrechen</em> verlassen.",
  'canceled'      => "Bearbeitung abgebrochen.",
  'minute'        => "Minute",
  'minutes'       => "Minuten",
  'seconds'       => "Sekunden",
  'button_cancel' => "Abbrechen",
);
--Jostar 10:05, 8 February 2010 (UTC)

2010Edit

Security release 0.3.5Edit

The 0.3.5 release fixes a SQL injection problem. Please update immediately!

--Nemphis 28 January 2010

Release 0.3.6Edit

The new version contains message strings for formal german. Users choosing this translation don't get english messages anymore.

For download and updates see: http://blog.code-geek.de/categories/2-EditWarning --Nemphis 16:04, 8 February 2010 (UTC)

Changing the Time to Local TimeEdit

The current time shown is the default time that I installed mediawiki with. How do I change the time in the extension to the local time? I have modified the localSettings file for the mediawiki installation but not sure of what to modify in this extension.

Thanks. --IP 23 February 2010

Blank Page when there's an edit conflictEdit

Our green header is showing up fine, but whenever someone is already editing a page, we get a blank white page instead of the red warning box - nothing loads on the page whatsoever. Anyone have any fixes for this? Thanks! --Aekki99 21:12, 11 April 2010 (UTC)


Nimish Patel

I Just installed this extension and I am receiving a blank page as well as stated above. Does anyone have a fix for this? Do we need to do any edits for this extension MW ver 1.15 Editwarning version: 0.3.6
  • Hi, I'm tested the extension with a fresh MediaWiki installation (v. 1.15.4) and couldn't reproduce the problem. Have you tried adding the line
$EditWarning_OnlyEditor = "false";

to your LocalSettings.php file? If it doesn't help, please provide a list of the installed extensions of your MediaWiki instance. --Nemphis 09:27, 20 July 2010 (UTC)

Fix for CSS pathEdit

If your wiki has "nice URLs" (like the Wikipedia's) then the links to the CSS files are wrong when a page loads and that produces not valid CSS. I.e. it would use http://yourdomain/$wgArticlePath/extensions/...instead of http://yourdomain/$wgScriptPath/extensions/... Since in some installs the $wgArticlePath is a server alias to scriptpath/index.php, the code will try to find a wikipage instead of a file and then fail.

Here is a fix. Edit file EditWarning.php and modify the three lines where you can see "$wgScriptPath". (Disclaimer: I am not a programmer, don't know if that is the best solution, but the CSS is now valid ...)

  function fnEditWarning_init() {
    if (EWDEBUG) error_log('----- fnEditWarning_init()');
    global $wgRequest, $wgOut, $EditWarning_OnlyEditor, $wgScriptPath;

    // Add CSS styles to header
    if ( ( $wgRequest->getVal('action') == 'edit' || $wgRequest->getVal('action') == 'submit' ) && $EditWarning_OnlyEditor != "false" ) {
    	$wgOut->addHeadItem('edit_css', '  <link href="' . $wgScriptPath . '/extensions/EditWarning/article_edit.css" rel="stylesheet" type="text/css" />');
    }
    $wgOut->addHeadItem('EditWarning', '  <link href="' . $wgScriptPath . '/extensions/EditWarning/EditWarning.css" rel="stylesheet" type="text/css" />');

    return true;
  }

- Daniel K. Schneider 17:42, 19 August 2010 (UTC)

  • Thank your Daniel! I published a new release with your fix. --Nemphis 19:54, 26 August 2010 (UTC)

Release 0.3.7Edit

The new version contains Daniel's CSS fix (see above).

For download and updates visit: http://blog.code-geek.de/categories/2-EditWarning --Nemphis 19:59, 26 August 2010 (UTC)

2011Edit

After executing the MySQL statement I receive this error when trying to edit a page: http://img51.imageshack.us/i/databaseerror.jpg/

Any help? -- justin

I fixed this problem by adding a "mdw_" before the "current_edits" in line 1 of the MySQL command. Sorry for the confusion. If you're having this problem check to make sure that the table name your mediawiki install is querying is the same as the one you create with the MySQL command. :-)

ErrorsEdit

I followed the instructions for the 0.4 release and I am getting the following Notices:

Notice: Undefined index: wpSection in /data/wiki/extensions/EditWarning/EditWarning.php on line 79

Notice: Undefined variable: self in /data/wiki/extensions/EditWarning/EditWarningMsg.class.php on line 56

Notice: Trying to get property of non-object in /data/wiki/extensions/EditWarning/EditWarningMsg.class.php on line 56

Please help.

With 3.7 I get

Notice: Undefined index: active in C:\wamp\www\gdmwiki\extensions\EditWarning\EditWarning.class.php on line 349

Notice: Undefined index: <user login> in C:\wamp\www\gdmwiki\extensions\EditWarning\EditWarning.class.php on line 391

(MediaWiki 1.17.0)

Version 0.4 broken for PHP 5.3Edit

With PHP 5.3.2-1ubuntu4.9 and both MW 1.16 and MW 1.17

Detected bug in an extension! Hook fnEditWarning_edit has invalid call signature; Parameter 1 to fnEditWarning_edit() expected to be a reference, value given

Backtrace for a MW 1.17 wiki

#0 /export/data/portails/fmediawiki/includes/EditPage.php(313): wfRunHooks('AlternateEdit', Array)
#1 /export/data/portails/fmediawiki/includes/EditPage.php(296): EditPage->edit()
#2 /export/data/portails/fmediawiki/includes/Wiki.php(522): EditPage->submit()
#3 /export/data/portails/fmediawiki/includes/Wiki.php(69): MediaWiki->performAction(Object(OutputPage), Object(Article), Object(Title), Object(User), Object(WebRequest))
#4 /export/data/portails/fmediawiki/index.php(114): MediaWiki->performRequestForTitle(Object(Title), Object(Article), Object(OutputPage), Object(User), Object(WebRequest))
#5 {main}

Backtrace for a MW 1.16 wiki

#0 /export/data/portails/demediawiki/includes/EditPage.php(288): wfRunHooks('AlternateEdit', Array)
#1 /export/data/portails/demediawiki/includes/EditPage.php(271): EditPage->edit()
#2 /export/data/portails/extensions/FCKeditor/FCKeditor.body.php(161): EditPage->submit()
#3 [internal function]: FCKeditor_MediaWiki->onCustomEditor(Object(Article), Object(StubUser))
#4 /export/data/portails/demediawiki/includes/Hooks.php(133): call_user_func_array(Array, Array)
#5 /export/data/portails/demediawiki/includes/Wiki.php(545): wfRunHooks('CustomEditor', Array)
#6 /export/data/portails/demediawiki/includes/Wiki.php(70): MediaWiki->performAction(Object(OutputPage), Object(Article), Object(Title), Object(User), Object(WebRequest))
#7 /export/data/portails/demediawiki/index.php(117): MediaWiki->performRequestForTitle(Object(Title), Object(Article), Object(OutputPage), Object(User), Object(WebRequest))
#8 {main}

See also:

Any hint from an extensions guru how to fix this ? :) - Daniel K. Schneider 10:34, 23 September 2011 (UTC)

PS: First thought it was MW 1.17 (didn't really look at it) - 09:42, 26 September 2011 (UTC)

      • I just upgraded my site from PHP 5.2 to 5.3 and the extension doesn't work. The "fixed" rc1 version doesn't work either. Is there a new fix? Is this extension still supported?--Jmnorvell (talk) 05:50, 28 August 2013 (UTC)

2013Edit

Hey, this isn't necessarily a fix, but is there any way you can slightly adapt this extension to show a security message every time a user edits a page? What I'm looking for is to show my users a friendly warning about not posting restricted or confidential content on our wiki, and I want to display this warning every time a user goes to edit a page. Like I said, it's not really a fix, just a customization, I'm not really sure how to go about doing this myself otherwise I'd just do it (I can certainly administer the wiki, but I haven't developed extensions for it before), if perhaps you can't do that then maybe you could tell me how to do it myself? I don't really need the locked editing functionality because we don't have enough users to really worry about that and this is a private wiki. Thanks!
-Sberube (talk) 23:30, 29 January 2013 (UTC)

WarningsEdit

Undefined index: wpSection in EditWarning.php on line 81 Please fix. Undefined variable: self in EditWarningMsg.class.php on line 56 Notice: Trying to get property of non-object in EditWarningMsg.class.php on line 56

Semantic FormsEdit

This extension is useful but it doesn't seem to work with Semantic Forms.
Has anyone considered making it work with Semantic Forms? This would be really great. Stefahn (talk) 15:06, 13 August 2013 (UTC)


MediaWiki v 1.21.3 Installation Issues (Using phpMyAdmin)Edit

After spending considerable time getting this extension to work, and trying to help others in the same vein, someone from an anonymous IP address just wiped out my entire contribution here. After contacting Nemphis, the originator of the EditWarning extension, and verifying it was not him, I am reinstating my contributions. I you want to delete these procedures, do me the courtesy of logging in and providing me the courtesy of a reason as to why you just wiped out an hour or two of my work to help others. Thank you.

17:11, 23 November 2013 (UTC)


Installing the EditWarning Extension on MediaWiki was a bit of a challenge due to multiple errors encountered during the installation process. Hopefully these notes will help others as they try to use this VALUABLE extension, and after the work that Nemphis has obviously done to build this jewel, a few notes on my experience and hopefully a leg up for many others who can benefit from this awesome work is the least I could do.

PLEASE NOTE: I am by no means the world's greatest, or even one of the mediocre best programmers. I plowed through this and hacked at it enough in order to make it work, and from all appearances, the extension is now functioning properly.

Only the original coder Nemphis and anyone else thoroughly familiar with the extension from the inside out will know whether these "fixes" actually screw up something down the line or not. If so, please feel free to edit and change the instructions here so that future conflicts and issues can be avoided. Thanks!

To Nemphis, thanks again for your hard work on this. We'd have been lost without it. (We've had our wiki up 3 days and were already driving each other crazy with multiple simultaneous edits and sorting nightmares!)

Software Version
MediaWiki 1.21.3
PHP 5.3.27 (litespeed)
MySQL 5.5.32-cll-lve
phpMyAdmin 4.0.8


The first error occurred during the database modifications.

The CREATE TABLE editwarning_locks portion presents no errors.

The ALTER TABLE editwarning_locks portion presented the following error when running the SQL code into the phpMyAdmin interface:

#1005 - Can't create table 'xxxxxxxx_mw111.#sql-a49f8_a3bdf6' (errno 150)

Modifying the DatabaseEdit

For some reason, the table editwarning_locks was missing two indexes to match up to the foreign key constraints. So these indexes must be added manually. Someone more skilled with SQL could write the queries here, but I used the phpMyAdmin interface to do it because it gave me the visual "hooks" I was looking for as I fiddled around to get it to work.


  1. In the editwarning_locks table, flip over to the Structure tab in phpMyAdmin.
  2. Click the Indexes link below the table rows and 'Add' functions and just above the 'Information' section.
  3. In the 'Create an index on 1 columns' box, click Go.
  4. Set Index name to user, Index type to INDEX, and the Column setting to user_id and click Go.
  5. You should see the new index user appear in the table of indexes. Ignore the "equal and could be removed" notification.
  6. Click the Go link again to create another index.
  7. Set Index name to page, Index type to INDEX, and the Column setting to article_id and click Go. Ignore the second "equal and could be removed" notification.
  8. Look back up under the table rows and above the 'Add' functions and click Relation view.
  9. Next to the user_id column, click the dropdown box and select the "xxxxxxxx_mw111.editwarning_locks.user_id" option, which in my phpMyAdmin interface was first on the list.
  10. Under Constraint name, type user, and change the 'ON DELETE' setting to CASCADE and the 'ON UPDATE' setting to CASCADE.
  11. Next to the article_id column, click the dropdown box and select the "xxxxxxxx_mw111.editwarning_locks.article_id" option, which in my phpMyAdmin interface was second on the list.
  12. Under Constraint name, type page, and change the 'ON DELETE' setting to CASCADE and the 'ON UPDATE' setting to CASCADE.
  13. Click Save and your foreign key constraints should be properly added to the editwarning_locks table.


Cleaning Up the EditWarning.php FileEdit

Okay, we're movin' and groovin'. The next step of the instructions has us adding the next line to LocalSettings.php:

require_once("$IP/extensions/EditWarning/EditWarning.php");


If you haven't already taken care of this little issue, at this point we get the White Screen of Death as PHP fails to locate the wfLoadExtensionMessages() function found on line 102 of the /extensions/EditWarning/EditWarning.php file. Apparently, this is deprecated in the newest versions of MediaWiki, and many on the Net suggest just remming out the line to fix the errors from older installations. If there's another way around this, I'm open to suggestions. Be aware that this may break other extensions that you have installed if they are using that function. Only you know the exact layout of your own install and the extensions you've plugged in.

However you get to the files on your server, edit the EditWarning.php file and rem that line out like so, then save the file:

//wfLoadExtensionMessages('EditWarning');


Now, if we browse to our MediaWiki installation, it should display just fine in reading mode. But as soon as we click on the Edit link, the next error appears:

A database error has occurred. Did you forget to run maintenance/update.php after upgrading? See: https://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script Query: SELECT * FROM `mw_editwarning_locks` WHERE `article_id` = '1' AND `timestamp` >= '1385176105' Function: DatabaseBase::select Error: 1146 Table 'xxxxxxxx_mw111.mw_editwarning_locks' doesn't exist (localhost)


Duplicating the editwarning_links TableEdit

I'm not sure exactly what's causing this problem, but I suspect it's a mix-up of between the regular mw_tablename convention used for almost all other MediaWiki tables and the editwarning_locks convention used with the EditWarning extension.

Renaming the editwarning_locks table to mw_editwarning_locks table won't work, because then the existing code is still also looking for the original editwarning_locks table.

My improvised fix for this was to copy the editwarning_locks table to a second mw_editwarning_locks table.

  1. In phpMyAdmin, make sure you're in the editwarning_locks table and click the 'Operations' tab.
  2. Under the "Copy table to (database.table)" section, edit the new table name to mw_editwarning_locks and make sure the "Structure and data" option is selected, and click Go.

If you haven't already done so, make sure you go back to your LocalSettings.php file and add the require_once line:

require_once("$IP/extensions/EditWarning/EditWarning.php");


Final CheckEdit

If your setup is anywhere close to mine, that should have fixed the errors and your EditWarning extension should now be in operational status.

Go over to your MediaWiki install and check to make sure the pages are displaying and that you can click the Edit tab and successfully get to the editing interface. Test it with two users trying to edit the same page and verify that the editing functions are operating properly.

All thanks again to Nemphis for the skills to create this beast in the first place!


Kubernetic (talk) 05:08, 23 November 2013 (UTC)


2017Edit

Update for MediaWiki 1.28.1 availableEdit

I have made a quick'n'dirty port to MediaWiki 1.28.1 https://github.com/nemphis/mw-editwarning/pull/2

A whole message handling should be refactored, but it works for now. Can be pretty insecure - so you have been warned.  « Saper // talk »  21:40, 11 May 2017 (UTC)

2018Edit

These are a few small patches to remove warnings and errors on MediaWiki 1.30 and PHP 7:

diff -Nur mw-editwarning-master/EditWarningMsg.class.php EditWarning/EditWarningMsg.class.php
--- mw-editwarning-master/EditWarningMsg.class.php      2017-05-12 19:51:39.000000000 +0200
+++ EditWarning/EditWarningMsg.class.php        2018-06-06 18:37:40.700989400 +0200
@@ -53,7 +53,7 @@

         $path = $IP . "/extensions/EditWarning/templates";

-        if ( $self->instance[$type] === null ) {
+        if ( !isset(self::$instance[$type]) ) {
             switch ( $type ) {
                 case "ArticleNotice":
                     $params[] = wfMessage( 'ew-leave' )->text();
diff -Nur mw-editwarning-master/EditWarning.php EditWarning/EditWarning.php
--- mw-editwarning-master/EditWarning.php       2017-05-12 19:51:39.000000000 +0200
+++ EditWarning/EditWarning.php 2018-06-06 23:15:56.556478800 +0200
@@ -77,8 +77,10 @@

     if ( isset( $_GET['section'] ) && !isset( $_POST['wpSection'] ) ) {
         return intval( $_GET['section'] );
-    } else {
+    } else if ( isset( $_POST['wpSection'] ) ) {
         return intval( $_POST['wpSection'] );
+    } else {
+       return 0;
     }
 }

@@ -147,7 +149,7 @@

     // Calculate time to wait
     $difference = floatval(abs(time() - $lockobj->getTimestamp()));
-    $time_to_wait = bcdiv($difference, 60, 0);
+    $time_to_wait = round($difference / 60, 0);

     // Parameters for message string
     if ($msgtype == TYPE_ARTICLE || $msgtype == TYPE_SECTION) {
@@ -190,8 +192,8 @@
     }

     if (! defined( 'EDITWARNING_UNITTEST' ) ) {
-        $dbr        =& wfGetDB( DB_SLAVE );
-        $dbw        =& wfGetDB( DB_MASTER );
+        $dbr        = wfGetDB( DB_SLAVE );
+        $dbw        = wfGetDB( DB_MASTER );
     }

     $ew->setUserID( $wgUser->getID() );
@@ -372,7 +374,7 @@
         return true;
     }

-    $dbw =& wfGetDB(DB_MASTER);
+    $dbw = wfGetDB(DB_MASTER);
     $ew->setUserID($wgUser->getID());
     $ew->setArticleID($article->getID());
     $ew->removeLock($dbw);
@@ -391,7 +393,7 @@
     global $wgRequest, $wgUser;

     if( $wgRequest->getVal('cancel' ) == "true") {
-        $dbw =& wfGetDB(DB_MASTER);
+        $dbw = wfGetDB(DB_MASTER);
         $ew->setUserID($wgUser->getID());
         $ew->setArticleID($article->getID());
         $ew->removeLock($dbw);
@@ -414,7 +416,7 @@
  *
  */
 function fnEditWarning_logout($ew, $user) {
-    $dbw =& wfGetDB( DB_MASTER );
+    $dbw = wfGetDB( DB_MASTER );
     $ew->setUserID( $user->getID() );
     $ew->removeUserLocks( $dbw );
Return to "EditWarning" page.