Active
Project:
OG Flag
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Jun 2013 at 00:34 UTC
Updated:
4 Feb 2014 at 20:27 UTC
Jump to comment: Most recent
I have a very strange and repeatable problem with a flag I've created with 7.x-2.1. Loading the flag via an export (I'm exporting and deploying using Features) kills Drupal with the error
PHP Fatal error: Cannot access property started with '\0' in /opt/my-site/drupal/sites/all/modules/contrib/flag/flag.inc on line 213
The cause turns out to be the exported flag.
It looks something like this:
>
$flags = array();
// Exported flag: "Mail Me On New Posts To This Group".
$flags['subscribe_group_content'] = array(
'' . "\0" . '*' . "\0" . 'defaultValues' => array(
'isOverridden' => FALSE,
'overridesApplied' => FALSE,
'ogContext' => FALSE,
'fid' => '2',
'content_type' => 'node',
'name' => 'subscribe_group_content',
'title' => 'Mail Me On New Posts To This Group',
'global' => '0',
'types' => array(
0 => 'chapter_group',
1 => 'dacountry_group',
2 => 'region_group',
3 => 'topic_group',
),
'flag_short' => 'Subscribe me to emails for this group',
'flag_long' => 'Send me mail on new messages',
'flag_message' => 'You are subscribed to email notifications',
'unflag_short' => 'Stop sending me email for this group',
'unflag_long' => 'Stop sending me email notifications on new content',
'unflag_message' => 'Email notifications have been turned off.',
'unflag_denied_text' => '',
'link_type' => 'toggle',
'roles' => array(
'flag' => array(
0 => '11',
1 => '7',
),
'unflag' => array(
0 => '11',
1 => '7',
),
),
'weight' => 0,
'show_on_form' => 0,
'access_author' => '',
'show_on_page' => 1,
'show_on_teaser' => 1,
'show_contextual_link' => 0,
'i18n' => 0,
'module' => 'group_content_notification_system',
'locked' => array(
'name' => 'name',
),
),
'isOverridden' => FALSE,
'overridesApplied' => FALSE,
'ogContext' => FALSE,
'content_type' => 'node',
'title' => 'Mail Me On New Posts To This Group',
'global' => '0',
'types' => array(
0 => 'chapter_group',
1 => 'dacountry_group',
2 => 'region_group',
3 => 'topic_group',
),
'flag_short' => 'Subscribe me to emails for this group',
'flag_long' => 'Send me mail on new messages',
'flag_message' => 'You are subscribed to email notifications',
'unflag_short' => 'Stop sending me email for this group',
'unflag_long' => 'Stop sending me email notifications on new content',
'unflag_message' => 'Email notifications have been turned off.',
'unflag_denied_text' => '',
'link_type' => 'toggle',
'roles' => array(
'flag' => array(
0 => '11',
1 => '7',
),
'unflag' => array(
0 => '11',
1 => '7',
),
),
'weight' => 0,
'show_on_form' => 0,
'access_author' => '',
'show_on_page' => 1,
'show_on_teaser' => 1,
'show_contextual_link' => 0,
'i18n' => 0,
'module' => 'group_content_notification_system',
'locked' => array(
'name' => 'name',
),
'api_version' => 2,
);
return $flags;
The issue is the truly weird
'' . "\0" . '*' . "\0" . 'defaultValues' => array(
If I edit out the part before 'defaultValues', everything works as expected. But this line in the export kills PHP deader than a doornail.
Not sure why this occurs, or how.
Comments
Comment #1
joachim commentedMy exported flag looks like this:
Do you maybe have modules that either alter the flag object, or alter Features exports?
Comment #2
gildir commentedI'm having the same issue with the newer version of flag. I have og_flag (3.x) installed as well, though that module does not appear to be setting up anything special for features export.
Same issue at the beginning:
Comment #3
joachim commentedCan you do some debugging in Features to see where those extra strings are coming from?
Comment #4
gildir commentedThe issue is that og_flag introduces protected fields when extending the flag classes. These are prefaced with "\0*\0" on array cast (likewise private fields are prefaced with "\0class\0") since PHP 5.3.0. This is likely happening at the array cast on line 37 of flag.export.inc.
This causes the following when clearing the cache (and similar errors at other times):
Comment #5
joachim commentedThanks for the debugging! That's really helpful.
Moving this to the OG Flag project.