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.

Problem with MSM and Safecracker File

June 10, 2011 1:10pm

Subscribe [4]
  • #1 / Jun 10, 2011 1:10pm

    ikiro

    18 posts

    We have an problem with a SafeCracker file field in a SAEF form. We have a MSM setup with EE 2.1.4. The channel where we want to upload the photo is on site_id 1. The form is on site_id 2. We have double checked all the file upload settings and paths and they are ok, rights too. But we get the following error when we open the form.

    A PHP Error was encountered
    Severity: Warning
    Message: preg_match() expects parameter 2 to be string, array given
    Filename: safecracker_file/ft.safecracker_file.php
    Line Number: 75

    After looking at the debug results we think that the file field is ignoring the site_id in the form and because of that the correct path is not found. Does somebody know how we can fix this.

    This is the test form we use, nothing special.

    {exp:safecracker 
    name="add_photoset_form"
    id="add_photoset_form"
    class="form"
    site="pmh"
    channel="section_default_photosets" 
    return="pms/index" 
    safecracker_head="yes"
    include_jquery="no"
    date_picker="no"
    }
    
    <label for="title">Entry Title</label> 
    <input type="text" name="title" id="title" value="{title}" maxlength="75" class="field">
    
    <label for="url_title">URL Title</label> 
    <input type="text" name="url_title" id="url_title" value="{url_title}" maxlength="75" class="field" />
    
    <label for="entry_date">Entry Date</label> 
    <input type="text" name="entry_date" id="entry_date" value="{entry_date}" class="field" />
    
    <label for="status">Status</label> 
    <select name="status" id="status" class="select"> 
    {statuses} 
    <option value="{status}"{selected}>{status}</option> 
    {/statuses} 
    </select>
    
    <h5>Photos</h5>
    <p>{field:def_photos}</p>
    
    <p><br />
    <input type="submit" name="submit" value="Submit" /><br />
    {/exp:safecracker}

  • #2 / Jun 11, 2011 6:20pm

    Greg Salt

    3988 posts

    Hi ikiro,

    Let me try and recreate a similar example to test this out. I’ll get back to you as soon as I can.

    Cheers

    Greg

  • #3 / Jun 11, 2011 6:38pm

    ikiro

    18 posts

    Hi Greg,

    OK sounds great.

    I will give you some extra info about our setup. We have 4 production sites for 3 different countries and they are sharing one product-database. The channels for this product database we have setup on a fifth site. So each country has it’s own SAEF for adding new and edit existing items. Everything is working perfect only managing photos with the safecracker file field or the standard file field gives problems.

    Like I said we did saw in the query that the correct upload preferences are selected only with the wrong site id.

    If you need more info or if you want to login let me know.

    Cheers,
    Ralf

  • #4 / Jun 13, 2011 8:33am

    ikiro

    18 posts

    Hi Greg,

    For you’re info I put here a part of the output profiler results. Mayby it’s helps you

    0.0002      SELECT site_id, site_name FROM exp_sites ORDER BY site_id 
    0.0002      SELECT `site_id`
    FROM (`exp_sites`)
    WHERE `site_name` = 'pmh'
    LIMIT 1 
    0.0000      SELECT `settings`
    FROM (`exp_extensions`)
    WHERE `class` = 'Safecracker_ext'
    LIMIT 1 
    0.0002      SELECT *
    FROM (`exp_channels`)
    WHERE `exp_channels`.`site_id` = '1'
    AND `exp_channels`.`channel_name` = 'section_default_photosets'
    LIMIT 1 
    0.0001      SELECT *
    FROM (`exp_channel_fields`)
    WHERE `group_id` = '13'
    ORDER BY `field_order` 
    0.0001      SELECT *
    FROM (`exp_fieldtypes`) 
    0.0001      SELECT *
    FROM (`exp_statuses`)
    WHERE `group_id` = '1'
    
    ############# At this point the wrong site_id is selected  #############
    
    0.0001      SELECT *
    FROM (`exp_upload_prefs`)
    WHERE `id` = '3'
    AND `site_id` = '2'
    ORDER BY `name`
    
    #############
     
    0.0001      SELECT `channel_id`
    FROM (`exp_channels`)
    WHERE `site_id` = '1' 
    0.0000      SELECT `channel_id`
    FROM (`exp_channels`)
    WHERE `site_id` IN (1) 
    AND `channel_name` = 'section_default_photosets' 
    0.0001      SELECT *
    FROM (`exp_channels`)
    WHERE `channel_id` = '15' 
    0.0001      SELECT *
    FROM (`exp_upload_prefs`)
    WHERE `site_id` = '1'
    ORDER BY `name`
  • #5 / Jun 15, 2011 7:41am

    John Henry Donovan

    12339 posts

    ikiro,

    The channels for this product database we have setup on a fifth site. So each country has it’s own SAEF for adding new and edit existing items. Everything is working perfect only managing photos with the safecracker file field or the standard file field gives problems.

    What happens when you use the standard file field. Do you get a different error.

    Can you double check that you have full server paths for your upload destinations an not just relative paths

    How much PHP memory do you have (seen another thread that this affected)

  • #6 / Jun 15, 2011 11:20am

    ikiro

    18 posts

    Hi John,

    All sites have 256M memory and I have double checked if the server paths are correct. With the default file field I have the same problem. I have a test form and when I use that on the site where the channel is setup it is working perfectly and the photos are uploaded in the correct folder. But when I use this form on a other site I get the error.

    Let me know if you wanna look yourself.

    Greetz,
    Ralf

  • #7 / Jun 16, 2011 7:36pm

    Brandon Jones

    5500 posts

    Hi Ralf,

    I actually get a different issue with our internal 2.2 build, which we’re working on. So I think this particular issue will be resolved in the final 2.2 release, due next week. Thanks for your patience!

  • #8 / Jun 16, 2011 8:01pm

    ikiro

    18 posts

    Hey Brandon,

    For the moment I have solved the problem by using an iframe and load the form in it. So I can wait till it works.

    Thanks anyway
    Ralf

  • #9 / Jun 17, 2011 4:16pm

    Brandon Jones

    5500 posts

    Thanks Ralf,

    I believe we have this taken care of for the 2.2 release so I’ll close this out, but don’t hesitate to start a new thread if anything else comes up!

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

ExpressionEngine News!

#eecms, #events, #releases