Search code examples
phpdocker-composeubuntu-20.04mediawiki-apimediawiki-visualeditor

How to properly configure the Visual Editor extension installation on MediaWiki (V1.38) with docker-compose and Ubuntu 20.04?


so I explain my problem.

I have a MediaWiki instance in version 1.38 that works perfectly locally. This instance is running with docker-compose. Here is my YAML file:

version: '3.7'
services:
  mediawiki:
    image: myImageMediawiki:1.38.2
    restart: always
    ports:
      - 8090:80
    links:
      - database
      - memcached
    volumes:
      - /home/path/mediawiki/volumes/extensions/PluggableAuth:/var/www/html/extensions/PluggableAuth
      - /home/path/mediawiki/volumes/extensions/LDAPAuthentication2:/var/www/html/extensions/LDAPAuthentication2
      - /home/path/mediawiki/volumes/extensions/LDAPProvider:/var/www/html/extensions/LDAPProvider
      - /home/path/mediawiki/volumes/extensions/LDAPAuthorization:/var/www/html/extensions/LDAPAuthorization
      - /home/path/mediawiki/volumes/extensions/Babel:/var/www/html/extensions/Babel
      - /home/path/mediawiki/volumes/extensions/VisualEditor:/var/www/html/extensions/VisualEditor
      - /home/path/mediawiki/volumes/images:/var/www/html/images
      - /home/path/mediawiki/volumes/LocalSettings.php:/var/www/html/LocalSettings.php
      - /home/path/mediawiki/volumes/ldapprovider.json:/var/www/html/ldapprovider.json
      - /home/path/mediawiki/volumes/php.ini:/usr/local/etc/php/php.ini
      - /home/path/mediawiki/volumes/logo/logo.png:/var/www/html/resources/assets/logo.png
  memcached:
    image: memcached:1.6-alpine
    restart: always
  database:
    image: mariadb:10.5
    restart: always
    volumes:
      - /home/path/mediawiki/volumes/db:/var/lib/mysql
      - /home/path/mediawiki/volumes/initdb:/docker-entrypoint-initdb.d
    environment:
      MYSQL_DATABASE: myDB
      MYSQL_USER: user
      MYSQL_PASSWORD: password
      MYSQL_RANDOM_ROOT_PASSWORD: 'yes'

All my containers run perfectly without any particular errors.

I want to install the VisualEditor plugin in version 1.38. To do this I downloaded the plugin from the official website and I followed the installation tutorial of the official MediaWiki website. I add my extension in the extension folder (as for the other extensions) and add the following lines to my LocalSettings.php file:

wfLoadExtension( 'VisualEditor' );

$wgDefaultUserOptions['visualeditor-enable'] = 1;
$wgDefaultUserOptions['visualeditor-enable-experimental'] = 1;
$wgHiddenPrefs[] = 'visualeditor-enable';
$wgDefaultUserOptions['visualeditor-editor'] = "visualeditor";
$wgGroupPermissions['user']['writeapi'] = true;

Once the plugin is installed I do have the VisualEditor button present. However, as soon as I click on the "Modify" button I get this error:

enter image description here enter image description here

I also looked at the API side. This one is well accessible with the link http://localhost:8091/api.php

enter image description here

But when I look at the call to the endpoint function for editing the page with VisualEditor I have this call:

enter image description here

And I get this response:

{
  "error": {
    "code": "apierror-visualeditor-docserver-http-error",
    "info": "Error contacting the Parsoid/RESTBase server: (curl error: 7) Couldn't connect to server",
    "docref": "See http://localhost:8091/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes."
  }
}

If more information is needed don't hesitate to ask me.


Solution

  • I've found a solution to my problem.

    I have upgraded my MediaWiki version from 1.38 to 1.39 as well as my PHP version. Of course, I upgraded my VisualEditor version to 1.39. However, when I migrated from Php 7.3 to Php 7.4, I had to remove the Mb-string package, which is not compatible with Php 7.4.

    Then I followed the official Mediawiki tutorial on updating the database (with the web browser). However, some files prevented the database from being updated.

    That's why I commented out the contents of these files and mounted them in my container. (Not deleted, just in case)

    • /var/www/html/maintenance/archives/patch-archive-MCR.sql
    • /var/www/html/maintenance/archives/patch-revision-actor-comment-MCR.sql

    These files create indexes, delete indexes that don't exist or create columns or indexes that already exist.

    Then I added the VisualEditor extension to LocalSettings.php and the Parsoid/Restbase service is preconfigured: no need to configure it yourself!

    Everything works perfectly.