Closed codeaken closed 6 years ago
Same here. The reason is that the field types are mapped to the wrong classes.
With PHP
[
...
"wysiwig" => "Attachments_Field_WYSIWIG"
...
]
With HHVM
[
...
"wysiwig" => "Walker_PageDropdown"
...
]
I suppose HHVM sorts the return array of get_declared_classes()
in a different way than PHP, so this a litte bit unconventional method of finding the class seems to crash:
// determine it's class
$flag = array_search( 'Attachments_Field', $existing_classes );
// the field's class is next
$field_class = $existing_classes[$flag + $field_index + 1];
Wouldn't it be possible to also specify the class names instead of trying to determine them?
function get_field_types()
{
$field_types = array(
'text' => array(
'path' => ATTACHMENTS_DIR . 'classes/fields/class.field.text.php',
'class' => 'Attachments_Field_Text'
),
'textarea' => array(
'path' => ATTACHMENTS_DIR . 'classes/fields/class.field.textarea.php',
'class' => 'Attachments_Field_Textarea'
),
'select' => array(
'path' => ATTACHMENTS_DIR . 'classes/fields/class.field.select.php',
'class' => 'Attachments_Field_Select'
),
'wysiwyg' => array(
'path' => ATTACHMENTS_DIR . 'classes/fields/class.field.wysiwyg.php',
'class' => 'Attachments_Field_WYSIWYG'
)
);
// support custom field types
// $field_types = apply_filters( 'attachments_fields', $field_types );
foreach( $field_types as $name => $type)
{
// proceed with inclusion
if( file_exists( $type['path'] ) )
{
// include the file
include_once( $type['path'] );
// create our link using our new field class
$field_types[$name] = $type['class'];
}
}
// send it back
return $field_types;
}
You are right. The output of get_declared_classes()
is not consistent between vanilla PHP and HHVM
Yup, I am opening a PR for this because I wrote a fix for this a while ago and was harshly reminded of it when I updated the plugin by mistake
When running this plugin under HHVM I get "white screen of death" in the admin. These are the errors I find in the log:
Disabling this plugin makes the admin work as expected again.
Plugin version: 3.5.5 Wordpress version: 4.2.2