3

Matrix version: 2.2.2.1

EE Version: v2.2.2

PHP Version 5.4.13

When I save an image to a File field, it properly saves and publishes the content. But when I return to the entry to Edit it, the matrix file data is gone.

Our server was recently force-migrated which bumped up the PHP version a bit.

Anything else I should check?

3
  • Are you getting any Javascript errors in the dev console? Commented Jul 12, 2013 at 5:57
  • Any solutions? I have the same fault. Just started pretty sure it is a requirement from Matrix for a specific Server side Tech.
    – user2380
    Commented Nov 19, 2013 at 12:25
  • I already used EE 2.7.2 and matrix Matrix 2.5.10 I changed the matrix field to the default GRID field type (yes, I had to reenter all the names; never just change field types!) but unfortunately that had the SAME problem. The mx_input_vars is set to 1000 on my hosting env; maybe that is the problem… I am trying to get this higher.
    – ABDC
    Commented Mar 11, 2014 at 11:49

3 Answers 3

3

In case this helps anyone else out there I fixed it with the same versions of EE (2.2.2) and Matrix (2.2.2.1) as the OP and with php 5.4.x and php5.5.x.

Essentially I did a diff between the latest version of Matrix (2.5.10) and a couple of older ones and tracked it down to these two parts.

File: system/expressionengine/third_party/matrix/celltypes/file.php

Lines: 131 to 143

Replace this:

if ($this->_data_exists($data))
{
  if (is_array($data))
  {
    $filedir = $data['filedir'];
    $filename = $data['filename'];
  }
  else if (preg_match('/^{filedir_([0-9]+)}(.*)/', $data, $matches))
  {
    $filedir  = $matches[1];
    $filename = $matches[2];
  }
}

With this:

if ($data)
{
  if (is_array($data) && ! empty($data['filedir']) && ! empty($data['filename']))
  {
    $filedir = $data['filedir'];
    $filename = $data['filename'];
  }
  else if (is_string($data) && preg_match('/^{filedir_([0-9]+)}(.*)/', $data, $matches))
  {
    $filedir  = $matches[1];
    $filename = $matches[2];
  }
}

File: system/expressionengine/third_party/matrix/ft.matrix.php

Line: 1820

After this: $field_id = $this->settings['field_id'];

Add this:

if (empty($data))
{
  $data = array();
}
2
  • 1
    This worked perfectly for me, was having the same issue on an old build that the client didn't have the budget to update Awesome quick fix - thanks so much!!! Commented Sep 11, 2015 at 17:20
  • Worked perfectly for me too. Thank you!
    – steve
    Commented May 8, 2019 at 0:48
2

Often problems like this are caused by the PHP Suhosin security patch, which has a configuration option to limit the number of POST variables in a single request. If you have a long publish page or lots of matrix fields it is easy to exceed this limit if it's set too low.

The way to check this is to look at your PHP Info (under Tools > Utilities > PHP Info in the CP) and search for Suhosin or configuration options like suhosin.post.max_vars. Ideally this would be set very high (say 2000+).

1

I was having the same issue with the following versions:

EE 2.7.2 Matrix 2.5.9 PHP 5.4.17

Upgrading to Matrix 2.5.10 fixed my issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.