Allowed memory exhausted

Issue #20 new
Yann Forget created an issue

Hi,

I got an error message: http://tools.wmflabs.org/magnustools/unused_files.php?category=Photographs+and+images+by+Yann+Forget&depth=1&projects=

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4502480 bytes) in /data/project/magnustools/public_html/unused_files.php on line 68

Comments (3)

  1. Federico Leva

    Thanks for filing, I meant to work on this too because I need the tool in BEIC projects. I can't find the tool in git but I read the source code on tools. The error happens at

    while($o = $result->fetch_object()){
            $unused_files[str_replace ( '_' , ' ' , $o->img_name )] = $o ;
    }
    

    which is quite unexpected. I think the bug is in the SQL query, which fetches way too much data:

    $sql = "SELECT * FROM image WHERE img_name IN ...
    

    I think "SELECT img_name, img_width, img_height" should be enough: memory required for each file should be at worst 300 B or so, while currently a single file can take multiple megabytes I think, considering the img_metadata field. https://www.mediawiki.org/wiki/Manual:Image_table#img_metadata

  2. Log in to comment