I have everything configured correctly, and I double checked by just putting adsense code into a blog, but everytime I try to use the Adsense module the comment in the HTML document says its disabled. It is enabled in both the database and through the admin interface.

CommentFileSizeAuthor
#12 adsense-cache.patch2.7 KBdarren oh

Comments

SalattiNET’s picture

Isn't there any way/hack to fix this (i got the same problem)?

kbahey’s picture

1. Clear your cache (run "DELETE FROM cache;" from phpmyadmin or mysql).

2. Try adsense in a block first, then try the embedded code (which requires filters).

3. Log off and see if the ads appear (they are disabled for the admin).

Post what you find ...

SalattiNET’s picture

I have tryed what you said, but I got the same problem... A comment in the HTML code saying that ads ar disabled....

greggles’s picture

Are you sure that all of the settings like your google id and channels and such are correct?

Also, is it possible for you to just copy/paste the javascript adsense code from the adsense website into an "html filtered" block on your website - does that code work?

SalattiNET’s picture

-Are you sure that all of the settings like your google id and channels and such are correct?
Revenue sharing is turned on (I have tryed to turn it off but it was the same).
My Google ID is "pub-" followed by 16 numbers.
Custom Channels are left blank ("If you are not using Custom Channels, or you are only using URL channels, then leave this empty").

-Also, is it possible for you to just copy/paste the javascript adsense code from the adsense website into an "html filtered" block on your website - does that code work?
Yes, this way it works.

kbrune’s picture

I am not 100% sure if I am expiriencing exactly the same phenomenon, however...

1) AdSense module has worked for me previously in blocks, but not with inline code.

2) Suddenly AdSense is displaying the PlaceHolder, both for inline and in blocks.

The only possible culprit I can think of is my recent minor upgrade from 4.6.3 to 4.6.5 (yeah I went through 4.6.4 as well). Note that pasting AdSense code into node text directly from www.google.com/adsense works perfectly, so it's definitely module-related. Going to have a peek at the source code now to see if I can offer suggestions.

I would REALLY love to get this resolved, as I'd rather not skew Googles display stats and really like having those placeholders when I'm logged into my admin account.

kbahey’s picture

Guys.

I am on 4.6.5 myself, and it is working fine for me for two sites.

I have it in blocks and custom blocks as well (see http://baheyeldin.com for example).

Inline code depends on your filter settings, what other filters you have, and what order they are in.

Check that you have this at the top of the module:

//$Id: adsense.module,v 1.25.2.8 2006/01/15 20:42:57 kbahey Exp $

If you do not have the same version and date, then download the latest version and install it.

trombone’s picture

Hi,

I had the same problem before.

I created a site with an only an admin account. All other site visitors where treated as anonymous users and had no priveleges for any content creation.

Ads in blocks were working fine but the inline Ads always showed the placeholder.

I found out that inline ads that are placed into content (book pages in my case) when using the admin account always end up in the cache nomatter what caching setup you have. Since the admin account always generates the placeholder iso the ad itself, the placeholder view is cached.

By creating a second account with the needed priveleges to create content I got around the problem.

Since then I only use the "number 1" account for site settings and the secondary account for content creation. This works fine for me.

I hope this gets you going. Good luck !!!

budda’s picture

I've just been investigating this very problem (before reading this thread).

Trombone is correct!

The problem lies in the function _adsense_check_if_enabled().

Here a check is done to see if the user_access('hide adsense') permission is enabled. As user 1 always has rights to everything (the 'superuser') then this permission is going to return TRUE. And because it does, the function _adsense_check_if_enabled() ends up returning FALSE, even though variable_get(ADSENSE_DISABLE, '0'); is 0 and NOT 1.

The Adsense filter method only checks the above permission when saving the node content. When viewing the content it pulls the output from the Drupal cache. So as it currently stands the node content caches the "placeholder" output from the adsense.module.

It's a bug, but how do we get around this? I've been experimenting this evening but not found a suitable solution yet. The main problem being the caching done by the Drupal filter system upon saving node content.

kbahey’s picture

Good detective work budda.

One frustrating thing developers often face is when people report bugs that are vague.

They have to describe EXACTLY what they are doing, EXACTLY what they expected to happen, and EXACTLY what they see.

Your description is now clear in that the problem they are seeing is with the adsense tags in the content.

Anyways, yes, Drupal caching is what gets us here. Don't have a solution either.

Keep brainstorming.

budda’s picture

Solution is in my patch http://drupal.org/node/50694

I would have posted it shortly after my previous follow up, but Firefox froze on me via a remote terminal and I was stuck until I came in to the office today!

Anyway, enjoy the fix!

darren oh’s picture

Assigned: Unassigned » darren oh
Status: Active » Needs review
StatusFileSize
new2.7 KB

budda, as I'm sure you know by now, the bigger a patch is, the lower its chance of being committed. I've modified your patch to deal with just this issue.

darren oh’s picture

Version: 4.6.x-1.x-dev » 4.7.x-1.x-dev

The patch seems to have been made for 4.7.

darren oh’s picture

Priority: Critical » Normal
darren oh’s picture

From issue 50694:

The side effect is that uid #1, and anybody who has "hide adsense" permission WILL see the ads embedded in a node body.

There doesn't appear to be a way around this using the current Drupal filtering system.

This makes the fix a lot less attractive. Since Darren Matthes provided this ingenious solution, I'm tempted to consider this a support request.

darren oh’s picture

There's an excellent description of the problem in issue 93483 (marked as a duplicate of this issue).

mcurry’s picture

Just adding this to "My Issues" queue. (Wish there was an easier way)

jjeff’s picture

subscribing

jjeff’s picture

Version: 4.7.x-1.x-dev » 4.7.x-1.0

It turned out that the reason I was experiencing this behavior was that I had enabled the "hide adsense" permission for my role. This is a bit counterintuitive -- since it's basically a "no access" access permission. Seems like this should really be handled on the node settings page rather than the user access page.

Also, I could be wrong... and I haven't tested... but a call to user_access('hide adsense') should always return TRUE for uid 1. This means that if you are logged in as user 1, adsense will always be disabled.

(I'm using the 5.x dev version)

kbahey’s picture

That is the intended behavior: the site owner does not see the ads so that she cannot click it by mistake and hence incur Google's wrath.

This is why it is "hide adsense" and not "show adsense".

Once you log off, you should see the ads again.

Back to the original problem : Ads in block work fine, regardless. This is how I use the module myself on several sites.

The issue is with filter ads, and like any filters they get cached. Did anyone test Budda's patch in #12? If it works and is backwards compatible, then I am willing to commit it.

rockgeek’s picture

I got latest official Drupal and latest Adsense module but when I log in as the user who activated the module and done all the configuration, the ADs are not showing but when I create another user with the same privs. the ADs appear.

Nothing too bad, just a tad annoying as I thought nothing was working.

jcnventura’s picture

Status: Needs review » Closed (fixed)

The latest version no longer saves data to the cache, so this is not relevant to any of the currently supported versions.