Thread: [Phpslash-devel] Very minor debugging suggestion for lib.resources.php
Brought to you by:
joestewart,
nhruby
From: Mike G. <mi...@op...> - 2003-07-10 14:57:31
|
Howdy, in lib.resources.php, the function pslNew could be slightly easier to debug in the future if the declared classes could be output more easily: else { // print_r(get_declared_classes()); pslError("No such class: $class"); return false; } I was trying to figure out why the heck pslNew wasn't working for a new class I was developing and finally figured out that I hadn't quite changed the class name correctly.... You can't pass arrays to the debug function very well.. I suppose you could serialize them so debug('List of classes',serialize(get_declared_classes())); In anycase just a thought.. Mike -- Mike Gifford, OpenConcept Consulting Free Software for Social Change -> http://www.openconcept.ca Featured Client: CUPE National -> http://www.cupe.ca Whoever controls the media-the images-controls the culture - A. Ginsberg |
From: Joe S. <joe...@us...> - 2003-07-10 17:00:57
|
On Thu, Jul 10, 2003 at 10:57:39AM -0400, Mike Gifford wrote: > Howdy, > > in lib.resources.php, the function pslNew could be slightly easier to > debug in the future if the declared classes could be output more easily: > > else { > // print_r(get_declared_classes()); > pslError("No such class: $class"); > return false; > } > > I was trying to figure out why the heck pslNew wasn't working for a new > class I was developing and finally figured out that I hadn't quite > changed the class name correctly.... > > You can't pass arrays to the debug function very well.. I suppose you > could serialize them so > debug('List of classes',serialize(get_declared_classes())); > > In anycase just a thought.. > Hey Mike, debug() should have no trouble outputting arrays. This works fine for me: debug("declared_classes", get_declared_classes()); What is the value of debug.max_recursion_level in config.ini? debug.max_recursion_level = 10 If you add a test like this do you get the full array displayed? debug("_PSL", $_PSL); Joe > Mike > -- > Mike Gifford, OpenConcept Consulting > Free Software for Social Change -> http://www.openconcept.ca > Featured Client: CUPE National -> http://www.cupe.ca > Whoever controls the media-the images-controls the culture - A. Ginsberg > |
From: Matthew L. <lei...@ma...> - 2003-07-10 19:44:39
|
Hi, Still unpacking but checking e-mail... On Thu, 10 Jul 2003, Joe Stewart wrote: > On Thu, Jul 10, 2003 at 10:57:39AM -0400, Mike Gifford wrote: > > Howdy, > > [snip!] > > You can't pass arrays to the debug function very well.. I suppose you > > could serialize them so > > debug('List of classes',serialize(get_declared_classes())); > > > > In anycase just a thought.. > > > > Hey Mike, > > debug() should have no trouble outputting arrays. This works fine for me: > > debug("declared_classes", get_declared_classes()); I agree. debug() got rewritten for 0.7 to recurse through arrays and objects. > What is the value of debug.max_recursion_level in config.ini? > > debug.max_recursion_level = 10 This was a guard against circular references. Consider: $a = new Parent; $b = new Child; $a->children[] =& $b; $b->parent =& $a; debug("a",$a); This would go on indefinitely without either (a) a check for circularity or (b) a maximum level to recurse to. I didn't really know how to do (a) so I built in (b). I believe if you set $_PSL['debug.max_recursion_level'] to something negative then you can get arbitrary recursion (with no circularity checks). But anyway, the array returned from get_defined_classes should only be one-dimensional, so 10 is fine for the purpose! --Matt ---------------------------------------------------------------- Matthew Leingang 617/495-2171 Harvard University lei...@ma... Department of Mathematics "This signature needs no quote." |
From: Mike G. <mi...@op...> - 2003-07-10 18:40:54
|
Sorry Gents.. On Thu, 2003-07-10 at 13:18, Matthew Leingang wrote: > On Thu, 10 Jul 2003, Joe Stewart wrote: > > debug() should have no trouble outputting arrays. This works fine for me: > > > > debug("declared_classes", get_declared_classes()); > I agree. debug() got rewritten for 0.7 to recurse through arrays and > objects. Good to know debug can handle both arrays & objects.. Sorry for overlooking that.. > > What is the value of debug.max_recursion_level in config.ini?> > > debug.max_recursion_level = 10 > This was a guard against circular references. Consider: > But anyway, the array returned from get_defined_classes should only be > one-dimensional, so 10 is fine for the purpose! Yes, but would this be a useful addition to pslNew: debug("declared_classes", get_declared_classes()); (which was the point of the email - I just underestimated the abilities of debug) Mike -- Mike Gifford, OpenConcept Consulting Free Software for Social Change -> http://www.openconcept.ca Featured Client: CUPE National -> http://www.cupe.ca Whoever controls the media-the images-controls the culture - A. Ginsberg |