We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

TinyMCE LG Plugin: PHP error when publishing entries

Development and Programming

phatphug's avatar
phatphug
31 posts
16 years ago
phatphug's avatar phatphug

I recently upgraded to v1.6.5, build 20081024.

I’ve just noticed that when publishing a new weblog entry, the following php error occurs:

Warning: Typography::require_once(./sPAbr3n7swez8rAPhe2EST66u5epezUC/plugins/pi..php) [function.Typography-require-once]: failed to open stream: No such file or directory in /home/inflex/public_html/dev/sPAbr3n7swez8rAPhe2EST66u5epezUC/core/core.typography.php on line 464

Fatal error: Typography::require_once() [function.require]: Failed opening required './sPAbr3n7swez8rAPhe2EST66u5epezUC/plugins/pi..php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/inflex/public_html/dev/sPAbr3n7swez8rAPhe2EST66u5epezUC/core/core.typography.php on line 464

I’ve done a bit of debugging and have noticed that the function parse_type($str, $prefs = ”) in core.typography.php is being called with the following $prefs value:

Array
(
    [text_format] => 
    [html_format] => all
    [auto_links] => n
    [allow_img_url] => y
)

I’m guessing text_format should not be empty, and this is the reason that the line 464 of core.typography.php fails later:

require_once PATH_PI.'pi.'.$prefs['text_format'].EXT;

Note: The field in my publish form which appears to cause this error has a ‘field_fmt’ value of ‘none’ (in the exp_weblog_fields table)

Additionally, when digging through the DB I’ve noticed that new entries to the field_ft_X fields are being given values of NULL instead of their actual field type.

Can anyone suggest what I can try next to find the cause of this problem?

Moved to Plugins: Discussion and Questions by Moderator

       
Robin Sowell's avatar
Robin Sowell
13,160 posts
16 years ago
Robin Sowell's avatar Robin Sowell

Can you look at the db schema for your exp_weblog_fields table and double check field_fmt- should be: field_fmt varchar(40) NOT NULL default ‘xhtml’.

I’m going to go do a test run real quick, see if I can replicate on the latest build.

       
Robin Sowell's avatar
Robin Sowell
13,160 posts
16 years ago
Robin Sowell's avatar Robin Sowell

Hm- I can’t replicate. The default is ‘none’, but when I select that field type, it goes in properly. I wonder if you’re using an extension that relied on the default being set instead of ‘None’. Any extensions in play?

       
phatphug's avatar
phatphug
31 posts
16 years ago
phatphug's avatar phatphug

Thanks for the quick response Robin.

I’ve check the DB and the field_fmt field is: Type: varchar(40) Collation: utf8_general_ci Null: No Default: xhtml

I believe those settings are all correct.

As for extensions I’m using: - File, by Mark Huot - jQuery for Control Panel - LG TinyMCE Custom Field - REEOrder - Playa

The custom field where this error is coming from is actually an LG TinyMCE ‘WYSIWYG’ type field with formatting set to ‘none’. Do you think it could be something to do with that?

       
phatphug's avatar
phatphug
31 posts
16 years ago
phatphug's avatar phatphug

Debugging through the code again. I think the issue is that the $prefs parameter of the parse_type function is not set.

Array
(
    [text_format] => 
    [html_format] => all
    [auto_links] => n
    [allow_img_url] => y
)

Therefore the following happens:

/** -------------------------------------
/**  Set up our preferences
/** -------------------------------------*/
if (is_array($prefs)) // -- true
{
   if (isset($prefs['text_format'])) // -- false
   {
      ...
   }
}

This means that the $this->text_format variable is not set to ‘none’, so later on at this switch, the default case runs (instead of the none case):

/** -------------------------------------
/**  Format text
/** -------------------------------------*/
switch ($this->text_format)
{
case 'none';
    break;
case 'xhtml'    : $str = $this->auto_typography($str);
    break;
case 'lite'        : $str = $this->format_characters($str);  // Used with weblog entry titles
    break;
case 'br'        : $str = $this->nl2br_except_pre($str);
    break;
default            :

...
}

Normally the program flow show have breaked up at case ‘none’;

I’m not sure why $prefs[‘text_format’] is not being set in this case.

       
phatphug's avatar
phatphug
31 posts
16 years ago
phatphug's avatar phatphug

Sorry to keep bombarding with posts…

I think I can explain why the ‘text_format’ value is not being set:

At line 8608 of cp.publish.php we have:

$r .= $TYPE->parse_type( stripslashes($result->row[$key]), 
 array(
            'text_format'   => $result->row['field_ft_'.$expl['1']],
            'html_format'   => $weblog_html_formatting,
            'auto_links'    => $weblog_auto_link_urls,
            'allow_img_url' => $weblog_allow_img_urls,
       )
);

Note: ‘field_ft_’.$expl[‘1’] equals to: field_ft_7

I’ve noticed that all new entries to the field_ft_7 field in exp_weblog_data are being set to NULL. (infact this is happening to all custom fields)

So the issue must be that when a new record is being inserted into exp_weblog_data, all field_ft_X fields are set to NULL, instead of ‘none’/’xhtml’/etc.

Do you know where in the code the insert to the exp_weblog_data table happens? I’m getting lost in code here 😊

       
phatphug's avatar
phatphug
31 posts
16 years ago
phatphug's avatar phatphug

Cracked it! I traced it back to the TinyMCE LG Plugin, as I noticed it hadn’t included a field_ft_X hidden field on the publish form.

Added this line to fix:

$r .= $DSP->input_hidden("field_ft_" . $row['field_id'], $row["field_fmt"]);

I’m not sure if this was fixed in a newer release of the plugin, as I just noticed I’m running an old version.

       
Robin Sowell's avatar
Robin Sowell
13,160 posts
16 years ago
Robin Sowell's avatar Robin Sowell

Ha- you’re fast. And making my job very easy. Yep- the problem is the null in the field. Which boils down to a problem with the plugin. But it’s possible there was a bit of a change in field creation which contributed to the plugin breaking. Haven’t tracked it down to see if that’s the case.

Try upgrading the plugin- let me know if this solves the issue for you. And- put something other in those NULL fields- likely ‘none’ if I had to bet.

       
phatphug's avatar
phatphug
31 posts
16 years ago
phatphug's avatar phatphug

For anyone else who has this issue…

I’ve just tried out the new version (1.3.2) of LG’s plugin. The same issue is there too.

I had to modify:

function publish_form_field_unique( $row, $field_data )
{
    global $DSP, $EXT, $SESS;

    // -- Check if we're not the only one using this hook
    $r = ($EXT->last_call !== FALSE) ? $EXT->last_call : '';

    if($row["field_type"] == $this->type)
    {
        $r .= $DSP->input_textarea("field_id_" . $row['field_id'], $field_data, $row['field_ta_rows'], 'lg_mceEditor', '99%');
        $SESS->cache['lg'][LG_TMC_addon_id]['require_scripts'] = TRUE;
    }

    return $r;
}

to:

function publish_form_field_unique( $row, $field_data )
{
    global $DSP, $EXT, $SESS;

    // -- Check if we're not the only one using this hook
    $r = ($EXT->last_call !== FALSE) ? $EXT->last_call : '';

    if($row["field_type"] == $this->type)
    {
        $r .= $DSP->input_textarea("field_id_" . $row['field_id'], $field_data, $row['field_ta_rows'], 'lg_mceEditor', '99%');
        $r .= $DSP->input_hidden("field_ft_" . $row['field_id'], $row["field_fmt"]);
        $SESS->cache['lg'][LG_TMC_addon_id]['require_scripts'] = TRUE;
    }

    return $r;
}

i.e. basically inserting the line:

$r .= $DSP->input_hidden("field_ft_" . $row['field_id'], $row["field_fmt"]);
       
Sue Crocker's avatar
Sue Crocker
26,054 posts
16 years ago
Sue Crocker's avatar Sue Crocker

phatphug, thanks for all the debug work you’ve done. Since this error is stemming from a 3rd party offering, I’m going to go ahead and move it. You might want to drop Leevi a line.

       
elemental's avatar
elemental
77 posts
16 years ago
elemental's avatar elemental

Hello, I am getting a similar problem. I don’t use TinyMCE, Playa or Multi related entries. However I am using Textile formatting plugin on one of the fields.

I am getting this error.

Warning: Typography::require_once((my_path_to_web_folder)/html/system/plugins/pi..php) [typography.require-once]: failed to open stream: No such file or directory in (my_path_to_web_folder)/html/system/core/core.typography.php on line 464

Fatal error: Typography::require_once() [function.require]: Failed opening required '(my_path_to_web_folder)/html/system/plugins/pi..php' (include_path='.:/usr/local/php-5.2.6-1/share/pear') in (my_path_to_web_folder)/html/system/core/core.typography.php on line 464

Mind you, the content and the file gets uploaded OK, once I check going back to the entry. I do think it is a 1.6.5+ issue and I was suspecting it was the FILE extension by Mark Huot (3.1.1) but what i can gather from phatphug it’s could actually be a textile plugin problem. Correct me

Running EE 1.6.5 (20081024) and 1.6.6 (20081114), Textile v.1.1 (2.0.0 r2779)) and (Mark Huot) File (3.1.1)

Any help appreciated Thank you

       
Robin Sowell's avatar
Robin Sowell
13,160 posts
16 years ago
Robin Sowell's avatar Robin Sowell

In truth, it shouldn’t be the Textile plugin- it’s very likely the ‘File’ extension. If you go to ‘Admin- Utilities- Extension Manager’ and hit the big button top right ‘Disable Extensions’, then test- do you still error?

       
elemental's avatar
elemental
77 posts
16 years ago
elemental's avatar elemental

You might be right Robin. Turned off the extension (all) and I could make a new entry without hitting the error page. Editing the old ones produced the old error (since they already had that file attached)

I can even now make a new entry without hitting the error page if I don’t attach a file(jpg) with the entry.

       
phatphug's avatar
phatphug
31 posts
16 years ago
phatphug's avatar phatphug

I found this problem occurs with any extension which doesn’t explictly set a field_ft_X value in the Publishing form. So it may effect other plugins (not just LG TinyMCE).

It may be worth checking the HTML of the Publishing form to see if any of your custom input fields are missing a hidden field_ft_X value.

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
16 years ago
Ingmar Greil's avatar Ingmar Greil

Yes, since EE 1.6.6 you can’t rely on default values there anymore.

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.