CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Huh? 1.69mb var_dump on $form in buildForm hook?
Pages: [1]

Author Topic: Huh? 1.69mb var_dump on $form in buildForm hook?  (Read 971 times)

alanms

  • I post occasionally
  • **
  • Posts: 72
  • Karma: 5
Huh? 1.69mb var_dump on $form in buildForm hook?
November 18, 2010, 11:11:54 am
It's a funny old world, QuickForms... but I never thought this odd.

I made a regular var_dump on the basic search form's $form value, and it returned over a megabyte of code. It literally crashes my text editor every time I try to make sense of it.

Over a megabyte for one variable in one function is probably normal, if you're modelling the effects of different enzyme protein foldings on HIV mutations, or looking for patterns in the stock market. But for a form with 3 medium-sized option lists and a text input?

Thinking I must have made a mistake in some mod coding somewhere (maybe accidentally typing "$form =& model_climate_change('tropic_of_capricorn','1995','2025');" ), I tried it on my fairly clean test install of 3.3. It came out even bigger - 1.69 mbs. This is just basic search - advanced search is bigger still, and I've not yet tried any of the really complex forms.

There's a serious question and a "huh?" question.

The serious question is, I need to know how to swap out an existing form element using a hook: how to figure out the naming convention, how to target it, etc. This is proving more difficult than it should considering that a) most of QuickForms' own docs are incomplete, contain mistakes such as parameters in the wrong order and/or haven't been updated since 1886, b) CiviCRM's quickform docs are mostly links to the above, and c) the debug variable containing the information I need literally crashes my text editor.

The "huh?" question is mostly, "huh?". From the small fraction of this code I've been physically able to look at, there seems to be many, many duplicates of my tags and groups taxonomies, and masses of what look to be config and error handling settings that appear to be duplicated multiple times. "{ ["_stateMachine:protected"]=> *RECURSION* } " appears a lot.

Does this sound expected?

Fun facts: 1,779,424 characters, 202,705 words, 407 pages...

A test tag name appears 108 times, a test group name 252 times, "RECURSION" recurs 873 times...
« Last Edit: November 18, 2010, 11:20:25 am by alanms »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Huh? 1.69mb var_dump on $form in buildForm hook?
November 18, 2010, 12:13:49 pm

dont know if var_dump handles recursion, but can u check: CRM_Core_Error::debug( $form );

most / all of them are stored as references within PHP, so it does not take as much memory

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

alanms

  • I post occasionally
  • **
  • Posts: 72
  • Karma: 5
Re: Huh? 1.69mb var_dump on $form in buildForm hook?
November 18, 2010, 03:42:04 pm
Brilliant, that does the job perfectly. Glad to hear it's nothing to worry about.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Huh? 1.69mb var_dump on $form in buildForm hook?

This forum was archived on 2017-11-26.