更新MediaWiki扩展,file_exists()

时间:2015-06-08 07:35:59

标签: php mediawiki mediawiki-extensions

我正在将我们的系统更新为新的MediaWiki(从1.18.3到1.25.1)

我们有一个扩展,它将.gnumeric文件呈现为html,以便我们可以显示它。

以下代码已针对新版本重新编写

class GnumericImage extends MediaTransformOutput {
    function GnumericImage( $file, $url, $path = false, $page = false ) {
            $this->file = $file;
            $this->url = $url;
            # These should be integers when they get here.
            # If not, there's a bug somewhere.  But let's at
            # least produce valid HTML code regardless.
            $this->path = $path;
            $this->page = $page;
    }

    //... <snip> ...

    // MEMBER OF GnumericImage
    function toHtml( $options = array() ) {
        $src = $this->file->getPath();
        $dst = $this->getStoragePath(); // was $this->getPath();

        if($this->file->exists()) {
            exec("LC_ALL=nl_NL.UTF-8 /usr/bin/ssconvert \"$src\" \"$dst\" > /dev/null");

            echo($dst);

            // This line errors
            // Converting might fail so check if there is a file
            if(! file_exists($dst)) return("ssconvert failed");

            $data = file_get_contents($dst);
            // ... MORE CODE TO DISPLAY RESULT ...
        }
    }

使用file_exists($dst)会出错:

Warning: file_exists(): Unable to find the wrapper "mwstore" 
- did you forget to enable it when you configured PHP? 
in /var/www/engineering/extensions/Gnumeric/Gnumeric.php on line 72

$dst包含:mwstore://local-backend/local-thumb/c/ca/file_name/-file_name.html

1 个答案:

答案 0 :(得分:0)

$src$dst中的路径是mediawiki路径。更改文件系统路径的路径可以解决问题。

$src = $this->file->getLocalRefPath();
$dst = $this->getLocalCopyPath();