Merge "(bug 43801) add a getter for ICU version to ICUCollation"
[lhc/web/wiklou.git] / includes / media / DjVuImage.php
index e2fcaa9..5300947 100644 (file)
  * @ingroup Media
  */
 class DjVuImage {
+       /**
+        * Constructor
+        *
+        * @param string $filename The DjVu file name.
+        */
        function __construct( $filename ) {
                $this->mFilename = $filename;
        }
 
+       /**
+        * @const DJVUTXT_MEMORY_LIMIT Memory limit for the DjVu description software
+        */
+       const DJVUTXT_MEMORY_LIMIT = 300000;
+
        /**
         * Check if the given file is indeed a valid DjVu image file
         * @return bool
@@ -250,9 +260,9 @@ class DjVuImage {
                if ( isset( $wgDjvuTxt ) ) {
                        wfProfileIn( 'djvutxt' );
                        $cmd = wfEscapeShellArg( $wgDjvuTxt ) . ' --detail=page ' . wfEscapeShellArg( $this->mFilename ) ;
-                       wfDebug( __METHOD__.": $cmd\n" );
+                       wfDebug( __METHOD__ . ": $cmd\n" );
                        $retval = '';
-                       $txt = wfShellExec( $cmd, $retval );
+                       $txt = wfShellExec( $cmd, $retval, array(), array( 'memory' => self::DJVUTXT_MEMORY_LIMIT ) );
                        wfProfileOut( 'djvutxt' );
                        if( $retval == 0) {
                                # Strip some control characters