michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
340 stars 71 forks source link

Revealer field throws array to string conversion error #178

Closed codearachnid closed 9 years ago

codearachnid commented 9 years ago

With the latest minified stable release version of the code (even tried from repo source too). The revealer field throws an error on Array to String conversion.

Actual error is: Notice: Array to string conversion in /wp-dev/wp-content/plugins/pluginname/lib/admin-page-framework.min.php on line 27

When I use the unminified code it works just fine. Am digging into the profiler now to determine what is causing the break.

codearachnid commented 9 years ago

I took the RevealerCustomFieldType.php class and imported it directly after the minified class file and this resolved the errors and the revealer field is working again. I haven't dug in fully but it seems that maybe the minifier is screwing with the array converters

michaeluno commented 9 years ago

With the given information, I cannot reproduce it. Can you post a small plugin that demonstrates the problem?

I suspect your plugin/theme is using a lesser version of the framework. The revealer custom field type was updated in v3.4.0. If your framework version is lesser than that, it may cause a problem. So double check the framework version number.

codearachnid commented 9 years ago

Thanks for following up @michaeluno the plugin I am currently implementing it in is https://github.com/codearachnid/legull. If you comment out line 22 on legull.php it will display the notices if you have wp_debug and display enabled when going to the main page on the plugin /wp-admin/admin.php?page=legull_dashboard. I upgraded the framework recently, again it works fine in the unminified version but with the minified codebase it bombs. The revealer fields are defined on the following file.

michaeluno commented 9 years ago

You need to double-check the framework version number. Which version do you see if your mouse hovers over the footer link, Admin Page Framework? If you use a recent version of the framework and enable WP_DEBUG, the version should be already indicated at the bottom of each section.

Also the linked plugin is rather large only to see a problem. Can you write a very very small plugin like this to just show the problem? https://gist.github.com/michaeluno/d0eca4c0c02af911aabd

codearachnid commented 9 years ago

That is what I was saying earlier I am using the latest framework version Admin Page Framework 3.4.3.min. As you requested here is a sample demo plugin of what I am noticing https://gist.github.com/codearachnid/b3b7e1b311ecdbea02eb. What I have found is when I inspect the minified version I do not see the RevealerCustomFieldType class present. An interesting side effect is when I have the APF demo plugin activated then it is found since the demo plugin uses the non-minified version which also has the linked revealer class.

When I inspect the available classes during run time these are the only related to APF.

[209] => AdminPageFramework_Registry_Base [210] => AdminPageFramework_Registry [211] => AdminPageFramework_Bootstrap [212] => AdminPageFramework_Factory_Router [213] => AdminPageFramework_Factory_Model [214] => AdminPageFramework_Factory_View [215] => AdminPageFramework_Factory_Controller [216] => AdminPageFramework_Factory [217] => AdminPageFramework_Router [218] => AdminPageFramework_Form_Model_Port [219] => AdminPageFramework_MetaBox_Router [220] => AdminPageFramework_MetaBox_Model [221] => AdminPageFramework_PostType_Router [222] => AdminPageFramework_PostType_Model [223] => AdminPageFramework_TaxonomyField [224] => AdminPageFramework_Widget_Router [225] => AdminPageFramework_Widget_Model [226] => AdminPageFramework_Form_Model_Validation [227] => AdminPageFramework_Form_Model [228] => AdminPageFramework_MetaBox_View [229] => AdminPageFramework_MetaBox_Controller [230] => AdminPageFramework_MetaBox [231] => AdminPageFramework_PostType_View [232] => AdminPageFramework_PostType_Controller [233] => AdminPageFramework_PostType [234] => AdminPageFramework_Widget_View [235] => AdminPageFramework_Widget_Controller [236] => AdminPageFramework_Widget [237] => AdminPageFramework_Form_View [238] => AdminPageFramework_Form_Controller [239] => AdminPageFramework_MetaBox_Page_Router [240] => AdminPageFramework_MetaBox_Page_Model [241] => AdminPageFramework_Page_Model [242] => AdminPageFramework_MetaBox_Page_View [243] => AdminPageFramework_MetaBox_Page_Controller [244] => AdminPageFramework_MetaBox_Page [245] => AdminPageFramework_Page_View_MetaBox [246] => AdminPageFramework_Page_View [247] => AdminPageFramework_Page_Controller [248] => AdminPageFramework_Menu_Model [249] => AdminPageFramework_Menu_View [250] => AdminPageFramework_Menu_Controller [251] => AdminPageFramework_Model [252] => AdminPageFramework_View [253] => AdminPageFramework_Controller [254] => AdminPageFramework [255] => AdminPageFramework_NetworkAdmin [256] => AdminPageFramework_Widget_Factory [257] => AdminPageFramework_ErrorReporting [258] => AdminPageFramework_RegisterClasses [259] => AdminPageFramework_Utility_String [260] => AdminPageFramework_Utility_Array [261] => AdminPageFramework_Utility_Path [262] => AdminPageFramework_Utility_URL [263] => AdminPageFramework_Utility [264] => AdminPageFramework_WPUtility_URL [265] => AdminPageFramework_WPUtility_HTML [266] => AdminPageFramework_WPUtility_Page [267] => AdminPageFramework_WPUtility_Hook [268] => AdminPageFramework_WPUtility_File [269] => AdminPageFramework_WPUtility_Option [270] => AdminPageFramework_WPUtility_Post [271] => AdminPageFramework_WPUtility [272] => AdminPageFramework_CustomSubmitFields [273] => AdminPageFramework_FormEmail [274] => AdminPageFramework_Debug [275] => AdminPageFramework_Link_Base [276] => AdminPageFramework_FormElement_Utility [277] => AdminPageFramework_FormElement [278] => AdminPageFramework_FieldType_Base [279] => AdminPageFramework_FieldType [280] => AdminPageFramework_FormOutput [281] => AdminPageFramework_FormField_Base [282] => AdminPageFramework_FormField [283] => AdminPageFramework_Input_Base [284] => AdminPageFramework_ExportOptions [285] => AdminPageFramework_ImportOptions [286] => AdminPageFramework_HelpPane_Base [287] => AdminPageFramework_Link_Page [288] => AdminPageFramework_Link_PostType [289] => AdminPageFramework_FormElement_Page [290] => AdminPageFramework_FieldType_image [291] => AdminPageFramework_FieldType_checkbox [292] => AdminPageFramework_FieldType_color [293] => AdminPageFramework_FieldType_default [294] => AdminPageFramework_FieldType_hidden [295] => AdminPageFramework_FieldType_radio [296] => AdminPageFramework_FieldType_section_title [297] => AdminPageFramework_FieldType_select [298] => AdminPageFramework_FieldType_submit [299] => AdminPageFramework_FieldType_export [300] => AdminPageFramework_FieldType_import [301] => AdminPageFramework_FieldType_system [302] => AdminPageFramework_FieldType_taxonomy [303] => AdminPageFramework_FieldType_text [304] => AdminPageFramework_FieldType_file [305] => AdminPageFramework_FieldType_number [306] => AdminPageFramework_FieldType_textarea [307] => AdminPageFramework_FormTable_Base [308] => AdminPageFramework_Input_checkbox [309] => AdminPageFramework_Input_radio [310] => AdminPageFramework_Input_select [311] => AdminPageFramework_HelpPane_MetaBox [312] => AdminPageFramework_HelpPane_Page [313] => AdminPageFramework_FieldType_media [314] => AdminPageFramework_FieldType_posttype [315] => AdminPageFramework_FieldType_size [316] => AdminPageFramework_FormTable_Row [317] => AdminPageFramework_FormTable_Caption [318] => AdminPageFramework_FormTable [319] => AdminPageFramework_HelpPane_MetaBox_Page [320] => AdminPageFramework_HelpPane_TaxonomyField [321] => AdminPageFramework_HelpPane_Widget [322] => AdminPageFramework_Resource_Base [323] => AdminPageFramework_Resource_MetaBox [324] => AdminPageFramework_Resource_Page [325] => AdminPageFramework_Resource_MetaBox_Page [326] => AdminPageFramework_Resource_Widget [327] => AdminPageFramework_Resource_PostType [328] => AdminPageFramework_Resource_TaxonomyField [329] => AdminPageFramework_CSS [330] => AdminPageFramework_Message [331] => AdminPageFramework_Property_Base [332] => AdminPageFramework_Property_MetaBox [333] => AdminPageFramework_Property_Page [334] => AdminPageFramework_Property_NetworkAdmin [335] => AdminPageFramework_Property_PostType [336] => AdminPageFramework_Property_Widget [337] => AdminPageFramework_Property_MetaBox_Page [338] => AdminPageFramework_Property_TaxonomyField [339] => AdminPageFramework_FieldTypeRegistration [340] => AdminPageFramework_WalkerTaxonomyChecklist [341] => AdminPageFramework_PageLoadInfo_Base [342] => AdminPageFramework_PageLoadInfo_NetworkAdminPage [343] => AdminPageFramework_PageLoadInfo_Page [344] => AdminPageFramework_PageLoadInfo_PostType [345] => AdminPageFramework_Script_Base [346] => AdminPageFramework_Script_AttributeUpdator [347] => AdminPageFramework_Script_CheckboxSelector [348] => AdminPageFramework_Script_CollapsibleSection [349] => AdminPageFramework_Script_MediaUploader [350] => AdminPageFramework_Script_OptionStorage [351] => AdminPageFramework_Script_RegisterCallback [352] => AdminPageFramework_Script_RepeatableField [353] => AdminPageFramework_Script_RepeatableSection [354] => AdminPageFramework_Script_Sortable [355] => AdminPageFramework_Script_Tab [356] => AdminPageFramework_Script_Utility [357] => AdminPageFramework_Script_Widget

michaeluno commented 9 years ago

I tried your test plugin but could not see any error. Make sure you include the file that defines the revealer field type bundled in the latest demo plugin.

What I have found is when I inspect the minified version I do not see the RevealerCustomFieldType class present.

Custom field types are not built-in so it is supposed to be so.

An interesting side effect is when I have the APF demo plugin activated then it is found since the demo plugin uses the non-minified version which also has the linked revealer class.

It is not a side effect. Check out the Change PHP Class Names section in the Other Notes page.

codearachnid commented 9 years ago

Well if custom field types aren't built into core then it makes sense why I would need to include that separately. Sorry to throw a false flag on this - might need to make it clearer in the documentation for the revealer.

michaeluno commented 9 years ago

No problem. I'll see how the documentation can be improved.