Do not read metadata from non-existing djvu image
authorumherirrender <umherirrender_de.wp@web.de>
Mon, 29 Sep 2014 18:53:43 +0000 (20:53 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Mon, 29 Sep 2014 18:53:43 +0000 (20:53 +0200)
Tests are printing:
*** [1-11711] Failed to open 'some-nonexistent-file': No such file or
directory.
*** (ByteStream.cpp:693)
*** 'DJVU::GUTF8String DJVU::ByteStream::Stdio::init(const DJVU::GURL&,
const char*)'
djvutxt: [1-11711] Failed to open 'some-nonexistent-file': No such file
or directory.
djvutxt: 'ByteStream.cpp:693'

That just spamming the logs, so adding a valid check before do anything.

Change-Id: Ia77377e632587ede76af4c722a1b8ac34fa50e1c

includes/media/DjVuImage.php

index 6ff19c9..596d3e8 100644 (file)
@@ -265,12 +265,16 @@ class DjVuImage {
 
        /**
         * Return an XML string describing the DjVu image
-        * @return string
+        * @return string|bool
         */
        function retrieveMetaData() {
                global $wgDjvuToXML, $wgDjvuDump, $wgDjvuTxt;
                wfProfileIn( __METHOD__ );
 
+               if ( !$this->isValid() ) {
+                       return false;
+               }
+
                if ( isset( $wgDjvuDump ) ) {
                        # djvudump is faster as of version 3.5
                        # http://sourceforge.net/tracker/index.php?func=detail&aid=1704049&group_id=32953&atid=406583