Jump to content

Extension:QuestyCaptchaEditor

From mediawiki.org
MediaWiki extensions manual
QuestyCaptchaEditor
Release status: experimental
Implementation Special page , Database
Description Adds a special page via which privileged users can administrate QuestyCaptcha questions and their answers
Author(s)
Latest version 1.1 (2023-02-02)
MediaWiki 1.35-1.39+
Database changes Yes
Tables questycaptcha_answers
questycaptcha_questions
License GNU General Public License 2.0 or later
Download git.legoktm.com
  • edit-captchas

QuestyCaptchaEditor is an on-wiki special page interface for managing QuestyCaptcha questions and their answers.

Privileged users can view the list of existing CAPTCHA questions and their correct answers on Special:QuestyCaptchaEditor and use this special page to add and delete questions and their answers. (While direct editing of existing question+answer(s) pairings isn't supported as of version 1.1, you can delete a question and then readd it to functionally "edit" it.)

Actions taken via the special page are logged to Special:Log/captcha; access to this log is restricted only to privileged users (those who have the same edit-captchas user right needed to access the QuestyCaptchaEditor special page).

Do note that since this extension needs a core hack, you will need to reapply that after each MediaWiki upgrade to a major new version of MediaWiki to keep your wiki operating.

Install

[edit]

Prior to installing the extension, you will need to patch a MediaWiki core file. This is needed because otherwise QuestyCaptchaEditor will not be able to properly overwrite the value of $wgCaptchaClass configuration variable and this will result in an exception being thrown, which thus breaks the wiki and we don't want that.

Apply the needed MediaWiki core hack

[edit]
  1. Open includes/registration/ExtensionProcessor.php in your favorite text editor
  2. Find the function addConfigGlobal
  3. Change the line if ( array_key_exists( $key, $this->globals ) ) { to if ( array_key_exists( $key, $this->globals ) && $key !== 'wgCaptchaClass' ) {
  4. (Optional but strongly recommended) Add a // single-line comment or /* multi-line comment */ explaining the patch, for example:
// CORE HACK for https://www.mediawiki.org/wiki/Extension:QuestyCaptchaEditor
if ( array_key_exists( $key, $this->globals ) && $key !== 'wgCaptchaClass' ) {
// END CORE HACK

5. Save changes to the file

Check out the extension via git

[edit]

Go to your wiki's extensions directory and run:
git clone https://git.legoktm.com/ashley/QuestyCaptchaEditor.git

Edit LocalSettings.php to load QuestyCaptchaEditor

[edit]

Add something like the following to the wiki's LocalSettings.php file:

wfLoadExtensions( [
	'ConfirmEdit',
	'ConfirmEdit/QuestyCaptcha',
	'QuestyCaptchaEditor'
] );

Ensure that QuestyCaptchaEditor is loaded after the base ConfirmEdit includes!

Create the new database tables

[edit]

Re-run the MediaWiki core updater script, maintenance/update.php, to have it create the two new, necessary database tables, questycaptcha_questions and questycaptcha_answers.

All three major DBMSes—MySQL/MariaDB, PostgreSQL and SQLite—should be supported, though support for the latter two hasn't been tested but it's present.

Done!

[edit]

That's it. You should now be able to use the Special:QuestyCaptchaEditor special page as a privileged user.

Legacy support

[edit]

If the $wgCaptchaQuestions variable is set in the wiki's LocalSettings.php file, questions and answers from it will override those specified on Special:QuestyCaptchaEditor and the variable should be removed or commented out from LocalSettings.php to make proper use of Special:QuestyCaptchaEditor.

User rights

[edit]

The new user right edit-captchas, given to the administrator (sysop) user group by default, is needed to access Special:QuestyCaptchaEditor and the restricted log of actions taken via that page at Special:Log/captcha.

Internationalization support

[edit]

The extension is fully internationalizable. As of version 1.1, the following languages are supported:

  • English (en)
  • Finnish (fi)

While the Special:QuestyCaptchaEditor special page supports adding question+answer(s) pairings in languages other than the wiki's content language, only the pairs in the wiki's content language will be currently used by the code (see includes/QuestyCaptchaDB.php). In the future, this will probably change so that the uselang URL parameter is properly supported to support wikis with multiple supported languages (e.g. Wikimedia Commons, Wikimedia Meta-Wiki, etc.).

Known bugs/missing features/etc.

[edit]
  1. No pagination on Special:QuestyCaptchaEditor
  2. The special page UI is literally from 2006-2007 and thus not responsive, uses <table>s, and so on
  3. The functional fix done in version 1.1 to properly support questions with multiple correct answers is unnecessarily inefficient and needs fixing ASAP