pungpoo / giix

Automatically exported from code.google.com/p/giix
0 stars 0 forks source link

Fatal error: Call to a member function __toString() on a non-object in giix-components\GxHtml.php on line 121 #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Database has table called Role with structure:
CREATE TABLE IF NOT EXISTS `Role` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `parentRoleId` int(10) unsigned DEFAULT NULL,
  ...
) ENGINE=InnoDB

2. Role table has Foreign Key constraint to itself on parentRoleId-id where 
parentRoleId is nullable:
ALTER TABLE `Role`
  ADD CONSTRAINT `FK_Role_parentRoleId` FOREIGN KEY (`parentRoleId`) REFERENCES `Role` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

3. Used Giix to generate a Role model in protected/models where Role extendes 
BaseRole, which is a GxActiveRecord.

4. Used Giix to generate CRUD files for a RoleController with default settings 
into an admin module.

5. Browsed to the admin/role/index action and received the following error:
Fatal error: Call to a member function __toString() on a non-object in 
XXXXX\protected\extensions\giix-components\GxHtml.php on line 121

6. Most Role table records had non-null parentRoleId's, but one record was NULL 
and caused the error.

What is the expected output? What do you see instead?
I see a Fatal Error; I expected no Fatal Error.

What version of the product are you using? On what operating system?
I am using Yii verion 1.1.6 and giix version 1.3 on Windows with Zend Server.

Please provide any additional information below.

Found original source with bug in GxHtml class, valueEx function, line 121 :
if ($attribute === null)
    return $model->__toString(); // It is assumed that $model is an instance of GxActiveRecord.

Modified code for bug fix:
if ($attribute === null)
{
    if(is_null($model))
        return "";
    return $model->__toString(); // It is assumed that $model is an instance of GxActiveRecord.
}

Original issue reported on code.google.com by jasonmko...@gmail.com on 11 Feb 2011 at 5:47

GoogleCodeExporter commented 8 years ago
I had the same Problem, if you delete the parentRoleId out of the view files 
(_view,admin) it will work. but for sure this is not the solution.

Original comment by m...@nils-menrad.de on 13 Feb 2011 at 10:35

GoogleCodeExporter commented 8 years ago
This was fixed by the revision 56.

Original comment by rodrigo.coelho@gmail.com on 4 May 2011 at 1:44