Plugin Directory

Changeset 1074021


Ignore:
Timestamp:
01/23/2015 12:05:13 PM (11 years ago)
Author:
aercolino
Message:

Removed error suppression (@) from eval, thus we can consider the captured output to always carry error information, both if there is a real error, and if there is user output, because we do not automatically serve execution enzymes output anymore.
Removed php_lint because the info it provides is already written into the captured output.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • enzymes/trunk/src/Enzymes3.php

    r1073979 r1074021  
    368368        // We are shutting down, so $error is really the last (fatal) error.
    369369        $error = error_get_last();
    370         echo "\n";
    371         $this->console_log($this->decorate(__('ENZYMES FATAL ERROR'),
    372                 sprintf(__('Fatal error: %1$s on line %2$s'), $error['message'], $error['line'])));
    373         echo "\n";
     370        $this->console_log($this->decorate(__('ENZYMES SHUTDOWN ERROR'),
     371                sprintf(__('%1$s: %2$s on line %3$s.'), Ando_ErrorFactory::to_str($error['type']), $error['message'], $error['line'])));
    374372    }
    375373
     
    390388        $this->last_eval_error = compact('type', 'message', 'file', 'line', 'context');
    391389        return true;  // True to consider the error handled and suppress bubbling.
    392     }
    393 
    394     /**
    395      * Check the syntax of a code snippet.
    396      *
    397      * @param $code
    398      *
    399      * @return mixed|null|string
    400      */
    401     protected
    402     function php_lint( $code )
    403     {
    404         $result = null;
    405         if ( ! function_exists('shell_exec') ) {
    406             return $result;
    407         }
    408         $temp     = tmpfile();
    409         $meta     = stream_get_meta_data($temp);
    410         $filename = $meta['uri'];
    411         fwrite($temp, "<?php $code");
    412         $result = shell_exec("php -n -l $filename");  // -n = no ini, -l = only lint
    413         fclose($temp);
    414 
    415         $result = trim($result);
    416         $result = str_replace("in $filename on", 'on', $result);
    417         $result = str_replace("\nErrors parsing $filename", '', $result);
    418         return $result;
    419390    }
    420391
     
    441412        // -------------------------------------------------------------------------------------------------------------
    442413        try {
    443             $result = @eval($code);
     414            $result = eval($code);
    444415            $error  = $this->last_eval_error;
    445416        } catch ( Exception $e ) {
     
    456427        if ( false === $result ) {
    457428            if ( ! $error instanceof Exception ) {
    458                 $error = $this->php_lint($code);
     429                $error = true; // Assume error info is into $output.
    459430            }
    460431        }
    461         // Notice that error can be null, array, string, or an Exception descendant.
     432        // Note that $error can be true, array, or exception.
    462433        return array($result, $error, $output);
    463434    }
Note: See TracChangeset for help on using the changeset viewer.