Page MenuHomePhabricator

VEForAll not working when $wgVisualEditorParsoidAutoConfig = true
Closed, ResolvedPublic

Description

in REL1_35 VisualEditor my VEForAll breaks when $wgVisualEditorParsoidAutoConfig = true (default value).

i used the following to fix it in my installation ( see /* Start addition */ and /* End addition */), function getVRSObject() in file VEForAll/includes/ApiParsoidUtils.php:

/**

* Create the Parsoid Virtual REST Service object to be used in API calls.

* @return ParsoidVirtualRESTService|null

*/

private function getVRSObject() {

global $wgVirtualRestConfig;

/* Start addition */
global $wgVisualEditorParsoidAutoConfig;
/* End addition */

// the params array to create the service object with

$params = [];

// the global virtual rest service config object, if any

if ( isset( $wgVirtualRestConfig['modules'] ) &&

isset( $wgVirtualRestConfig['modules']['parsoid'] ) ) {

// there's a global parsoid config, use it next

$params = $wgVirtualRestConfig['modules']['parsoid'];

$params['restbaseCompat'] = true;

} 
/* Start addition */
elseif ( $wgVisualEditorParsoidAutoConfig ) {

$params = $wgVirtualRestConfig['modules']['parsoid'] ?? [];

$params['restbaseCompat'] = true;

// forward cookies on private wikis

$params['forwardCookies'] = !MediaWikiServices::getInstance()

->getPermissionManager()->isEveryoneAllowed( 'read' );

}
/* End addition */
else {

return null;

}

// merge the global and service-specific params

if ( isset( $wgVirtualRestConfig['global'] ) ) {

$params = array_merge( $wgVirtualRestConfig['global'], $params );

}

// set up cookie forwarding

if ( $params['forwardCookies'] && !User::isEveryoneAllowed( 'read' ) ) {

$params['forwardCookies'] =

RequestContext::getMain()->getRequest()->getHeader( 'Cookie' );

} else {

$params['forwardCookies'] = false;

}

// create the VRS object

return new ParsoidVirtualRESTService( $params );

}

it is done in a similar way in VisualEditor itself when $wgVisualEditorParsoidAutoConfig = true