rsanchez / Deep

A set of Eloquent models for ExpressionEngine Channel Entries.
http://rsanchez.github.io/Deep/
MIT License
51 stars 14 forks source link

Files are not loaded from matrix's sometimes..? #21

Closed tobz-nz closed 9 years ago

tobz-nz commented 9 years ago

I've noticed that quite often but not always file fields in a matrix return null when attempting to get the File object. The other fields are accessible, just not file field. The same template with a different entry can work though. I haven't been able to work out what the difference is though.

This matrix in question has :

thumb = file file = file title = text

The column (col_id_99, col_id_100) names are populated, but the named keys (thumb, file) are null

Here is a dump of my entire matrix field object:

object(rsanchez\Deep\Model\MatrixRow)#12906 (21) {
  ["table":protected]=>
  string(11) "matrix_data"
  ["primaryKey":protected]=>
  string(6) "row_id"
  ["hidden":protected]=>
  array(9) {
    [0]=>
    string(7) "site_id"
    [1]=>
    string(8) "entry_id"
    [2]=>
    string(8) "field_id"
    [3]=>
    string(6) "var_id"
    [4]=>
    string(8) "is_draft"
    [5]=>
    string(9) "row_order"
    [6]=>
    string(9) "col_id_99"
    [7]=>
    string(10) "col_id_100"
    [8]=>
    string(10) "col_id_101"
  }
  ["cols":protected]=>
  object(rsanchez\Deep\Collection\MatrixColCollection)#561 (1) {
    ["items":protected]=>
    array(3) {
      [0]=>
      object(rsanchez\Deep\Model\MatrixCol)#569 (20) {
        ["table":protected]=>
        string(11) "matrix_cols"
        ["primaryKey":protected]=>
        string(6) "col_id"
        ["connection":protected]=>
        NULL
        ["perPage":protected]=>
        int(15)
        ["incrementing"]=>
        bool(true)
        ["timestamps"]=>
        bool(true)
        ["attributes":protected]=>
        array(12) {
          ["col_id"]=>
          string(2) "99"
          ["site_id"]=>
          string(1) "1"
          ["field_id"]=>
          string(3) "182"
          ["col_name"]=>
          string(5) "thumb"
          ["col_label"]=>
          string(9) "Thumbnail"
          ["col_instructions"]=>
          string(0) ""
          ["col_type"]=>
          string(4) "file"
          ["col_required"]=>
          string(1) "y"
          ["col_search"]=>
          string(1) "n"
          ["col_order"]=>
          string(1) "0"
          ["col_width"]=>
          string(0) ""
          ["col_settings"]=>
          string(172) "YTo0OntzOjk6ImRpcmVjdG9yeSI7czoxOiI3IjtzOjEyOiJjb250ZW50X3R5cGUiO3M6NToiaW1hZ2UiO3M6MTg6ImZpbGVfc2hvd19leGlzdGluZyI7czoxOiJ5IjtzOjE3OiJmaWxlX251bV9leGlzdGluZyI7czowOiIiO30="
        }
        ["original":protected]=>
        array(12) {
          ["col_id"]=>
          string(2) "99"
          ["site_id"]=>
          string(1) "1"
          ["field_id"]=>
          string(3) "182"
          ["col_name"]=>
          string(5) "thumb"
          ["col_label"]=>
          string(9) "Thumbnail"
          ["col_instructions"]=>
          string(0) ""
          ["col_type"]=>
          string(4) "file"
          ["col_required"]=>
          string(1) "y"
          ["col_search"]=>
          string(1) "n"
          ["col_order"]=>
          string(1) "0"
          ["col_width"]=>
          string(0) ""
          ["col_settings"]=>
          string(172) "YTo0OntzOjk6ImRpcmVjdG9yeSI7czoxOiI3IjtzOjEyOiJjb250ZW50X3R5cGUiO3M6NToiaW1hZ2UiO3M6MTg6ImZpbGVfc2hvd19leGlzdGluZyI7czoxOiJ5IjtzOjE3OiJmaWxlX251bV9leGlzdGluZyI7czowOiIiO30="
        }
        ["relations":protected]=>
        array(0) {
        }
        ["hidden":protected]=>
        array(0) {
        }
        ["visible":protected]=>
        array(0) {
        }
        ["appends":protected]=>
        array(0) {
        }
        ["fillable":protected]=>
        array(0) {
        }
        ["guarded":protected]=>
        array(1) {
          [0]=>
          string(1) "*"
        }
        ["dates":protected]=>
        array(0) {
        }
        ["touches":protected]=>
        array(0) {
        }
        ["observables":protected]=>
        array(0) {
        }
        ["with":protected]=>
        array(0) {
        }
        ["morphClass":protected]=>
        NULL
        ["exists"]=>
        bool(true)
      }
      [1]=>
      object(rsanchez\Deep\Model\MatrixCol)#530 (20) {
        ["table":protected]=>
        string(11) "matrix_cols"
        ["primaryKey":protected]=>
        string(6) "col_id"
        ["connection":protected]=>
        NULL
        ["perPage":protected]=>
        int(15)
        ["incrementing"]=>
        bool(true)
        ["timestamps"]=>
        bool(true)
        ["attributes":protected]=>
        array(12) {
          ["col_id"]=>
          string(3) "100"
          ["site_id"]=>
          string(1) "1"
          ["field_id"]=>
          string(3) "182"
          ["col_name"]=>
          string(4) "file"
          ["col_label"]=>
          string(4) "File"
          ["col_instructions"]=>
          string(0) ""
          ["col_type"]=>
          string(4) "file"
          ["col_required"]=>
          string(1) "y"
          ["col_search"]=>
          string(1) "n"
          ["col_order"]=>
          string(1) "1"
          ["col_width"]=>
          string(0) ""
          ["col_settings"]=>
          string(168) "YTo0OntzOjk6ImRpcmVjdG9yeSI7czoxOiI3IjtzOjEyOiJjb250ZW50X3R5cGUiO3M6MzoiYWxsIjtzOjE4OiJmaWxlX3Nob3dfZXhpc3RpbmciO3M6MToieSI7czoxNzoiZmlsZV9udW1fZXhpc3RpbmciO3M6MDoiIjt9"
        }
        ["original":protected]=>
        array(12) {
          ["col_id"]=>
          string(3) "100"
          ["site_id"]=>
          string(1) "1"
          ["field_id"]=>
          string(3) "182"
          ["col_name"]=>
          string(4) "file"
          ["col_label"]=>
          string(4) "File"
          ["col_instructions"]=>
          string(0) ""
          ["col_type"]=>
          string(4) "file"
          ["col_required"]=>
          string(1) "y"
          ["col_search"]=>
          string(1) "n"
          ["col_order"]=>
          string(1) "1"
          ["col_width"]=>
          string(0) ""
          ["col_settings"]=>
          string(168) "YTo0OntzOjk6ImRpcmVjdG9yeSI7czoxOiI3IjtzOjEyOiJjb250ZW50X3R5cGUiO3M6MzoiYWxsIjtzOjE4OiJmaWxlX3Nob3dfZXhpc3RpbmciO3M6MToieSI7czoxNzoiZmlsZV9udW1fZXhpc3RpbmciO3M6MDoiIjt9"
        }
        ["relations":protected]=>
        array(0) {
        }
        ["hidden":protected]=>
        array(0) {
        }
        ["visible":protected]=>
        array(0) {
        }
        ["appends":protected]=>
        array(0) {
        }
        ["fillable":protected]=>
        array(0) {
        }
        ["guarded":protected]=>
        array(1) {
          [0]=>
          string(1) "*"
        }
        ["dates":protected]=>
        array(0) {
        }
        ["touches":protected]=>
        array(0) {
        }
        ["observables":protected]=>
        array(0) {
        }
        ["with":protected]=>
        array(0) {
        }
        ["morphClass":protected]=>
        NULL
        ["exists"]=>
        bool(true)
      }
      [2]=>
      object(rsanchez\Deep\Model\MatrixCol)#559 (20) {
        ["table":protected]=>
        string(11) "matrix_cols"
        ["primaryKey":protected]=>
        string(6) "col_id"
        ["connection":protected]=>
        NULL
        ["perPage":protected]=>
        int(15)
        ["incrementing"]=>
        bool(true)
        ["timestamps"]=>
        bool(true)
        ["attributes":protected]=>
        array(12) {
          ["col_id"]=>
          string(3) "101"
          ["site_id"]=>
          string(1) "1"
          ["field_id"]=>
          string(3) "182"
          ["col_name"]=>
          string(5) "title"
          ["col_label"]=>
          string(5) "Title"
          ["col_instructions"]=>
          string(0) ""
          ["col_type"]=>
          string(4) "text"
          ["col_required"]=>
          string(1) "n"
          ["col_search"]=>
          string(1) "n"
          ["col_order"]=>
          string(1) "2"
          ["col_width"]=>
          string(0) ""
          ["col_settings"]=>
          string(88) "YTozOntzOjQ6Im1heGwiO3M6MDoiIjtzOjM6ImZtdCI7czo0OiJub25lIjtzOjM6ImRpciI7czozOiJsdHIiO30="
        }
        ["original":protected]=>
        array(12) {
          ["col_id"]=>
          string(3) "101"
          ["site_id"]=>
          string(1) "1"
          ["field_id"]=>
          string(3) "182"
          ["col_name"]=>
          string(5) "title"
          ["col_label"]=>
          string(5) "Title"
          ["col_instructions"]=>
          string(0) ""
          ["col_type"]=>
          string(4) "text"
          ["col_required"]=>
          string(1) "n"
          ["col_search"]=>
          string(1) "n"
          ["col_order"]=>
          string(1) "2"
          ["col_width"]=>
          string(0) ""
          ["col_settings"]=>
          string(88) "YTozOntzOjQ6Im1heGwiO3M6MDoiIjtzOjM6ImZtdCI7czo0OiJub25lIjtzOjM6ImRpciI7czozOiJsdHIiO30="
        }
        ["relations":protected]=>
        array(0) {
        }
        ["hidden":protected]=>
        array(0) {
        }
        ["visible":protected]=>
        array(0) {
        }
        ["appends":protected]=>
        array(0) {
        }
        ["fillable":protected]=>
        array(0) {
        }
        ["guarded":protected]=>
        array(1) {
          [0]=>
          string(1) "*"
        }
        ["dates":protected]=>
        array(0) {
        }
        ["touches":protected]=>
        array(0) {
        }
        ["observables":protected]=>
        array(0) {
        }
        ["with":protected]=>
        array(0) {
        }
        ["morphClass":protected]=>
        NULL
        ["exists"]=>
        bool(true)
      }
    }
  }
  ["connection":protected]=>
  NULL
  ["perPage":protected]=>
  int(15)
  ["incrementing"]=>
  bool(true)
  ["timestamps"]=>
  bool(true)
  ["attributes":protected]=>
  array(108) {
    ["row_id"]=>
    string(4) "8496"
    ["site_id"]=>
    string(1) "1"
    ["entry_id"]=>
    string(4) "4346"
    ["field_id"]=>
    string(3) "182"
    ["row_order"]=>
    string(1) "1"
    ["col_id_1"]=>
    NULL
    ["col_id_2"]=>
    NULL
    ["col_id_3"]=>
    NULL
    ["col_id_4"]=>
    NULL
    ["col_id_5"]=>
    NULL
    ["col_id_6"]=>
    NULL
    ["col_id_7"]=>
    NULL
    ["col_id_8"]=>
    NULL
    ["col_id_9"]=>
    NULL
    ["col_id_10"]=>
    NULL
    ["col_id_11"]=>
    NULL
    ["col_id_12"]=>
    NULL
    ["col_id_13"]=>
    NULL
    ["col_id_14"]=>
    NULL
    ["col_id_15"]=>
    string(1) "0"
    ["col_id_16"]=>
    NULL
    ["col_id_17"]=>
    NULL
    ["col_id_18"]=>
    NULL
    ["col_id_19"]=>
    NULL
    ["col_id_20"]=>
    NULL
    ["col_id_21"]=>
    NULL
    ["col_id_22"]=>
    NULL
    ["col_id_23"]=>
    NULL
    ["col_id_26"]=>
    NULL
    ["col_id_27"]=>
    NULL
    ["col_id_28"]=>
    NULL
    ["col_id_29"]=>
    NULL
    ["col_id_30"]=>
    NULL
    ["col_id_31"]=>
    NULL
    ["col_id_32"]=>
    NULL
    ["col_id_33"]=>
    NULL
    ["col_id_34"]=>
    NULL
    ["col_id_35"]=>
    NULL
    ["col_id_36"]=>
    NULL
    ["col_id_37"]=>
    NULL
    ["col_id_38"]=>
    NULL
    ["col_id_39"]=>
    NULL
    ["col_id_40"]=>
    NULL
    ["col_id_41"]=>
    NULL
    ["col_id_42"]=>
    NULL
    ["col_id_43"]=>
    NULL
    ["col_id_44"]=>
    NULL
    ["col_id_45"]=>
    NULL
    ["col_id_46"]=>
    NULL
    ["col_id_47"]=>
    NULL
    ["col_id_48"]=>
    NULL
    ["col_id_49"]=>
    NULL
    ["col_id_50"]=>
    NULL
    ["col_id_51"]=>
    NULL
    ["col_id_52"]=>
    NULL
    ["col_id_53"]=>
    NULL
    ["col_id_54"]=>
    NULL
    ["col_id_55"]=>
    NULL
    ["col_id_56"]=>
    string(1) "0"
    ["col_id_57"]=>
    NULL
    ["col_id_58"]=>
    NULL
    ["col_id_59"]=>
    NULL
    ["col_id_60"]=>
    NULL
    ["col_id_61"]=>
    NULL
    ["col_id_62"]=>
    NULL
    ["col_id_63"]=>
    NULL
    ["col_id_64"]=>
    NULL
    ["col_id_65"]=>
    NULL
    ["col_id_66"]=>
    NULL
    ["col_id_67"]=>
    NULL
    ["col_id_68"]=>
    NULL
    ["col_id_69"]=>
    NULL
    ["col_id_70"]=>
    NULL
    ["col_id_71"]=>
    NULL
    ["col_id_72"]=>
    NULL
    ["col_id_73"]=>
    NULL
    ["col_id_74"]=>
    NULL
    ["col_id_75"]=>
    NULL
    ["col_id_76"]=>
    NULL
    ["col_id_77"]=>
    NULL
    ["col_id_78"]=>
    NULL
    ["col_id_79"]=>
    NULL
    ["col_id_80"]=>
    NULL
    ["col_id_81"]=>
    NULL
    ["col_id_82"]=>
    NULL
    ["col_id_83"]=>
    NULL
    ["col_id_84"]=>
    NULL
    ["col_id_85"]=>
    NULL
    ["col_id_86"]=>
    NULL
    ["col_id_87"]=>
    NULL
    ["col_id_88"]=>
    NULL
    ["col_id_89"]=>
    NULL
    ["col_id_90"]=>
    NULL
    ["col_id_91"]=>
    NULL
    ["col_id_92"]=>
    NULL
    ["is_draft"]=>
    string(1) "0"
    ["col_id_93"]=>
    NULL
    ["col_id_94"]=>
    NULL
    ["col_id_95"]=>
    NULL
    ["col_id_96"]=>
    NULL
    ["col_id_97"]=>
    NULL
    ["col_id_98"]=>
    NULL
    ["col_id_99"]=>
    string(33) "{filedir_7}1800X1200-BG-GREEN.jpg"
    ["col_id_100"]=>
    string(50) "{filedir_7}700_Series_Manual_Final_12-07-12_LR.pdf"
    ["col_id_101"]=>
    string(19) "This is a test file"
    ["thumb"]=>
    NULL
    ["file"]=>
    NULL
    ["title"]=>
    string(19) "This is a test file"
  }
  ["original":protected]=>
  array(105) {
    ["row_id"]=>
    string(4) "8496"
    ["site_id"]=>
    string(1) "1"
    ["entry_id"]=>
    string(4) "4346"
    ["field_id"]=>
    string(3) "182"
    ["row_order"]=>
    string(1) "1"
    ["col_id_1"]=>
    NULL
    ["col_id_2"]=>
    NULL
    ["col_id_3"]=>
    NULL
    ["col_id_4"]=>
    NULL
    ["col_id_5"]=>
    NULL
    ["col_id_6"]=>
    NULL
    ["col_id_7"]=>
    NULL
    ["col_id_8"]=>
    NULL
    ["col_id_9"]=>
    NULL
    ["col_id_10"]=>
    NULL
    ["col_id_11"]=>
    NULL
    ["col_id_12"]=>
    NULL
    ["col_id_13"]=>
    NULL
    ["col_id_14"]=>
    NULL
    ["col_id_15"]=>
    string(1) "0"
    ["col_id_16"]=>
    NULL
    ["col_id_17"]=>
    NULL
    ["col_id_18"]=>
    NULL
    ["col_id_19"]=>
    NULL
    ["col_id_20"]=>
    NULL
    ["col_id_21"]=>
    NULL
    ["col_id_22"]=>
    NULL
    ["col_id_23"]=>
    NULL
    ["col_id_26"]=>
    NULL
    ["col_id_27"]=>
    NULL
    ["col_id_28"]=>
    NULL
    ["col_id_29"]=>
    NULL
    ["col_id_30"]=>
    NULL
    ["col_id_31"]=>
    NULL
    ["col_id_32"]=>
    NULL
    ["col_id_33"]=>
    NULL
    ["col_id_34"]=>
    NULL
    ["col_id_35"]=>
    NULL
    ["col_id_36"]=>
    NULL
    ["col_id_37"]=>
    NULL
    ["col_id_38"]=>
    NULL
    ["col_id_39"]=>
    NULL
    ["col_id_40"]=>
    NULL
    ["col_id_41"]=>
    NULL
    ["col_id_42"]=>
    NULL
    ["col_id_43"]=>
    NULL
    ["col_id_44"]=>
    NULL
    ["col_id_45"]=>
    NULL
    ["col_id_46"]=>
    NULL
    ["col_id_47"]=>
    NULL
    ["col_id_48"]=>
    NULL
    ["col_id_49"]=>
    NULL
    ["col_id_50"]=>
    NULL
    ["col_id_51"]=>
    NULL
    ["col_id_52"]=>
    NULL
    ["col_id_53"]=>
    NULL
    ["col_id_54"]=>
    NULL
    ["col_id_55"]=>
    NULL
    ["col_id_56"]=>
    string(1) "0"
    ["col_id_57"]=>
    NULL
    ["col_id_58"]=>
    NULL
    ["col_id_59"]=>
    NULL
    ["col_id_60"]=>
    NULL
    ["col_id_61"]=>
    NULL
    ["col_id_62"]=>
    NULL
    ["col_id_63"]=>
    NULL
    ["col_id_64"]=>
    NULL
    ["col_id_65"]=>
    NULL
    ["col_id_66"]=>
    NULL
    ["col_id_67"]=>
    NULL
    ["col_id_68"]=>
    NULL
    ["col_id_69"]=>
    NULL
    ["col_id_70"]=>
    NULL
    ["col_id_71"]=>
    NULL
    ["col_id_72"]=>
    NULL
    ["col_id_73"]=>
    NULL
    ["col_id_74"]=>
    NULL
    ["col_id_75"]=>
    NULL
    ["col_id_76"]=>
    NULL
    ["col_id_77"]=>
    NULL
    ["col_id_78"]=>
    NULL
    ["col_id_79"]=>
    NULL
    ["col_id_80"]=>
    NULL
    ["col_id_81"]=>
    NULL
    ["col_id_82"]=>
    NULL
    ["col_id_83"]=>
    NULL
    ["col_id_84"]=>
    NULL
    ["col_id_85"]=>
    NULL
    ["col_id_86"]=>
    NULL
    ["col_id_87"]=>
    NULL
    ["col_id_88"]=>
    NULL
    ["col_id_89"]=>
    NULL
    ["col_id_90"]=>
    NULL
    ["col_id_91"]=>
    NULL
    ["col_id_92"]=>
    NULL
    ["is_draft"]=>
    string(1) "0"
    ["col_id_93"]=>
    NULL
    ["col_id_94"]=>
    NULL
    ["col_id_95"]=>
    NULL
    ["col_id_96"]=>
    NULL
    ["col_id_97"]=>
    NULL
    ["col_id_98"]=>
    NULL
    ["col_id_99"]=>
    string(33) "{filedir_7}1800X1200-BG-GREEN.jpg"
    ["col_id_100"]=>
    string(50) "{filedir_7}700_Series_Manual_Final_12-07-12_LR.pdf"
    ["col_id_101"]=>
    string(19) "This is a test file"
  }
  ["relations":protected]=>
  array(0) {
  }
  ["visible":protected]=>
  array(0) {
  }
  ["appends":protected]=>
  array(0) {
  }
  ["fillable":protected]=>
  array(0) {
  }
  ["guarded":protected]=>
  array(1) {
    [0]=>
    string(1) "*"
  }
  ["dates":protected]=>
  array(0) {
  }
  ["touches":protected]=>
  array(0) {
  }
  ["observables":protected]=>
  array(0) {
  }
  ["with":protected]=>
  array(0) {
  }
  ["morphClass":protected]=>
  NULL
  ["exists"]=>
  bool(true)
}
rsanchez commented 9 years ago

Is there a way you can send me a DB dump I can test off of? And/or a repo of an I can clone? We can take this offline if you need: info at robsanchez dot com

rsanchez commented 9 years ago

Is it possible those those files ( {filedir_7}1800X1200-BG-GREEN.jpg ) are not in the exp_files table? Might have to sync the file upload destination if not.

tobz-nz commented 9 years ago

I'm thinking about it, yes that could be possible. I'll check first thing Monday. 

— Sent from Mailbox

On Sun, Nov 30, 2014 at 11:43 AM, Rob Sanchez notifications@github.com wrote:

Is it possible those those files ( {filedir_7}1800X1200-BG-GREEN.jpg ) are not in the exp_files table? Might have to sync the file upload destination if not.

Reply to this email directly or view it on GitHub: https://github.com/rsanchez/Deep/issues/21#issuecomment-64968066

rsanchez commented 9 years ago

File cols were not getting hydrated properly in Matrix/Grid fields. Fixed in 1.1.3.

tobz-nz commented 9 years ago

Sweet, all working. Thanks mate - this package is really saving me so time time & hassle. Really appreciate your work.

rsanchez commented 9 years ago

:thumbsup: