4

ExpressionEngine 2.5.3, Assets 2.0.

I also have a ticket into ElectricPutty's support but they suggested that since Assets is supported natively by BWF now, that I post it here.

When previewing changes to a BWF managed entry, the following PHP warnings are shown in the preview modal:

A PHP Error was encountered Severity: Warning

Message: trim() expects parameter 1 to be string, array given

Filename: libraries/Functions.php

Line Number: 2711

A PHP Error was encountered Severity: Warning

Message: trim() expects parameter 1 to be string, array given

Filename: libraries/Functions.php

Line Number: 2711

A PHP Error was encountered Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /Volumes/Macintosh >HD/Users/iso100/Sites/pbsmartsuite/public_html/_system/codeigniter/system/core/Exceptions.php:170)

Filename: core/Common.php

Line Number: 412

If I save the draft and try to visit the same entry again to edit it, I get a blank page with only this error:

Fatal error: Call to a member function file_id() on a non-object in /Volumes/Macintosh HD/Users/iso100/Sites/pbsmartsuite/public_html/third_party/assets/views/thumbview/files.php on line 15

4
  • I don't think the PHP preview errors are down to Assets, but obviously the 'file_id()' error and you also said the thumbnails were disappearing after a preview Ian?
    – Rob Hodges
    Jan 16, 2013 at 17:09
  • Yes, but I think they were disappearing because of PHP errors possibly causing JS functions to stop working.
    – Ian Pitts
    Jan 16, 2013 at 17:13
  • Thank you Ian. I've sent this one to our devs. I'll make a note to follow up here as well with the answer.
    – Lisa
    Jan 16, 2013 at 17:22
  • Rob tested P&T List for compatibility with BWF and found that it's definitely not compatible either. Since I use that field type in a matrix on the page I tested, it could be the cause too. Here's a link to my support ticket with ElectricPutty: betterworkflow.tenderapp.com/discussions/problems/…
    – Ian Pitts
    Jan 16, 2013 at 17:46

3 Answers 3

4

We'll have an official release out for this shortly, but in the meantime, open up system/expressionengine/third_party/assets/ft.assets.php.

Your line 523 should look like:

foreach ($data as $file_id)
{
    try
    {
        $vars['files'][] = $this->EE->assets_lib->get_file_by_id($file_id);
    }
    catch (Exception $exception)
    {
        // nothing much to do except move on
    }
}

Change it to this and you should be golden:

foreach ($data as $file_id)
{
    if (!empty($file_id))
    {
        $file = $this->EE->assets_lib->get_file_by_id($file_id);

        if ($file !== FALSE)
        {
            $vars['files'][] = $file;
        }
    }
}
3
  • Hi Brad, that works for me!
    – Rob Hodges
    Jan 17, 2013 at 10:27
  • Thanks Brad. Something must be awry with my setup. I'm on Assets 2.0.1 and applied this patch and still get these warnings in the preview: gist.github.com/3e37ea094a792bfa8d3a
    – Ian Pitts
    Jan 17, 2013 at 14:15
  • I'm still seeing these php warnings on BWF1.6.2.1 and Assets 2.1.4 on EE 2.6.1. but the fix above does work - annoying though :) Sep 12, 2013 at 14:28
2

It turns out this was essentially an issue with how the inline preview function in BetterWorkflow functions. I just finished a screen share session with Rob Hodges and the way we resolved the errors was by changing conditional tests on Assets fields from:

{if ov_product_logo_image}

to:

{if '{ov_product_logo_image}' != ''}

I don't know all the details but I'll let Rob comment on the details if he chooses to do so.

Thanks for the help everyone!

2
  • This question is effectively 2 different issues, I'm not sure if an admin can split them into two tickets? The first PHP error was solved by this answer, the second was solved by Brad's answer
    – Rob Hodges
    Jan 17, 2013 at 16:45
  • Oh, drat. I didn't realize that. Yes, it would be good to give credit to both solutions. If you wanted to post a separate resolution with more detail I can choose that as the approved answer.
    – Ian Pitts
    Jan 17, 2013 at 16:48
0

We're up to 2.0.4 and this should no longer be showing up as an issue for you guys. Release Notes here. Thank you!

Your Answer

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

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