• Resolved shaunpez

    (@shaunpez)


    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

    (@tealium)

    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

    (@shaunpez)

    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/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, 1 month ago by shaunpez.
    Thread Starter shaunpez

    (@shaunpez)

    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, 1 month ago by shaunpez.
    Thread Starter shaunpez

    (@shaunpez)

    Just checking up on this?

    Plugin Author Tealium

    (@tealium)

    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

    (@shaunpez)

    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.