I am gettting this error on my Devel->Tokens link on all of my product pages. Any idea as to what may be causing this?

Notice: Undefined variable: object in uc_product_tokens() (line 100 of /home/jadamsfx/public_html/aliciafernandezphotography.com/sites/all/modules/ubercart/uc_product/uc_product.tokens.inc).
Notice: Trying to get property of non-object in uc_product_tokens() (line 100 of /home/jadamsfx/public_html/aliciafernandezphotography.com/sites/all/modules/ubercart/uc_product/uc_product.tokens.inc).
CommentFileSizeAuthor
#16 1165618-tokens.patch34.06 KBtr
#4 tokens-overhaul.patch30.01 KBtr
#3 tokens-overhaul.patch31.72 KBtr

Comments

tr’s picture

Title: Error on Devel Token Page of All Products » PHP notice on Devel Token Page of All Products
Version: 7.x-3.0-beta2 » 7.x-3.x-dev
Assigned: Unassigned » tr
Category: support » bug

I have been working on the Ubercart tokens and I already found and fixed this problem locally. I'll be committing my changes to 7.x-3.x-dev in the next few days. If you're not using tokens you can just ignore those PHP notices. If you want to use product tokens you'll have to wait for the fix.

jadamsfx’s picture

Thanks but one more question and I'm not sure if you can answer this but do you think that your token fix would also fix the issue that I'm having with the custom price module. I'm trying to use the cost token to calculate price as follows.

$item->price = $item->price;
$item->price = [cost] * 1.1;

But i get the follwing error.

Parse error: syntax error, unexpected '[' in /home/jadamsfx/public_html/nueera.com/sites/all/modules/uc_custom_price/uc_custom_price.module(87) : eval()'d code on line 1

tr’s picture

StatusFileSize
new31.72 KB

Re: #2. I believe I answered that in the issue queue for uc_custom_price.

Here is my patch to the Ubercart tokens system. Please try it and let me know if you still see errors. Note that with this patch, all product tokens start with product: instead of node:, so instead of using the [node:cost] token for the product cost you will need to use [product:cost].

tr’s picture

StatusFileSize
new30.01 KB

Actually, use this patch. I accidentally left a couple of debugging statements in the previous one and forgot to rebase it against 7.x-3.x head.

tr’s picture

Status: Active » Needs review
longwave’s picture

Status: Needs review » Needs work
+  $language_code = NULL;
+  if (isset($options['language'])) {
+    $language_code = $options['language']->language;
+  }
+  $sanitize = !empty($options['sanitize']);

This has been added to all token hooks, but $language_code never appears to be used, and uc_file_token_info() does not use $sanitize either.

jadamsfx’s picture

Forgive me I'm rather new to drupal and patching. I placed this patch in my ubercart module folder and tried to run it but I get the following error "can't find file to patch at input line 5." When i opened up the patch file i saw you had an a and a b folder. Do I need to create those folders and then place the files in there?

longwave’s picture

These are git-style patches, you need to use "patch -p1" to apply them, which will ignore the a/ and b/ prefixes.

jadamsfx’s picture

Here are the results that I get after patching.

Last login: Thu May 26 11:13:08 on ttys000
computer:~ Jonathan$ cd /Users/Jonathan/Desktop/ubercart\ copy 
computer:ubercart copy Jonathan$ patch -p1 < tokens.patch
patching file uc_cart/uc_cart.module
Hunk #1 succeeded at 737 (offset -6 lines).
patching file uc_file/uc_file.tokens.inc
patching file uc_order/uc_order.rules_defaults.inc
patching file uc_order/uc_order.tokens.inc
patching file uc_product/tests/uc_product.test
Reversed (or previously applied) patch detected!  Assume -R? [n] 
Apply anyway? [n] 
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file uc_product/tests/uc_product.test.rej
patching file uc_product/uc_product.module
Reversed (or previously applied) patch detected!  Assume -R? [n] 
Apply anyway? [n] 
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file uc_product/uc_product.module.rej
patching file uc_product/uc_product.tokens.inc
patching file uc_roles/uc_roles.tokens.inc
patching file uc_stock/uc_stock.tokens.inc
patching file uc_store/tests/uc_store.test
Hunk #1 FAILED at 21.
1 out of 1 hunk FAILED -- saving rejects to file uc_store/tests/uc_store.test.rej
patching file uc_store/uc_store.tokens.inc

Is that right?

longwave’s picture

Looks like you're testing the first patch instead of the second, and the patch needs to be applied against 7.x-3.x-dev, not beta2.

jadamsfx’s picture

Great patch seems to be working not longer getting the errors. Thanks!

farnsworth’s picture

Can some one take the time to link or explain how to apply this patch not sure why but i am more lost then Rebecca black in a recording studio on this.

tr’s picture

@farnsworth: First, make sure you have a recent version of Ubercart 7.x-3.x installed. Then download the patch http://drupal.org/files/issues/tokens-overhaul_0.patch into your ubercart directory. Use the command patch -p1 < tokens-overhaul_0.patch to apply the patch.

The patch should work as is and provide the changed mentioned in #3. But as @longwave noticed in #6, there are still some new features I intend to add that haven't been finished yet.

tdiepiv’s picture

Hmm doesn't seem to be working for me:

host-103-84:~ john$ cd /Users/john/Sites/kissi/ubercart/
host-103-84:ubercart john$ patch -p1 < tokens-overhaul_0.patch
patching file uc_cart/uc_cart.module
patching file uc_file/uc_file.tokens.inc
patching file uc_order/uc_order.rules_defaults.inc
patching file uc_order/uc_order.tokens.inc
patching file uc_product/uc_product.tokens.inc
Reversed (or previously applied) patch detected! Assume -R? [n] n
Apply anyway? [n]
Skipping patch.
2 out of 2 hunks ignored -- saving rejects to file uc_product/uc_product.tokens.inc.rej
patching file uc_roles/uc_roles.tokens.inc
patching file uc_stock/uc_stock.tokens.inc
patching file uc_store/uc_store.tokens.inc

errors still on site:

Notice: Undefined variable: object in uc_product_tokens() (line 96 of /home/johni/kissique.com/sites/all/modules/ubercart/uc_product/uc_product.tokens.inc).
Notice: Trying to get property of non-object in uc_product_tokens() (line 96 of /home/johni/kissique.com/sites/all/modules/ubercart/uc_product/uc_product.tokens.inc).

tdiepiv’s picture

Also getting errors when I save configurations for this specific module, tweetbutton:

Notice: Undefined index: name in _token_token_tree_format_row() (line 107 of /home/johni/kissi.com/sites/all/modules/token/token.pages.inc).

Unsure where the error is

tr’s picture

Status: Needs work » Fixed
StatusFileSize
new34.06 KB

Committed attached patch.

tr’s picture

Issue tags: +Needs tests

Tagging to remind myself that I intend to write SimpleTest cases for Ubercart's token support.

Automatically closed -- issue fixed for 2 weeks with no activity.