MediaWiki扩展Math渲染失败
Jihongchang(讨论 | 贡献)2022年8月10日 (三) 12:12的版本 (建立内容为“万恶的墙!  需要墙外代理才能调用 Wiki 提供的 Restbase 和 Mathoid 服务,LocalSettings.php 中的<syntaxhighlight lang="properties"> // Set Ma…”的新页面)
万恶的墙!
需要墙外代理才能调用 Wiki 提供的 Restbase 和 Mathoid 服务,LocalSettings.php 中的
// Set MathML as default rendering option
$wgDefaultUserOptions['math'] = 'mathml';
$wgMathFullRestbaseURL = 'https://wikimedia.org/api/rest_';
$wgMathMathMLUrl = 'https://mathoid-beta.wmflabs.org';
修改 Math 扩展中的接口调用:MathRestbaseInterface.php 修改函数 getCheckRequest:
        /** 
         * @return array
         * @throws MWException
         */
        public function getCheckRequest() {
                $request = [ 
                                'method' => 'POST',
                                'body'   => [
                                        'type' => $this->type,
                                        'q'    => $this->tex
                                ],  
                                'proxy' => '172.17.0.1:10808',
                                'url'    => $this->getUrl( "media/math/check/{$this->type}" )
                ];  
                return $request;
        }
修改函数 getContentRequest:
        /**
         * @return string
         */
        public function getMathoidStyle() {
                return $this->mathoidStyle;
        }
        /**
         * @param string $type
         * @return array
         * @throws MWException
         */
        private function getContentRequest( $type ) {
                $this->calculateHash();
                $request = [
                        'method' => 'GET',
                        'proxy' => '172.17.0.1:10808',
                        'url' => $this->getUrl( "media/math/render/$type/{$this->hash}" )
                ];
                if ( $this->purge ) {
                        $request['headers'] = [
                                'Cache-Control' => 'no-cache'
                        ];
                        $this->purge = false;
                }
                return $request;
        }
其中的 proxy 声明就是新增的代码