[PATCH] Work around PHP 5.3 limitation (was: Using filebin with PHP 5.3)

eye eye at eyenx.ch
Sat Feb 15 22:45:06 CET 2014


Hi Florian

Thanks. This is working very well.

Kind regards.

Toni




On 15 February 2014 21:14, Florian Pritz <bluewind at xinu.at> wrote:

> $this in anonymous functions is only supported in PHP >= 5.4
>
> Signed-off-by: Florian Pritz <bluewind at xinu.at>
> ---
>
> I don't have a box to test this on, but I guess it should work, please
> test.
>
> This patch is also available in my working branch at git://
> git.server-speed.net/users/flo/filebin
>
>  application/controllers/file.php | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/application/controllers/file.php
> b/application/controllers/file.php
> index 1473643..cb925f4 100644
> --- a/application/controllers/file.php
> +++ b/application/controllers/file.php
> @@ -140,6 +140,7 @@ class File extends MY_Controller {
>
>                 // highlight the file and cache the result
>                 $highlit = cache_function($filedata['hash'].'_'.$lexer,
> 100, function() use ($file, $lexer){
> +                       $CI =& get_instance();
>                         $ret = array();
>                         if ($lexer == "rmd") {
>                                 ob_start();
> @@ -152,11 +153,11 @@ class File extends MY_Controller {
>
>                                 $ret["output"] = ob_get_clean();
>                         } else {
> -                               $ret = $this->_colorify($file, $lexer);
> +                               $ret = $CI->_colorify($file, $lexer);
>                         }
>
>                         if ($ret["return_value"] != 0) {
> -                               $tmp = $this->_colorify($file, "text");
> +                               $tmp = $CI->_colorify($file, "text");
>                                 $ret["output"] = $tmp["output"];
>                         }
>                         return $ret;
> @@ -388,7 +389,8 @@ class File extends MY_Controller {
>                 $cache_key = $filedata['hash'].'_thumb_'.$thumb_size;
>
>                 $thumb = cache_function($cache_key, 100, function() use
> ($id, $thumb_size){
> -                       $thumb = $this->mfile->makeThumb($id, $thumb_size,
> IMAGETYPE_JPEG);
> +                       $CI =& get_instance();
> +                       $thumb = $CI->mfile->makeThumb($id, $thumb_size,
> IMAGETYPE_JPEG);
>
>                         if ($thumb === false) {
>                                 show_error("Failed to generate thumbnail");
> --
> 1.8.5.3
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.server-speed.net/archives/filebin-general/attachments/20140215/f4c0e41c/attachment.html>


More information about the Filebin-general mailing list