#49 Errors generated when configured to not cull cache

open
nobody
None
5
2012-12-06
2008-05-22
Nextline
No

I am encountering some errors when I try to use phpThumb() and configure it to not use any cache culling.

Specifically, I see this: (trying to just paste this in SF, will probably turn out pretty bad)

Notice: Undefined variable: DeletedKeys in /data/oi/htdocs/finntemplates/phpThumb-1.7.8/phpthumb.class.php on line 752

Warning: Invalid argument supplied for foreach() in /data/oi/htdocs/finntemplates/phpThumb-1.7.8/phpthumb.class.php on line 752

Notice: Undefined variable: AllFilesInCacheDirectory in /data/oi/htdocs/finntemplates/phpThumb-1.7.8/phpthumb.class.php on line 755
**Headers already sent in file "/data/oi/htdocs/finntemplates/phpThumb-1.7.8/phpthumb.class.php" on line "752", dumping error message as text:**

phpThumb() v1.7.8-200709161750

Headers already sent (phpThumb.php line 446)

--

Steps to reproduce:
1. Install latest phpThumb() (1.7.8-200709161750).

2. Configure off any cache culling
Set cache_[maxage|maxsize|maxfiles] to null

3. Try to use phpThumb()
For me it works on the second try, so image is generated. However, first request only results in error.

4. ???

5. Profit!

Discussion

  • Nextline
    Nextline
    2008-05-22

    Error message from phpThumb

     
    Attachments
  • Nextline
    Nextline
    2008-05-22

    Logged In: YES
    user_id=2095164
    Originator: YES

    Seems to fix is to just return from the function a couple of lines before the errors starts.
    When you configure phpThumb() to not cull the cache, it logs a message to that effect, then tries to do some statistics, and then it tries to remove empty cache dirs.

    The actions following the the logging statement do not make sense at that point, so my guess is to just return the function after the logging statement.
    Included is a very simple patch that does just that.

    --- phpthumb.class.php.org 2008-05-22 14:35:19.000000000 +0200
    +++ phpthumb.class.php 2008-05-22 14:43:00.000000000 +0200
    @@ -747,6 +747,7 @@

    } else {
    $this->DebugMessage('skipping CleanUpCacheDirectory() because config set to not use it', __FILE__, __LINE__);
    + return true;
    }
    $totalpurged = 0;
    foreach ($DeletedKeys as $key => $value) {
    @@ -3845,4 +3846,4 @@

    }

    -?>
    \ No newline at end of file
    +?>

     
  • Nextline
    Nextline
    2008-05-22

    Patch to remedy this bug

     
  • Nextline
    Nextline
    2008-05-22

    Logged In: YES
    user_id=2095164
    Originator: YES

    SF totally wrangled my text, as was expected.
    The patch is of course completely trivial, but just so I do this the right way, here is the patch attached as a seperate file.
    File Added: phpthumb-no-cull-error.diff