I get this error when I try to add a produc kit with 2 products:

Fatal error: Call to undefined function uc_price() in /....../sites/all/modules/ubercart/uc_product_kit/uc_product_kit.module on line 572

Comments

Island Usurper’s picture

Status: Active » Postponed (maintainer needs more info)

That function is in a file that should be included on every page load during hook_init(). Do you have multiple copies of Ubercart in your modules folders, or might you have not upgraded all of the modules?

jamesoakley’s picture

Status: Postponed (maintainer needs more info) » Active

Sorry, I've got this as well.

Updated from Beta 5. (I deleted the whole /modules/ubercart folder and started from scratch, just to be sure that there were no old files hanging around to cause trouble. I ran update.php. I cleared the cache. I added a Product Kit. I can go to Administer > Content Management > Content and edit the node with no trouble. But whenever I try to view the node I've created, I get exactly the error described above.

So: To answer your questions above - no. Only one copy of UC. Every module is upgraded to the latest versions.

The weird thing is that I can view Product Kits that I created before the update with no trouble at all, so it seems it is just creating / updating product kits that is the problem.

jamesoakley’s picture

Title: Product kit - Call to undefined function uc_price() » Product kit - Call to undefined function uc_price() when Nodewords enabled

I've tracked this down further, by trying to create a test case that reproduces this bug.

It's nothing to do with the upgrade path from Beta5 to RC1.

Here's how to reproduce the bug. Create a new install of Drupal 6.10. Extract Nodewords, Ubercart and Token into the site's modules directory. Enable Token, the Ubercart-core modules, and Product Kit. Create a simple Product, and a Product Kit containing a single instance of that one product. The Product Kit displays fine.

Now enable Nodewords (displays as Meta Tags in the Module list).

Go to the site's homepage, which has now become a list of all the node teasers. You will see two teasers displaying - the product kit then the product. Click on the title of the Product Kit to go to its node page - (/node/2)... You get the error being reported in this bug.

All that has to be done, then, is to enable Nodewords. There is no need to set up any global meta tags, or to set up any custom meta tags on any of the nodes. The module enabled is sufficient to break Product Kits.

This is a new bug that was not present in 6.x-2.0-beta5. This can be demonstrated by continuing with the example above. Having reproduced the problem, now delete the Ubercart folder in the site's Modules folder. In its place, extract ubercart 6.x-2.0-beta5. Then open http://www.example.com/node/2, and the page displays fine.

Island Usurper’s picture

Title: Product kit - Call to undefined function uc_price() when Nodewords enabled » Fatal error: Description meta tag built before all files are loaded
Project: Ubercart » Nodewords: D6 Meta Tags
Version: 6.x-2.0-rc1 » 6.x-1.0

The problem is that nodewords_init() is building the product kit's teaser to use as a description meta tag. Unfortunately, this happens before uc_store_init(), in which uc_price.inc is loaded. In the Meta Tags settings page, you should turn off the "use teaser if description is empty" setting, as that will prevent this error from happening.

I suggest changing nodewords_init() to nodewords_preprocess_page(). This still happens before headers are sent, so drupal_set_html_head() should work there.

jamesoakley’s picture

OK. The work-around of turning off "use teaser if description is empty" works for me (as a work-around not a solution). But at least I can get my product kits to display again.

quevo’s picture

A fix for this bug would be greatly appreciated.

Every build sine Beta 6 has been quite buggy and this bug still exists in RC 2.

Where can I find the Meta Tags settings page where I'm supposed to turn off this "use teaser if description is empty" setting?

By the way, when this bug occurs, accessing the admin pages via Drupal is impossible.

Thanks

jamesoakley’s picture

@Quevo (#6)

This won't have changed from RC1 to RC2 because it is Meta Tags that needs fixing not Ubercart.

(The issue is that Meta Tags sometimes uses the pages teaser for the Description meta tag. When it does so, the whole page needs loading up before the Description tag can be formed. But, to price a product kit, we need to already have the page header in place. This won't have happened because the Description tag is formed as part of the header. So the order in which all these things are done needs changing so that the product kit price is available before the headers are printed.)

The precise setting to turn off is labelled "Use the teaser of the page if the meta description is not set.". Search for it on siteurl/admin/content/nodewords. (It comes just after the section headed "auto-keywords vocabularies").

Even when I got this bug, I could still access all of my admin pages, so that sounds like a different, probably unrelated, issue. If you can't get to the admin pages to fix the bug, the other way to stop it occurring would be to set a description for each page manually. Then the "use teaser" fall-back would never be invoked, stopping the bug from occurring.

Hope that helps

quevo’s picture

@JamesOakley

I absolutely cannot find anything labeled "Use the teaser of the page if the meta description is not set". I visited the path you indicated, which takes me to the "Content management" page, and examined every subcategory. Nothing. Even doing a substring search through the install directory, including subdirectories, turns up nothing even remotely close to that.

What module is that function and string contained in?

jamesoakley’s picture

Hmm.... That function is in the project which is known by two names: Nodewords and Meta Tags. Download from http://drupal.org/project/nodewords.

If you don't have that module enabled, then the "Call to undefined function uc_price()..." error is not being caused by Meta Tabs but by something else. When I narrowed the problem down to Nodewords, I did so by disabling modules one at a time until my Product Kit displayed without the error. I suggest you do the same, and then search the issue queue / create a new issue over at http://drupal.org/project/ubercart, as this particular bug is now assigned to Meta Tags.

See if that helps

quevo’s picture

Ok. Thanks. I don't have that module, so I guess I'll have go hunting for the culprit, as you suggest.

Island Usurper’s picture

Island Usurper’s picture

Status: Active » Needs review
StatusFileSize
new1.81 KB

It turns out I'm wrong about drupal_set_html_head() still being useful in hook_preprocess_page(). drupal_get_html_head() has already been put into $variables['head'] by template_preprocess_page() by that time. Fortunately, we can change that directly.

joshmiller’s picture

+1 I ran into this problem

cparrish817’s picture

Version: 6.x-1.0 »

Ran into the same problem with rc-2

seabrawk’s picture

I just added some text in the "Meta Tags" field, on product creation and the error went away.

Island Usurper’s picture

Marked #457174: Call to undefined function uc_price() in \Drupal6\modules\ubercart\uc_product\uc_product.module on line 1421 as duplicate.

I'd really appreciate it if someone would review the patch, and make a bug fixing release in all affected versions.

andrewfn’s picture

@quevo (#11)
I had this symptom without metatag/nodewords installed. It turned out to be a conflict with imagecache. I had to uninstall imagecache, upgrade uc and then re-install imagecache.

quevo’s picture

Thanks for your suggestion, andrewfn; however, the underlying bug appears to have been fixed by RC 3.

I had simply reverted to beta 6 and when I applied RC 3, I no longer had the issue.

glowkeeper’s picture

I just got this issue on rc3 after adding the nodewords module to the site http://www.cosyheart.com.

So I tried to apply the hook_init.patch above, but I get the following:

(Stripping trailing CRs from patch.)
patching file nodewords.module
Reversed (or previously applied) patch detected! Assume -R? [n]
Apply anyway? [n]
Skipping patch.
5 out of 5 hunks ignored -- saving rejects to file nodewords.module.rej

Am I missing something? How should I proceed?

Island Usurper’s picture

StatusFileSize
new905 bytes

Sorry, it looks like I didn't make the patch off of a clean copy. Here's a better one.

fenstrat’s picture

Patch at #22 works perfectly

Applied to nodewords-6.x-1.0 with ubercart rc3

glowkeeper’s picture

Indeed, I just got the patch at #22, and it worked perfectly with the same setup as #24.

Thanks guys :)

TrinitySEM’s picture

Same issue but when I applied the patch I then received the following error:

Fatal error: Call to undefined function uc_price() in /sites/all/modules/ubercart/uc_product/uc_product.module on line 1421

Any thoughts?

thill_’s picture

+1 to #22 patch, fixed the issue for me, Thanks

TrinitySEM’s picture

I've tried again and I'm receiving an odd error when initiating the patch.

Here's what I did:

1. placed patch in nodewords directory
2. in that directory I ran patch < hook_init.patch

Resulting message:
patching file nodewords.module
Hunk #1 succeeded at 75 (offset 4 lines).
Hunk #2 succeeded at 688 (offset 4 lines).
patch: **** write error : No space left on device

Since the patch is fairly simple I then attempted to patch manually. When I did so Drupal returns the following error:

Fatal error: Call to undefined function uc_price() in /root_path_omitted/sites/all/modules/ubercart/uc_product/uc_product.module on line 1421

I'm stuck. Any thoughts?

TrinitySEM’s picture

P.S. Neglected to mention that the disk should not be full and that I'm on Media Temple GS.

asak’s picture

Status: Needs review » Reviewed & tested by the community

Patch at #22 worked for me.

Marking as reviewed... seems like a fix.

TrinitySEM’s picture

Status: Reviewed & tested by the community » Needs review

Finally got it to work. Thank you for the patch.

avpaderno’s picture

Status: Needs review » Reviewed & tested by the community
jday’s picture

I'm not using product kit but had the fatal error after adding nodewords, #22 patch fixed it for me THANKS!

pcambra’s picture

I have run into this problem also, suscribing.

jdwfly’s picture

#22 patch worked for me.

jamesoakley’s picture

So it seems patch #22 is the one we all need. Several people have confirmed that since the patch was posted. Thank you Island Usurper.

Now all we need is for someone to commit this and in time (hopefully before too long) to release a new version of MetaTags that includes the fix. What's the process for that to happen?

avpaderno’s picture

Status: Reviewed & tested by the community » Needs work

The code the patch is supposed to change is the following:

/**
 * Implementation of hook_init().
 */
function nodewords_init() {
  $tags = nodewords_get();
  drupal_set_html_head(nodewords_output($tags));
}

That is not the actual code used by the patch, which needs to be changed.

Island Usurper’s picture

Status: Needs work » Needs review
StatusFileSize
new1.68 KB

Hmm. The changes that were put into the dev version have made this patch more intrusive than it was. I've had to modify nodewords_views_pre_render() a little bit since nodewords_add_html_head() is now returning a value instead of calling drupal_set_html_head() itself.

TheBurf’s picture

i had an issue with SimplestGMap not showing my map when i enabled the nodewords module.
I disabled the "Use the teaser of the page if the meta description is not set." and this has solved my issue

thanks so much

Starminder’s picture

subscribe

ck9’s picture

Can someone please upload the patched nodewords.module file? I don't have shell access and there's too many changes for me to manually patch it.

dogface’s picture

Had the same error #39 did not work :
patching file nodewords.module
Hunk #1 FAILED at 246.
Hunk #2 FAILED at 518.
Hunk #3 FAILED at 603.
Hunk #4 FAILED at 659.

#22 worked perfectly. Thanks!

Anonymous’s picture

Version: » 6.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

Patch from #39 works against latest 1.x-dev, error gone!
Marking as RTBC.

avpaderno’s picture

Version: 6.x-1.x-dev »
Status: Reviewed & tested by the community » Needs review

The patch is for 6.x-2; let us keep the report for 6.x-2, then.

jamesoakley’s picture

Unless a 6.x-2.x final release is imminent, the need is still there for a 6.x-1.x patch, though, because 6.x-1.x is the version in use on lots of production Drupal sites.

If patch #39 is for 6.x-2.x, please could someone produce a corresponding patch for 6.x-1.x as well, so that this can be tested, committed to CVS and then released.

avpaderno’s picture

As the two branches of this module are developed from two different people, it is better to have a different issue for each of the Drupal 6 branches.

avpaderno’s picture

-- Duplicated comment --

avpaderno’s picture

Title: Fatal error: Description meta tag built before all files are loaded » Fatal error: description meta tag is built before third-party module files are loaded
Status: Needs review » Needs work

As nodewords_add_html_head() doesn't add any HTML head tag, in the proposed patch, it would be better to change the name of the function. nodewords_get_html_head_tags() could be a better name.

avpaderno’s picture

For the 6.x-1 branch, I created another report (#506474: Replace nodewords_init() with nodewords_preprocess_page()).

Anandyrh’s picture

Please let me know how to use this Patch code which is in #22

Thanks & Regards,
AnAnD

Anandyrh’s picture

???

Anandyrh’s picture

Hi do any of you know where exactly and how exactly do i need to use the patch which is in #22?

Please let me know....

Thanks and Regards,
AnAnD

Island Usurper’s picture

Version: » 6.x-1.x-dev
Priority: Critical » Normal
Status: Needs work » Fixed

Actually, since the patches here were originally for 1.x, and since all of the duplicate issues were from people using that version, I want to just marked this one as fixed.

It's true that the 2.x branch shouldn't use hook_init(), either, so I'll either make a new issue or just reset the other issue.

Anandyrh, just use the 6.x-1.x-dev version. It has the proper fix in it.

avpaderno’s picture

Version: 6.x-1.x-dev »
Status: Fixed » Needs review

As branch 6.x-2 doesn't implement the code as suggested, it's preferable to keep this report for that branch, even if it was not originally thought for that branch; rather than having two reports for the same branch (which should both be marked as fixed), it is better to have one open for branch 6.x-2.

What I reported about the name chosen for nodewords_add_html_head() is not actually a patch problem; it's the function the module defines, and it should the module that adopts a different name for a function that has a different purpose than the original one it had.

avpaderno’s picture

Title: Fatal error: description meta tag is built before third-party module files are loaded » Replace nodewords_init() with nodewords_preprocess_page()
Status: Needs review » Active

All this thread became a little confusing.
Let us start again, and keep this report for branch 6.x-2.

EDIT: the patches you find here are for branch 6.x-1, even when the report was marked for 6.x-2.x-dev (I didn't check that before, and I assumed the patches were for the same version the report was tagged for).
The code for version 6.x-1.x-dev has been already changed as suggested in this report. The code for version 6.x-2.x-dev has not been changed.

avpaderno’s picture

Status: Active » Fixed

I changed the code, and implemented the suggested change also for version 6.x-2.x-dev.

Thanks to all for the report, and the help in finding how to correctly change the code.

kenorb’s picture

Status: Fixed » Needs work

Where people can download fixed version?
I don't see any updated version available for download.
Can you publish it as dev version or patched?
Because people still have this problem.

avpaderno’s picture

Status: Needs work » Fixed

Version 6.x-2.x-dev is available here. All the versions are available from the project page, clicking on View all releases.

kenorb’s picture

It should be published normally as dev as other modules does.
Especially if there are some bugs fixed.
Not every Drupal user is so smart to find some fixes in 'all releases' link, they using only one published version on the project page which is stable and they expecting to be stable.
It takes 5 seconds for maintainer to publish latest development version on the project page, and it could save hours for people who dealing with that issue which are not programmers.

avpaderno’s picture

The explanation of why the link to download version 6.x-2.x-dev is not listed in the project page is reported in the project page (which clearly states to not use that development snapshot).

When to make that development snapshot publicly available can only be decided from Robrecht Jacques (the actual maintainer).

Status: Fixed » Closed (fixed)

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

joachim’s picture

Please could you make a 1.1 release with this fix? It's a pretty major bug as I'm sure you can appreciate.

bryrock’s picture

subscribe

Wilhelmiine’s picture

Thank you Island Usurper!
"In the Meta Tags settings page, you should turn off the "use teaser if description is empty" setting, as that will prevent this error from happening." => it's work really!

eyeandsee’s picture

Thanks wilhelmiine... a simple solution for a major problem. works like a charm! ^_^

msosin’s picture

Try to change uc_store weight to -1 in the database ( table called system )

That worked for my error: Fatal error: Call to undefined function uc_price() in /modules/ubercart/uc_order/uc_order.module on line 1437\

Regards,

M

Plucompany’s picture

That also fixed it for me, changed uc_store weight to -1 in the database

not sure why though?

joachim’s picture

Because it makes the uc_store module load before this one, and so the function from that module is defined by the time this module's code executes.

This still needs fixing properly though -- hook_init is the wrong place for this code.

alexmoreno’s picture

upgrading nodewords solved my problem