Talk:Parsoid

About this board

45.227.131.210 (talkcontribs)

Please post a tutorial for IIS users. Same problem.

Reply to "Any IIS tutorial?"

Working with self-signed SSL certificate?

15
Maiden taiwan (talkcontribs)

Is there a way to tell VisualEditor/Parsoid to work correctly for a wiki with a self-signed SSL cert? Clicking "Edit" in VisualEditor produces the error "Error contacting the Parsoid/RESTBase server: (curl error: 60) Peer certificate cannot be authenticated with given CA certificates." This is on MediaWiki 1.37.1.

I've tried the "insecure http" workaround at https://phabricator.wikimedia.org/T272680 (setting $wgVirtualRestConfig['modules']['parsoid']['url'] = 'http://mywiki.com/w/rest.php'), but the error message remained.

This is a test wiki on my own network, not a production wiki. I'm hoping for a server-side solution, not client-side, since multiple clients connect to this wiki.

Thank you very much.

Arlolra (talkcontribs)

If you set the url to http then there's no certificate to verify, so something didn't quite work out in your testing

Scibearspace (talkcontribs)

Hello all.


I am having the exact same issue with my install of mediawiki. This is a 'private' wiki (only certain users will be able to edit), but the majority of pages will be publicly readable.

Hence the whole site must be working on HTTPS (SSL).


I know however that a large number of the editors will not be impressed if they have to learn mediawiki markup, so the visual editor is a must have.


My set up is as follows.

MediaWiki 1.36.2
PHP 7.4.25 (apache2handler)
MariaDB 10.5.12-MariaDB-0+deb11u1
ICU 67.1
Article path /index.php/$1
Script path /
index.php /index.php
api.php /api.php
rest.php /rest.php


Running on top of the Apache web server, with Debian 11.

I have used the https config as I found it from here : https://askubuntu.com/questions/788658/configuring-apache2-for-mediawiki


I have tried copying the SSL certificates to /etc/ssl/certs on the main part of the server, but I'm sure I have not done this correctly.


I have tried many solutions and have been able to recreate all the errors found in Extension:VisualEditor#Troubleshooting, so much so I can flip between them almost at will !


The solution in my mind would be for the parsoid to be able to verify the authenticity of the server (in this instance itself), I must be able to do this, but where should I place the public and private certificates ?

I am __very__ reluctant to run the wiki over http only. I notice that all the pages can be edited on the various wikimedia sites (including this one) with the visual editor, and they are working on https.

It leads me to question if I should install parsoid / restbase as if I was in a Dev environment.


finaly. I'm quite surprised that there isn't sample config for apache / nginx for working over SSL anywhere in the manual page .... once I get my config figured out, and cut down to the bare required minimum on my dev site I will be very happy to share my config to the manual:install page.


Thanks in advance for you aid in resolving this issue.


David

Arlolra (talkcontribs)

You don't need to run the wiki over http only. You only need to allow http requests to localhost.

Scibearspace (talkcontribs)

I understood that, but running parsoid over http causes the error that I posted above. I'm not getting the local communication to work.


Also when running parsoid over local non SSL communication the address bar says http in it (unlike on this site, and other mediawiki sites) that continue to say https.


I'm sure there is an error in my apache config for the site, specific to parsoid, or in the LocalSettings.php file. Having tried all the various options that are set out in the various threads here, and across the net (OK mabye not all, but a lots of them! ;) ). I continue to end up with the error above, or one of the others on the visual editor : troubleshooting page.


You said in your earlier response to Maiden taiwan that something didn't work out in their testing. do you have any further suggestions for troubleshooting ? I'm not sure what other log files I need to debug the situation fully.


I should say here that I really like mediawiki, its lovely to use, I'm just concerned for my colleagues if they have to edit the source for pages (I know it won't be popular)


Thanks

D

Arlolra (talkcontribs)
Scibearspace (talkcontribs)

Hello Arlolra,


appologies for the slow reply, my dev work is only a part of my main job, and I've been rather 'busy' !


So I can actually use a browser from the local host (headless server). But I can ssh into the server and 'curl' the page you have asked about.


$ curl  http://localhost/rest.php/localhost/v3/page/html/Main%20Page

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

<html><head>

<title>404 Not Found</title>

</head><body>

<h1>Not Found</h1>

<p>The requested URL was not found on this server.</p>

<hr>

<address>Apache/2.4.38 (Debian) Server at localhost Port 80</address>

</body></html>

the same but this time using https ...

curl  https://localhost/rest.php/localhost/v3/page/html/Main%20Page
curl: (60) SSL certificate problem: self signed certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

which is consistent with the problems that I have seen other users have. IT also is why I wonder if I can get the server to 'self verify' somehow (like I do when I ssh into the server, but done locally). I know that the browser will normally store the SSL certificate, so as to 'verify' the server. but how to enable the same for the php commands within parsoid over localhost.

Again, I can confirm that when I run the site without https everything works just fine.


Should I try with a 'dev' version of parsoid (as outlined in Parsoid#Installation). In fact on that page (Parsoid#Linking a developer checkout of Parsoid) it states that :

<blockquote>

Parsoid code is bundled in two different ways: first, Parsoid is included from MediaWiki as a composer library, wikimedia/parsoid </blockquote>

Is this only in the git version ? as I don't find this path on the main mediawiki files that I downloaded. The only folder is the

/extensios/VisualEditor

and this doesn't have the structure as described in the parsoid development pages, which makes it hard to know what I should be modifying.

Appologies this became a longer response that I had anticipated !

David

Ciencia Al Poder (talkcontribs)
Arlolra (talkcontribs)
Scibearspace (talkcontribs)

@Arlolra,


I appreciate your suggestions .... but ...


That would be a problem as all the guides say that web sites should now be served over HTTPS (ie SSL and port 403) and not be using port 80 (which makes lots of sense to me).


When I run the site without SSL (so on port 80 / http) everything is fine, but see above, I want SSL.

The site will have registered users, and I can't have them log in over port 80 sending passwords to my server "in the clear".


@Ciencia Al Poder, that looks interesting, I'll test to see if it works.

Its also given me another idea, can I use a config file for CURL that will cause it to always use the 'insecure' flag, or point to the required certificate to authenticate with ? ... its a facetious question ... Im off to have a look now ...

Scibearspace (talkcontribs)

So there is a default config file for curl :

see : https://everything.curl.dev/cmdline/configfile


this leads to the question for curl as used by mediawiki, is there a local mediwiki config file for php / curl.

My reasoning for this is if the server uses curl in other automated jobs / web apps etc, pointing to this "default config" file may tread on the toes of how CURL works in those other instances.


Can we (cough I) create a config for curl in the LocalSettings.php , or somewhere else in the mediawiki file structure, that would be easily to modified as required.


suggested example :

$wgCurlSSLcert = "/path/to/SSL/cert"

Arlolra (talkcontribs)

My suggestion was to accept connections at port 80 on localhost, not from traffic coming from outside your machine

So, something like <VirtualHost localhost:80> and <VirtualHost mywiki.com:443>

Another option is to use a certificate from https://letsencrypt.org/ instead of self-signing

Scibearspace (talkcontribs)

Arlorla,


Ah sorry, I missunderstood.


That makes sense ... I'll need to look into how to configure apache for that.

I'm guessing something like

<VirtualHost localhost:80>

ServerName wiki.example.com ServerAdmin admin@wiki.example.com

${APACHE_LOG_DIR}/wiki.example.com.error.log CustomLog ${APACHE_LOG_DIR}/wiki.example.com.access.log combined


</VirtualHost>


But my current config has <virtualHost *:80> pushing everything to SSL with Redirect permanent "/" "https://wiki.example.com/"

Do you have any guides on how I can do this, I'm sure its fairly common, but not something I've had to do before.

Once again, thanks in advance, and I fully intend to create a page to document my config once it is working, which I will happily share.

Scibearspace (talkcontribs)

Appologies to anyone following this thread.

I've not found time to work on this ... will report back once I have.

212.68.70.3 (talkcontribs)

tried the <VirtualHost localhost:80> solution, and get:


{"message":"Error: exception of type Wikimedia\\ParamValidator\\ValidationException: Validation of `domain` failed: invalid-domain {\"expected\":\"...

Reply to "Working with self-signed SSL certificate?"

exception of type TypeError: Argument 2 passed to Wikimedia\\Parsoid\\Wt2Html\\TT\\ListHandler::pushList() must be an instance of stdClass, instance of Wikimedia\\Parsoid\\NodeData\\DataParsoid given

4
Summary by SSastry (WMF)

Solved by fixing the installation / upgrade.

Hyperreview (talkcontribs)

I've just upgraded my MediaWiki to 1.38.2 and Visual Editor broke down. I tried a lot of different attempts without success, I've opened various question on StackOverflow but I am lost.


This is the error:

exception of type TypeError: Argument 2 passed to Wikimedia\\Parsoid\\Wt2Html\\TT\\ListHandler::pushList() must be an instance of stdClass, instance of Wikimedia\\Parsoid\\NodeData\\DataParsoid given


This is the error on the wiki: https://www.tematichedigenere.com/rest.php/www.tematichedigenere.com/v3/page/html/Cosa%20c'%C3%A8%20da%20fare%3F/27246


And this is the error trying to click on the Edit button. https://www.tematichedigenere.com/wiki/Guerra_Ucraina_Russia?veaction=edit


What's the easiest way to make the wiki get back working?

Hyperreview (talkcontribs)

Solved by reinstalling the whole folder

SSastry (WMF) (talkcontribs)

So, can I resolve this then?

Arlolra (talkcontribs)
NguoiDungKhongDinhDanh (talkcontribs)

What regex does Parsoid use to catch and parse URLs? I asked at en:WP:VPT and was redirected here.

SSastry (WMF) (talkcontribs)

Autourls and external links are parsed in this PEG grammar block. So, Parsoid doesn't just use a regex for it.

Arlolra (talkcontribs)
NguoiDungKhongDinhDanh (talkcontribs)

Thank you both for answering. I guess I'll just have to learn PHP to figure out the rest.

Use a single Parsoid PHP server for multiple wikis

2
Calebgcooper (talkcontribs)

I am trying to separate restbase and other nodejs apps into separate VMs/containers. I am testing in mediawiki 1.38 and 1.37.


If I configure parsoid host in this form: parsoidHost (restbase config.yaml):

  /parsoid:
    x-modules:
      - path: sys/parsoid.js
        options:
          parsoidHost: "{{'http://{domain}/rest.php'}}"


I get the following error in the log which indicates domain has not been replaced with the correct domain:

"HTTPError","message":"Invalid URI \"http:///%7Bdomain%7D/rest.php/testwiki.wiki.internal/v3/page/pagebundle/Main_Page/20\"","status":504,

The correct url for parsoid should be:


http://testwiki.wiki.internal/rest.php/testwiki.wiki.internal/v3/page/html/Main%20Page/20


This format gives a similar error:

parsoidHost: "{{'http://{$.request.params.domain}/rest.php'}}"


full error 
{"name":"restbase","hostname":"restbase","pid":7192,"level":50,"message":"Invalid URI \"http:///$%7B$.request.params.domain%7D/rest.php/testwiki-fat.wiki.internal/v3/transform/pagebundle/to/wikitext/Main_Page/20\"","res":{"name":"HTTPError","message":"Invalid URI \"http:///$%7B$.request.params.domain%7D/rest.php/testwiki-fat.wiki.internal/v3/transform/pagebundle/to/wikitext/Main_Page/20\"","status":504,"headers":{"content-t
ype":"application/problem+json","access-control-allow-origin":"*","access-control-allow-methods":"GET,HEAD","access-control-allow-headers":"accept, content-type, content-length, cache-control, accept-language, api-user-agent, if-match, if-modified-since, if-none-match, dnt, accept-encoding","access-control-expose-headers":"etag","x-content-type-options":"nosniff","x-frame-options":"SAMEORIGIN","referrer-policy":"origin-when
-cross-origin","x-xss-protection":"1; mode=block","content-security-policy":"default-src 'none'; frame-ancestors 'none'","x-content-security-policy":"default-src 'none'; frame-ancestors 'none'","x-webkit-csp":"default-src 'none'; frame-ancestors 'none'","cache-control":"private, max-age=0, s-maxage=0, must-revalidate","x-request-id":"65e84430-ca39-11ec-80d5-5303b9bf502a","server":"restbase"},"body":{"type":"internal_http_er
ror","detail":"Invalid URI \"http:///$%7B$.request.params.domain%7D/rest.php/testwiki-fat.wiki.internal/v3/transform/pagebundle/to/wikitext/Main_Page/20\"","internalStack":"Error: Invalid URI \"http:///$%7B$.request.params.domain%7D/rest.php/testwiki-fat.wiki.internal/v3/transform/pagebundle/to/wikitext/Main_Page/20\"\n    at Request.init (/var/lib/restbase/node_modules/request/request.js:273:31)\n    at new Request (/var/l
ib/restbase/node_modules/request/request.js:127:8)\n    at Function.request (/var/lib/restbase/node_modules/request/index.js:53:10)\n    at Request._tryUntilFail (/var/lib/restbase/node_modules/requestretry/index.js:124:23)\n    at Factory (/var/lib/restbase/node_modules/requestretry/index.js:178:7)\n    at Request.run (/var/lib/restbase/node_modules/preq/index.js:160:16)\n    at preq (/var/lib/restbase/node_modules/preq/in
dex.js:267:46)\n    at Object.module.exports [as filter] (/var/lib/restbase/node_modules/hyperswitch/lib/filters/http.js:76:12)\n    at handlerWrapper (/var/lib/restbase/node_modules/hyperswitch/lib/hyperswitch.js:420:27)\n    at /var/lib/restbase/node_modules/hyperswitch/lib/hyperswitch.js:426:28\n    at HyperSwitch._filteredRequest (/var/lib/restbase/node_modules/hyperswitch/lib/hyperswitch.js:171:19)\n    at HyperSwitch.
<computed> [as post] (/var/lib/restbase/node_modules/hyperswitch/lib/hyperswitch.js:460:21)\n    at ParsoidService.callParsoidTransform (/var/lib/restbase/sys/parsoid.js:690:40)\n    at /var/lib/restbase/sys/parsoid.js:643:25\n    at tryCatcher (/var/lib/restbase/node_modules/bluebird/js/release/util.js:16:23)\n    at Promise._settlePromiseFromHandler (/var/lib/restbase/node_modules/bluebird/js/release/promise.js:547:31)","
internalURI":"http://${$.request.params.domain}/rest.php/testwiki-fat.wiki.internal/v3/transform/pagebundle/to/wikitext/Main_Page/20","internalQuery":"{}","internalErr":"Invalid URI \"http:///$%7B$.request.params.domain%7D/rest.php/testwiki-fat.wiki.internal/v3/transform/pagebundle/to/wikitext/Main_Page/20\"","internalMethod":"post"},"requestName":"get_from_backend"},"stack":"HTTPError: Invalid URI \"http:///$%7B$.request.p
arams.domain%7D/rest.php/testwiki-fat.wiki.internal/v3/transform/pagebundle/to/wikitext/Main_Page/20\"\n    at /var/lib/restbase/node_modules/preq/index.js:246:19\n    at tryCatcher (/var/lib/restbase/node_modules/bluebird/js/release/util.js:16:23)\n    at Promise._settlePromiseFromHandler (/var/lib/restbase/node_modules/bluebird/js/release/promise.js:547:31)\n    at Promise._settlePromise (/var/lib/restbase/node_modules/bl
uebird/js/release/promise.js:604:18)\n    at Promise._settlePromiseCtx (/var/lib/restbase/node_modules/bluebird/js/release/promise.js:641:10)\n    at _drainQueueStep (/var/lib/restbase/node_modules/bluebird/js/release/async.js:97:12)\n    at _drainQueue (/var/lib/restbase/node_modules/bluebird/js/release/async.js:86:9)\n    at Async._drainQueues (/var/lib/restbase/node_modules/bluebird/js/release/async.js:102:5)\n    at Imm
ediate.Async.drainQueues [as _onImmediate] (/var/lib/restbase/node_modules/bluebird/js/release/async.js:15:14)\n    at processImmediate (node:internal/timers:466:21)","latency":21,"root_req":{"method":"post","uri":"/testwiki-fat.wiki.internal/v1/transform/html/to/wikitext/Main_Page/20","headers":{"content-length":"5758","content-type":"multipart/form-data; boundary=------------------------54315dbeb2b1f7be","if-match":"\"20/
956ec650-ca1d-11ec-b753-6728b9e18a10\"","user-agent":"VisualEditor-MediaWiki/1.38.0-rc.0","api-user-agent":"VisualEditor-MediaWiki/1.38.0-rc.0","x-client-ip":"::ffff:192.168.128.20","x-forwarded-for":"::ffff:192.168.128.20","x-request-id":"65e84430-ca39-11ec-80d5-5303b9bf502a","x-request-class":"external"}},"request_id":"65e84430-ca39-11ec-80d5-5303b9bf502a","levelPath":"error/request","msg":"Invalid URI \"http:///$%7B$.req
uest.params.domain%7D/rest.php/testwiki-fat.wiki.internal/v3/transform/pagebundle/to/wikitext/Main_Page/20\"","time":"2022-05-02T17:00:41.352Z","v":0}


This syntax does work however for the api endpoint and restbase base uri (and is recommended in the docs:

apiUriTemplate: "{{'http://{domain}/api.php'}}"
baseUriTemplate: "{{'http://restbase.wiki.internal:7231/{domain}/v1'}}"


Using curl or web browser this returns the main page as expected:

http://restbase.wiki.internal/testwiki.wiki.internal/v1/page/html/Main_Page


As does the same request directly to parsoid:

http://testwiki.wiki.internal/rest.php/testwiki.wiki.internal/v3/page/html/Main%20Page/20


If I change config.yaml for restbase to use a DNS entry to point all wiki servers to a single wiki for parsoid I get errors like 'Validation of `domain` failed' 
{"message":"Error: exception of type Wikimedia\\ParamValidator\\ValidationException: Validation of `domain` failed: invalid-domain {\"expected\":\"testwiki-a.wiki.internal\",\"actual\":\"testwiki-b.wiki.internal\"}","exception":{"id":"699104fa54c628eaf170cbb0","type":"Wikimedia\\ParamValidator\\ValidationException","file":"/var/lib/mediawiki/vendor/wikimedia/parsoid/extension/src/Rest/Handler/ParsoidHandler.php","line":162,"message":"Validation of `domain` failed: invalid-domain {\"expected\":\"testwiki-a.wiki.internal\",\"actual\":\"testwiki-b.wiki.internal\"}","code":0,"url":"/rest.php/testwiki-b.wiki.internal/v3/page/html/Main%20Page/20","caught_by":"other","backtrace":[{"file":"/var/lib/mediawiki/vendor/wikimedia/parsoid/extension/src/Rest/Handler/ParsoidHandler.php","line":260,"function":"assertDomainIsCorrect","class":"MWParsoid\\Rest\\Handler\\ParsoidHandler","type":"->"},{"file":"/var/lib/mediawiki/vendor/wikimedia/parsoid/extension/src/Rest/Handler/PageHandler.php","line":75,"function":"getRequestAttributes","class":"MWParsoid\\Rest\\Handler\\ParsoidHandler","type":"->"},{"file":"/var/lib/mediawiki/includes/Rest/Router.php","line":414,"function":"execute","class":"MWParsoid\\Rest\\Handler\\PageHandler","type":"->"},{"file":"/var/lib/mediawiki/includes/Rest/Router.php","line":338,"function":"executeHandler","class":"MediaWiki\\Rest\\Router","type":"->"},{"file":"/var/lib/mediawiki/includes/Rest/EntryPoint.php","line":167,"function":"execute","class":"MediaWiki\\Rest\\Router","type":"->"},{"file":"/var/lib/mediawiki/includes/Rest/EntryPoint.php","line":132,"function":"execute","class":"MediaWiki\\Rest\\EntryPoint","type":"->"},{"file":"/var/lib/mediawiki/rest.php","line":31,"function":"main","class":"MediaWiki\\Rest\\EntryPoint","type":"::"}]},"httpCode":500,"httpReason":"Internal Server Error"}


Clearly it is not allowed for one wiki to parse text for another. Is there a flag to change this behavior perhaps?


So either I need to figure out how to get restbase to dynamically create the correct URL or how to configure a parsoid php server to respond for other wiki sites.


I have no problem getting restbase and parsoid working when everything is in the same container/VM.

Calebgcooper (talkcontribs)
Here is my full config.yaml 
bash-5.1# cat restbase/config.yaml
#
# Simple RESTBase config for Mediawiki Container
# https://www.mediawiki.org/wiki/RESTBase/Installation
#
# - cassandra DB
# - parsoid at http://localhost/rest.php
# - wiki at http://testwiki.wiki.internal/api.php
#
# - proxied via nginx, available via
# - http://hostname/api/rest_v1/
#
services:
  - name: restbase
    module: hyperswitch
    conf:
      port: 7231
      salt: 988881adc9fc3655077dc2d4d757d480b5ea0e11
      default_page_size: 125
      user_agent: RESTBase
      ui_name: RESTBase
      ui_url: https://www.mediawiki.org/wiki/RESTBase
      ui_title: RESTBase docs
      spec:
        x-request-filters:
          - path: lib/security_response_header_filter.js
          - path: lib/normalize_headers_filter.js
        x-sub-request-filters:
          - type: default
            name: http
            options:
              allow:
                - pattern: /^https?:\/\//
        paths:
          /{domain}/{api:v1}:
            x-modules:
              - spec:
                  info:
                    version: 1.0.0
                    title: Wikimedia REST API
                    description: Welcome to your RESTBase API.
                  x-route-filters:
                    - path: ./lib/normalize_title_filter.js
                      options:
                        redirect_cache_control: 's-maxage=0, max-age=86400'
                  paths:
                    /page:
                      x-modules:
                        - path: v1/content.yaml
                          options:
                            response_cache_control: 's-maxage=0, max-age=86400'
                        - path: v1/content_segments.yaml
                          options:
                            response_cache_control: 's-maxage=0, max-age=86400'
                        - path: v1/common_schemas.yaml
                        - path: v1/summary.js
                        - path: v1/related.js
                        - path: v1/random.yaml
                        - path: v1/pdf.js
                          options:
                            uri: http://restbase.wiki.internal:3030
                            secret: secret
                    /transform:
                      x-modules:
                        - path: v1/transform.yaml
                    /media:
                      x-modules:
                        - path: v1/mathoid.yaml
                          options:
                            host: http://restbase.wiki.internal:10042
                    /data:
                      x-modules:
                        - path: v1/citoid.js
                          options:
                            host: http://restbase.wiki.internal:1970
                        - path: v1/lists.js
                        - path: v1/recommend.yaml
                        - path: v1/javascript.yaml
                        - path: v1/css.yaml

          /{domain}/{api:sys}:
            x-modules:
              - path: projects/proxy.yaml
                options:
                  backend_host_template: '{{"/{domain}/sys/legacy"}}'
              - spec:
                  paths:
                    /table:
                      x-modules:
                        - path: sys/table.js
                          options:
                            conf:
                              version: 1
                              backend: cassandra
                              hosts:
                                - cassandradb
                              pool_idle_timeout: 20000
                              retry_delay: 250
                              retry_limit: 10
                              show_sql: false
                              keyspace: system
                              defaultConsistency: localOne
                              localDc: datacenter1
                              datacenters:
                                - datacenter1
                              storage_groups:
                                - name: local
                                  domains: /./
                    /legacy/key_value:
                      x-modules:
                        - path: sys/key_value.js
                    /legacy/page_revisions:
                      x-modules:
                        - path: sys/page_revisions.js
                    /post_data:
                      x-modules:
                        - path: sys/post_data.js
                    /action:
                      x-modules:
                        - path: sys/action.js
                          options:
                            apiUriTemplate: "{{'http://{domain}/api.php'}}"
                            baseUriTemplate: "{{'http://restbase.wiki.internal:7231/{domain}/v1'}}"
                    /page_save:
                      x-modules:
                        - path: sys/page_save.js
                    /events:
                      x-modules:
                        - path: sys/events.js
                    /parsoid:
                      x-modules:
                        - path: sys/parsoid.js
                          options:
                            parsoidHost: "{{'http://{domain}/rest.php'}}"
                            grace_ttl: 1000000
                    /mathoid:
                      x-modules:
                        - path: sys/mathoid.js
                          options:
                            host: "{{'http://restbase.wiki.internal:10042'}}"


# Finally, a standard service-runner config.
info:
  name: restbase

logging:
  name: restbase
  level: warn
  streams:
    - type: stdout


num_workers: 0

bash-5.1#


I found this page but it is for parsoid js, if there was an equivalent for parsoid php it would be very helpful: https://www.mediawiki.org/wiki/Parsoid/Setup/RESTBase/Arbitrary_domains

Reply to "Use a single Parsoid PHP server for multiple wikis"

mediawiki 1.37.1 Error contacting the Parsoid/RESTBase server: (curl error: 7) Couldn't connect to server

17
Summary by Arlolra
GCTWorks (talkcontribs)

After upgrading to MediaWiki 1.37.1, I can no longer use the visual editor. The loading box pops up and then gives me the following error:


Error contacting the Parsoid/RESTBase server: (curl error: 7) Couldn't connect to server


I am not even sure how to diagnose this. I spent about 4 hours on the Google trying to find solutions. None seemed to work or were even applicable. Any help would be appreciated?


I am running:

Ubuntu Server 20.04.3 as a VM

Apache 2.4.41

PHP 7.4.3

MariaDB 10.5.13 (not local)

Arlolra (talkcontribs)

Can you paste your Parsoid configuration from your LocalSettings.php

The first step is to isolate Parsoid and see if that works on its own

GCTWorks (talkcontribs)

I am not sure my LocalSetting.php file has the configuration you are talking about. I did a text search for "parsoid" and nothing came up.

Arlolra (talkcontribs)
GCTWorks (talkcontribs)

I do not have this in my LocalSettings.php file. I basically have a near Out of the Box LocalSettings.php file except some additional $wgFileExtensions appended to the end. All of the was working fine in 1.37.0. I will try adding this later.

Is this something I need to do because my LocalSettings.php is from my initial install at 1.36.2 or 1.36.3? The upgrade to 1.37.0 went fine.

Arlolra (talkcontribs)
GCTWorks (talkcontribs)

It does up once for a Docker install. I am not using Docker. Just a native install.

Arlolra (talkcontribs)

An error is being reported by curl. My suggestion would be to log those errors and see what url it's trying to access.

GCTWorks (talkcontribs)

Apologies, but how do I do that? I did some googling, but I was not successful in finding the logs for that error.

Arlolra (talkcontribs)
GCTWorks (talkcontribs)

Okay. Here is what I think are the two pertinent log lines, obfuscated for security:

[http] HTTP start: GET https://mywiki.my.domain/rest.php/mywiki.my.domain/v3/page/html/Main_Page/3?redirect=false&stash=true

[http] Error fetching URL "https://mywiki.my.domain/rest.php/mywiki.my.domain/v3/page/html/Main_Page/3?redirect=false&stash=true": (curl error: 7) Couldn't connect to server


I do not know enough about how it is supposed to work to know what might be wrong

Arlolra (talkcontribs)

What happens when you visit that url directly, say in a browser

GCTWorks (talkcontribs)

I get the following:

{"error":"rest-read-denied","httpCode":403,"httpReason":"Forbidden"}

Arlolra (talkcontribs)

That's a different error. You connected but didn't forward a cookie so don't have permission to access the api. But it shows that you can connect to the endpoint.

The curl error says that MediaWiki can't connect, which means that it is probably having a hard time resolving the right address for your domain. That is indeed similar to the docker issue linked to before at https://www.mediawiki.org/wiki/Extension:VisualEditor#Troubleshooting

GCTWorks (talkcontribs)

Oh okay. So, I think you are correct in that it might be similar. I did not realize it until you mentioned it, the hostname of my server is the same as the "mywiki" part of mywiki.my.domain. Let me change the hostname and retest. I will follow-up with the results.

GCTWorks (talkcontribs)

Okay. That did the trick. Interesting that this was not an issue before I upgraded. How can I help to get that docker issue text updated to reflect my circumstances as well? I bet this would help some people.


Also, thank you so much for helping me! I really appreciate it considering I am a bit of n00b.

Arlolra (talkcontribs)

mediawiki.org is a wiki, please just edit the page as you see fit

Parsoid is not converting piped wiki links to html correctly

3
Summary by Ammcgillivray

The problem was user error.

Ammcgillivray (talkcontribs)

Versions

  • Mediawiki: 1.34.4
  • Node.js: 8.11.11
  • Parsoid: 0.11.0
  • OS: CentOS 7.9.2009

Issue

I am currently using Parsoid to convert wikitext to html. However, when I have an inter-wiki link that includes a pipe such as [[Main Page|test 123]], Parsoid converts it to href="http://127.0.0.1:8080/wiki1/Main_Pagetest_123" title="Main Pagetest 123" (omitting some of the other html output for the link)

If anyone has any understand why this is happening or how to work around it, I'd really appreciate it!

Arlolra (talkcontribs)

Odd. Is it actually a vertical bar or some other unicode character?

Does it happen on the command line as well? echo "test 123" | node bin/parse.js

Ammcgillivray (talkcontribs)

Oh my goodness, this is 100% user error. It does work from the command line. The reason it doesn't work from inside my program is because I was stripping pipe characters from the text being converted 🤦‍♀️

False alarm. Thank you for your help and quick response time that allowed me to spot my own idiocy!

Alternative value for $wgServer in Docker (Linux)

1
Summary by Arlolra
217.18.182.130 (talkcontribs)

// While using Docker in macOS, you may need to replace $wgServer with http: //host.docker.internal:8080

'url' => $wgServer . $wgScriptPath . '/rest.php',

I found out that http: //container_name for $wgServer is also working.

In my specific case I am also using HTTP Auth globally for the wiki instance, so I'm using http: //user:password@container_name.

Error loading data from server

2
Summary by Arlolra

User disappeared

JJ245-AA (talkcontribs)

Hello everyone!

I installed parsoid successfully. I was able to use the visual editor to edit a page at first but the second time I try to edit it I get the following error -

Error loading data from server: apierror-visualeditor-docserver-http: HTTP 404. Would you like to retry?


Any help would be greatly appreciated!!

Thanks

Arlolra (talkcontribs)

Can you provide some more information about the wiki and how it's configured?

expand templates locally

7
Summary by Arlolra

Import templates to your wiki

111.125.208.58 (talkcontribs)

I have mediawiki and parsoid setup locally

I am trying to expand templates locally, while coverting from wikitetx to HTML. But templates remain as it is.

can anyone suggest where i am going wrong

Arlolra (talkcontribs)

Are the templates defined in your local mediawiki instance?

111.125.208.58 (talkcontribs)

How to do it,

I have enabled few extensions like ParserFunctions, Scribunto, to expand templates.

I am trying to convert "{{Convert|907|hp|kW PS|0|abbr=on}}" --> "907 hp (676 kW; 920 PS)" but i get output as "Template:Convert"


Arlolra (talkcontribs)

You need to create a page on your local wiki, //localhost/wiki/Template:Convert, or whathaveyou.

You can copy the source from enwiki, https://en.wikipedia.org/w/index.php?title=Template:Convert&action=edit

Although, that seems to invoke a Scribunto module, so you'll also need a //localhost/wiki/Module:Convert as well.

Again, the source can be copied from, https://en.wikipedia.org/w/index.php?title=Module:Convert&action=edit

Alternatively, depending on how you're planning on using the tool, you can set --domain en.wikipedia.org to use the templates defined there, but then you won't have access to the pages on your local wiki.

SSastry (WMF) (talkcontribs)
111.125.208.58 (talkcontribs)

@Arlolra and @SSastry (WMF) Thanks for guidinig me through the solution,

Another question has arised to me, likewise i have multiple templates which i need to expand while converting from wikitext to HTML. So manual importing of each template could be cumbersome. Is there a way to download all the template dumps at once and then import to local mediwaiki.

Arlolra (talkcontribs)

Again, you might want to consider parsing with --domain en.wikipedia.org or wherever you're getting this content from, rather than your local wiki

There are larger project dumps you can import at https://meta.wikimedia.org/wiki/Data_dumps