roles/permissions question

A place for users and developers of the Xataface to discuss and receive support.

Postby maddin » Wed Jan 31, 2007 5:58 am

hi steve
i implemented this function "as is"
and it semms that there is a problem with this line
$user =& $app->getLoggedInUser();

Fatal error: Call to undefined function: getloggedinuser() in /data/mad/haschisch-online.de/www/html/df69/cdb/conf/ApplicationDelegate.php on line 15

this happens either on win and linux
maybe you have an idea

?(?(?(
maddin
 
Posts: 58
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Wed Jan 31, 2007 10:33 am

oops.. that should be $auth->getLoggedInUser();
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby maddin » Thu Feb 01, 2007 10:40 am

hi steve

i changed it to $auth ,but..

Fatal error: Call to a member function val() on a non-object in E:\schlumpp\htdocs\df6.11\cdb\conf\ApplicationDelegate.php on line 33

line 33:
if ( $record and $record->val('owner') == $user->val('UserName') )

spooky isn`t it?
maddin
 
Posts: 58
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Thu Feb 01, 2007 1:15 pm

OK.. this is where you need to get your debugging hat on and figure out what is going on. I can give you some tips of where to look, but ultimately you're gonna have to find this one.

First... you know which line is the culprit and you know what the error is.

Evidently it claims that $record is not an object - but it is also not null!
So add an echo statement just before that line to see what $record is:

e.g.
echo "Record is $record"; exit;

If it turns out to be an array, go:
echo "Record is "; print_r($record);exit;

Do what you have to do to prevent that line from being called if $record is not an object.
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby maddin » Thu Feb 01, 2007 4:10 pm

Record is Array ( [table] => datenbank )

..if I was the parser, I would approve it ;)
but unfortunately php seems to be more strict

It looks like an object to me...it even looks like the right object and it contains a field 'owner', when I understood it right,
that [table] => datenbank is an array of all fields of datenbank

ps: a friend of mine borrowed my debugging hat and never gave it back
maddin
 
Posts: 58
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Thu Feb 01, 2007 4:50 pm

Ok.. this is a bit sticky.Ê Record is not an object, it is an array.. there are 2 possibilities for the cause of this.
  1. It is a bug in dataface
  2. Somewhere in your code (anywhere in your application) you have assigned some other value to that particular record..
Here's what you can do to help diagnose the problem.
In the spot where you are placing your debugging code, add:
echo Dataface_Error::printStackTrace();
An post the output to the forum.Ê Also it would help to know what version of Dataface you are using.
Thanks
Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby maddin » Fri Feb 02, 2007 8:35 am

hi steve
I am using dataface 6.11 and the FacultyOfWidgetry-12 example (not modified)
,where i extended the course table with a field "owner". and the ApplicationDelegate.php from your last post. (system: win xampp)

Code: Select all
On line 33 of file E:\schlumpp\htdocs\df6.11\FacultyOfWidgetry-12\conf\ApplicationDelegate.php in function printStackTrace()
On line 1766 of file E:\schlumpp\htdocs\df6.11\Dataface\Table.php in function getPermissions(array(Course))
On line 128 of file E:\schlumpp\htdocs\df6.11\Dataface\PermissionsTool.php in function getPermissions(array())
On line 1019 of file E:\schlumpp\htdocs\df6.11\Dataface\Application.php in function getPermissions(Dataface_Table Object,array())
On line 1024 of file E:\schlumpp\htdocs\df6.11\Dataface\Application.php in function getPermissions()
On line 194 of file E:\schlumpp\htdocs\df6.11\Dataface\ActionTool.php in function checkPermission(view)
On line 1354 of file E:\schlumpp\htdocs\df6.11\Dataface\Table.php in function getActions(array(Course))
On line 71 of file E:\schlumpp\htdocs\df6.11\Dataface\ActionTool.php in function getActions(array(Course))
On line 84 of file E:\schlumpp\htdocs\df6.11\Dataface\ActionTool.php in function _loadTableActions(Course)
On line 699 of file E:\schlumpp\htdocs\df6.11\Dataface\Application.php in function getAction(array(Course,list))
On line 1152 of file E:\schlumpp\htdocs\df6.11\Dataface\Application.php in function handleRequest()
On line 19 of file E:\schlumpp\htdocs\df6.11\FacultyOfWidgetry-12\index.php in function display()
On line 33 of file E:\schlumpp\htdocs\df6.11\FacultyOfWidgetry-12\conf\ApplicationDelegate.php in function printStackTrace()

the output above is printed out on the screen about 40 times!
Code: Select all
echo "Record is "; print_r($record);exit;


Record is Array ( [table] => Course )

the following is the output of the linux server where I am using dataface 6.9 (same setup as the example above)
Code: Select all
On line 33 of file /data/mad/haschisch-online.de/www/html/df69/FacultyOfWidgetry-12/conf/ApplicationDelegate.php in function printstacktrace()
On line 1763 of file /data/mad/haschisch-online.de/www/html/df69/Dataface/Table.php in function getpermissions(course)
On line 128 of file /data/mad/haschisch-online.de/www/html/df69/Dataface/PermissionsTool.php in function getpermissions()
On line 960 of file /data/mad/haschisch-online.de/www/html/df69/Dataface/Application.php in function getpermissions(Object,)
On line 965 of file /data/mad/haschisch-online.de/www/html/df69/Dataface/Application.php in function getpermissions()
On line 194 of file /data/mad/haschisch-online.de/www/html/df69/Dataface/ActionTool.php in function checkpermission(view)
On line 1354 of file /data/mad/haschisch-online.de/www/html/df69/Dataface/Table.php in function getactions(course)
On line 71 of file /data/mad/haschisch-online.de/www/html/df69/Dataface/ActionTool.php in function getactions(course)
On line 84 of file /data/mad/haschisch-online.de/www/html/df69/Dataface/ActionTool.php in function _loadtableactions(course)
On line 640 of file /data/mad/haschisch-online.de/www/html/df69/Dataface/Application.php in function getaction(course-list)
On line 1093 of file /data/mad/haschisch-online.de/www/html/df69/Dataface/Application.php in function handlerequest()
On line 19 of file /data/mad/haschisch-online.de/www/html/df69/FacultyOfWidgetry-12/index.php in function display()

cheers
martin
maddin
 
Posts: 58
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Fri Feb 02, 2007 10:17 am

This looks like it may be a bug in Dataface (in Dataface table around line 1766).

--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Fri Feb 02, 2007 10:23 am

I have added this to the issue tracker and submitted a patched version of Table.php.Ê Let me know how it goes.


http://framework.weblite.ca/development/issue-tracker/141

--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby maddin » Fri Feb 02, 2007 3:44 pm

hi steve
this is the output with the patch:
Code: Select all
On line 33 of file E:\schlumpp\htdocs\df6.11\FacultyOfWidgetry-12\conf\ApplicationDelegate.php in function printStackTrace()
On line 1767 of file E:\schlumpp\htdocs\df6.11\Dataface\Table.php in function getPermissions(,array(Course))
On line 128 of file E:\schlumpp\htdocs\df6.11\Dataface\PermissionsTool.php in function getPermissions(array())
On line 1019 of file E:\schlumpp\htdocs\df6.11\Dataface\Application.php in function getPermissions(Dataface_Table Object,array())
On line 1024 of file E:\schlumpp\htdocs\df6.11\Dataface\Application.php in function getPermissions()
On line 194 of file E:\schlumpp\htdocs\df6.11\Dataface\ActionTool.php in function checkPermission(view)
On line 1354 of file E:\schlumpp\htdocs\df6.11\Dataface\Table.php in function getActions(array(Course))
On line 71 of file E:\schlumpp\htdocs\df6.11\Dataface\ActionTool.php in function getActions(array(Course))
On line 84 of file E:\schlumpp\htdocs\df6.11\Dataface\ActionTool.php in function _loadTableActions(Course)
On line 699 of file E:\schlumpp\htdocs\df6.11\Dataface\Application.php in function getAction(array(Course,list))
On line 1152 of file E:\schlumpp\htdocs\df6.11\Dataface\Application.php in function handleRequest()
On line 19 of file E:\schlumpp\htdocs\df6.11\FacultyOfWidgetry-12\index.php in function display()

Fatal error: Call to a member function val() on a non-object in E:\schlumpp\htdocs\df6.11\FacultyOfWidgetry-12\conf\ApplicationDelegate.php on line 35
maddin
 
Posts: 58
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Fri Feb 02, 2007 5:01 pm

Excellent.Ê That looks right.Ê Remove the debugging code (i.e. the stack trace).ÊÊ Now, testing to see if record exists should work properly.

-Steve

--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby maddin » Fri Feb 02, 2007 6:14 pm

Fatal error: Call to a member function val() on a non-object in E:\schlumpp\htdocs\df6.11\FacultyOfWidgetry-12\conf\ApplicationDelegate.php on line 35

???
maddin
 
Posts: 58
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Sat Feb 03, 2007 1:38 am

If I were you I'd probably be ready to give up :)Ê Can't believe it is giving you this much trouble.


That error means:

You are calling a member function on a non-object.

So it is doing something like $record->val() but $record is not an object.

What you have to do is, find out what $record is, and by way of an if statement, prevent that line from being executed unless $record is an object.

You can also use the php is_object() function to test if it is an object, but you shouldn't need to.Ê Either $record will be null, or it will be an object (in which case you can call the val() method on it without problems).Ê It will be null if no records were found in the current query and it is just checking the permissions on the table in general.Ê Otherwise it will have a reference to the current record object.Ê There should be no in between.

I have about 20 apps all running with permissions methods very similar to the one you are setting up here and they all work ok - so there is light at the end of the tunnel here.

--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby geller » Sat Feb 03, 2007 11:15 am

Hi Guys

I have been following this thread with interest as I am getting the same problems as Martin using a similar application delegate class on my own application. I have kept my nose out until now as I am really not that technical but have been struggling for several weeks to secure my tables.

What I am finding is that using the old Table.php ( on current release before Steve's patch) is exactly what Martin was finding

from the output of 'echo "Record is.. "; print_r($record);exit;'
Record is Array ( [table] => table25 )

After applying the patch I guess the output is null or no records?

Record is..

(All my tables have some data in them)

Further back in the thread Steve said that:-

Quote

Ok.. this is a bit sticky. Record is not an object, it is an array.. there are 2 possibilities for the cause of this.

1. It is a bug in dataface
2. Somewhere in your code (anywhere in your application) you have assigned some other value to that particular record..


I am not sure if this is relavent but I captured the output from echo "User is "; print_r($user);exit;

Some way through the output is:-

[_tables] => Array ( [table25] => table 1 [table26] => table 2 [table27] => table 3 [table28] => table 4 )

Is this related to Steve's point number 2. ? Is it the conf.ini assigning another value to the tables?

Probably not but I am clutching at straws...
geller
 
Posts: 26
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Sat Feb 03, 2007 12:18 pm

Can you post your current getPermissions() method that you are using... keeping your debugging code intact and also post the full output so I can take a look.

On another note, I have just posted another tutorial in the documentation section that involves permissions that might be helpful.Ê It comes with source code.


-Steve

--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

PreviousNext

Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 18 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved