ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

File module breaks on no entries in category

April 23, 2014 10:32am

Subscribe [1]
  • #1 / Apr 23, 2014 10:32am

    koosterhout

    4 posts

    Hi,

    I am using this code (within a exp:channel:entries tag) to present images which belong in a particular category:

    {categories show_group="3"}
       {exp:file:entries limit="5" directory_id="2" category="{category_id}"}
          {file_url}
       {/exp:file:entries}
    {/categories}

    When no images are in a certain category this returns notices and errors:

    A PHP Error was encountered
    
    Severity: Notice
    
    Message: Undefined offset: 1
    
    Filename: database/DB_active_rec.php
    
    Line Number: 1724
    
    AND
    
    Error Number: 1052
    
    Column 'site_id' in where clause is ambiguous
    
    SELECT `exp_files`.`file_id`, `variable_name`, `variable_data` FROM (`exp_files`, `exp_global_variables`) INNER JOIN `exp_file_categories` ON `exp_files`.`file_id` = `exp_file_categories`.`file_id` INNER JOIN `exp_categories` ON `exp_file_categories`.`cat_id` = `exp_categories`.`cat_id` WHERE `upload_location_id` = '2' AND `exp_categories`.`cat_id` = '2' AND `site_id` = '1'
    
    Filename: libraries/Template.php
    
    Line Number: 2989

    The easy fix is to go to libraries/Template.php and change line 2988 to:

    ee()->db->where('exp_global_variables.site_id', ee()->config->item('site_id'));

    (adding the tablename)

    The pages do render then, but generate even more notices and a new error:

    Error Number: 1052
    
    Column 'site_id' in where clause is ambiguous
    
    SELECT `exp_files`.`file_id`, `last_cache_clear` FROM (`exp_files`, `exp_stats`) INNER JOIN `exp_file_categories` ON `exp_files`.`file_id` = `exp_file_categories`.`file_id` INNER JOIN `exp_categories` ON `exp_file_categories`.`cat_id` = `exp_categories`.`cat_id` WHERE `upload_location_id` = '2' AND `exp_categories`.`cat_id` = '2' AND `site_id` = '1'
    
    Filename: libraries/Core.php
    
    Line Number: 733

    I can fix this the same way as above, only using exp_files. The notices will not disappear.

    However I am afraid hardcoding this will break other things in EE.

    What is your advice on this?

    EE version: 2.8.1
    File module version: 1.0.0

    —UPDATE—
    Turns out making the changes I did above here indeed breaks other things. Someone please come up with a better idea :(

    —UPDATE 2—
    As temporary fix I commented out the lines I pasted above: 732 in libraries/Core.php and 2988 in libraries/Template.php.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases