Title: Undefined Variables PHP notice
Last modified: February 13, 2018

---

# Undefined Variables PHP notice

 *  Resolved [shaunpez](https://wordpress.org/support/users/shaunpez/)
 * (@shaunpez)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/undefined-variables-php-notice/)
 * Hello,
 * I have been receiving PHP notices for some fields that are undefined (postCategory,
   postTags). In my settings, for Data Layer Style is set to `underscore`, while
   the legacy option is `camel case`.
 * When I switch to `camel case` the PHP notices go away, however I would prefer
   the `underscore` option (which is defaulted on several of my sites and all have
   the same issue).
 * Is there a solution for this?
    Can this be fixed on the next update?

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Tealium](https://wordpress.org/support/users/tealium/)
 * (@tealium)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/undefined-variables-php-notice/#post-9988998)
 * Hi,
 * I must admit this is the first report of this that I’ve encountered, and my test
   site doesn’t seem to have any issues regardless of data layer style. Which version
   of WP are you running? Do your error messages reveal any further detail that 
   might be useful for debugging this?
 * Thanks!
 *  Thread Starter [shaunpez](https://wordpress.org/support/users/shaunpez/)
 * (@shaunpez)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/undefined-variables-php-notice/#post-10004446)
 * Hi Tealium,
 * This issue seems to only happen on blog posts only. I believe its only with 2
   attributes – postCategory and postTags. I am running the latest version of WP.
 *     ```
       Notice
       : Undefined index: postCategory in
       /{site_path}/wp-content/plugins/tealium/tealium.php
       on line
       178
   
       Notice
       : Undefined index: postTags in
       /{site_path}/wp-content/plugins/tealium/tealium.php
       on line
       178
       ```
   
 * Couple of sites that have this issue:
    [https://www.dropbox.com/s/mgeeibzeccjln4j/Screen%20Shot%202018-02-22%20at%2010.54.43%20AM.png?dl=0](https://www.dropbox.com/s/mgeeibzeccjln4j/Screen%20Shot%202018-02-22%20at%2010.54.43%20AM.png?dl=0)
 * [https://www.dropbox.com/s/1iigfvfzhz715ov/Screen%20Shot%202018-02-22%20at%2010.53.17%20AM.png?dl=0](https://www.dropbox.com/s/1iigfvfzhz715ov/Screen%20Shot%202018-02-22%20at%2010.53.17%20AM.png?dl=0)
 * At the same time the defined values on both sites include post_tags & post_category
    -  This reply was modified 8 years, 3 months ago by [shaunpez](https://wordpress.org/support/users/shaunpez/).
 *  Thread Starter [shaunpez](https://wordpress.org/support/users/shaunpez/)
 * (@shaunpez)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/undefined-variables-php-notice/#post-10004842)
 * Hi Tealium Team,
 * So I did a quick test on the function of the point of error and it looks like
   the issue has to do with when the variable contains an array of items. Seems 
   to be fine when the variable is a string
 *     ```
       function tealiumConvertCamelCase( $utagdata, $arrayHolder = array() ) {
       	$underscoreArray = !empty( $arrayHolder ) ? $arrayHolder : array();
       	foreach ( $utagdata as $key => $val ) {
       		$newKey = preg_replace( '/[A-Z]/', '_$0', $key );
       		$newKey = strtolower( $newKey );
       		$newKey = ltrim( $newKey, '_' );
       		if ( !is_array( $val ) ) {
       			$underscoreArray[$newKey] = $val;
       		} else {
       			if ( array_key_exists( $newKey, $underscoreArray ) ) {
       				$underscoreArray[$newKey] = tealiumConvertCamelCase( $val, $underscoreArray[$newKey] );
       			}
       			else {
       				$underscoreArray[$newKey] = tealiumConvertCamelCase( $val, $underscoreArray[$key] );
       			}
       		}
       	}
       	return $underscoreArray;
       }
       ```
   
 * print_r(tealiumConvertCamelCase([‘postTags’ => [‘test’, ‘test’, ‘testing’]]));
 *     ```
       NOTICE Undefined index: postTags on line number 17
       Array ( [post_tags] => Array ( [0] => test [1] => test2 [2] => test3 ) ) 
       ```
   
 * print_r(tealiumConvertCamelCase([‘postTags’ => ‘test’]));
 * `Array ( [post_tags] => test )`
    -  This reply was modified 8 years, 3 months ago by [shaunpez](https://wordpress.org/support/users/shaunpez/).
 *  Thread Starter [shaunpez](https://wordpress.org/support/users/shaunpez/)
 * (@shaunpez)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/undefined-variables-php-notice/#post-10050312)
 * Just checking up on this?
 *  Plugin Author [Tealium](https://wordpress.org/support/users/tealium/)
 * (@tealium)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/undefined-variables-php-notice/#post-10052123)
 * Hi Shaun,
 * I’ve released a new version of the plugin (2.1.8) which includes a fix that was
   submitted to us through Github. I believe that it’s the same issue that you’re
   running into, could you update and let me know if the error is resolved?
 * Many thanks!
 *  Thread Starter [shaunpez](https://wordpress.org/support/users/shaunpez/)
 * (@shaunpez)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/undefined-variables-php-notice/#post-10054194)
 * Great! It is resolved. Closing

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Undefined Variables PHP notice’ is closed to new replies.

 * ![](https://ps.w.org/tealium/assets/icon-256x256.png?rev=1203811)
 * [Tealium](https://wordpress.org/plugins/tealium/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tealium/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tealium/)
 * [Active Topics](https://wordpress.org/support/plugin/tealium/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tealium/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tealium/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [shaunpez](https://wordpress.org/support/users/shaunpez/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/undefined-variables-php-notice/#post-10054194)
 * Status: resolved