Bug #23557 Duplicate

Field api setup_handler returns false

Version: Reporter: Brian Litzinger

I haven’t tracked down the cause of this yet but while making a new fieldtype I encountered this error:

Error: Call to a member function accepts_content_type() on boolean in /var/www/html/system/ee/EllisLab/Addons/grid/libraries/Grid_lib.php on line 665
Call Stack
# Time Memory Function Location
1 0.0014 366016 {main}( ) .../admin.php:0
2 0.0040 367016 require_once( '/var/www/html/system/ee/EllisLab/ExpressionEngine/Boot/boot.php' ) .../admin.php:147
3 0.0543 479608 EllisLab\ExpressionEngine\Core\Core->run( ) .../boot.php:146
4 0.0895 576080 EllisLab\ExpressionEngine\Core\Core->runController( ) .../Core.php:109
5 1.8711 3423184 call_user_func_array:{/var/www/html/system/ee/EllisLab/ExpressionEngine/Core/Core.php:240} ( ) .../Core.php:240
6 1.8711 3423576 EllisLab\ExpressionEngine\Controller\Channels\Channels->edit( ) .../Core.php:240
7 1.8711 3423576 EllisLab\ExpressionEngine\Controller\Channels\Channels->form( ) .../Channels.php:183
8 4.4023 10894440 EllisLab\ExpressionEngine\Model\Content\FieldModel->getSettingsForm( ) .../Channels.php:329
9 4.4092 10897992 EllisLab\ExpressionEngine\Model\Content\FieldFacade->getSettingsForm( ) .../FieldModel.php:71
10 4.4366 10905520 Api_channel_fields->apply( ) .../FieldFacade.php:225
11 4.4545 10904928 Grid_ft->display_settings( ) .../Api_channel_fields.php:408
12 4.4692 10911968 Grid_lib->get_grid_fieldtypes( ) .../ft.grid.php:460

I tracked it down to the setup_handler method returning false, so its trying to call the accepts_content_type method on a boolean. Either the setup_handler shouldn’t return a boolean or an object, or before trying to call accepts_content_type it should check to make sure $fieldtype is a valid field object, and if not, throw a helpful error message.

foreach ($fieldtypes as $field_short_name => $field_name)
     {
      $fieldtype = $ft_api->setup_handler($field_short_name, TRUE);

      // Check to see if the fieldtype accepts Grid as a content type;
      // also, temporarily exlcude Relationships for content types
      // other than channel
      if ( ! $fieldtype->accepts_content_type('grid') ||
       ($this->content_type != 'channel' && $field_short_name == 'relationship'))
      {
       unset($fieldtypes[$field_short_name], $compatibility[$field_short_name]);
      }
     }
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases