I just installed advertisement-module on my testsite and all worked well. So I upgraded my live site (as I was doing that and needed to replace the banner-module). However the banner now points to http://www.example.com/testsite/?q=ad/redirect/200/ and since my testsite is offline that leads to the offline message.
My site settings seem to be fine, so I was wondering how to solve this the best way?
Thanks!
Robin
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | ad-dropredirect-column-2.patch | 12.58 KB | john franklin |
| #21 | ad-dropredirect-column.patch | 9.8 KB | john franklin |
| #14 | ad_D5-146319-14.patch | 1.38 KB | agileware |
Comments
Comment #1
jeremy commentedIf you copied the database data from your test site to your live site, then you've got stale URLs in your ads table. You'll need to go through and manually fix the "redirect" column in that table for each ad, fixing the base url of each.
Comment #2
rvk commentedThanks for your quick reply Jeremy! I will follow your advice and correct the table manually. It's a pity though as I would like to see modules in general take care of something like that in the background.
On the whole however, I like the module a lot and wished I had discovered it sooner!
Robin
Comment #3
jeremy commentedI was looking at this section of the code earlier during an unrelated fix and believe it would be possible to not store the entire URL in the database. This would solve your problem as then the data would not be tied to a specific domain, so moving this to a feature request.
Comment #4
fax8 commentedMaybe I missed something but I don't understand the needs for storing the whole redirect path in the db.
Let's look the db contents:
Given an aid=NNN the link is always the result of url('ad/redirect/NNN').
The redirect link could be created at load time.
I'm still not an expert in the ad module but maybe this could be done
changing the line
into
Having path hardcoded into the database is IMHO a bad approach as it will give problems
any time a drupal site is moved.
Hope this helps,
Fabio Varesano
Comment #5
jeremy commentedI plan to clean this up soon, assigning to myself as a reminder.
Comment #6
jeremy commentedThough certainly possible, there's some extra logic needing to be added if we don't pre-build the redirect URL. The problem being that there are multiple ways to serve ads, and they may come from several different base paths -- I need to give more thought on how to cleanly handle this (simply calling url() when we want to display an ad is not sufficient). I'd hoped to include this in the next release, but it looks like not.
Comment #7
sunInteresting. Could you please elaborate on why calling url() is not sufficient?
Comment #8
jeremy commentedBecause the base_path will be different depending on if you call url() from the main drupal/ directory, or if you call it from drupal/sites/domain/modules/ad/ subdirectory (such as when serving advertisements from adserve.inc).
Comment #9
sunJust an idea: How about registering a menu item like this, to allow serving ads both from
ad/redirect/#andpath/to/adserve.inc/redirect/#?Comment #10
dchaffin commentedOn or around line 948 (in the function: ad_nodeapi), change the line ...
db_query("INSERT INTO {ads} (aid, uid, adstatus, adtype, redirect, autoactivate, autoexpire, activated, maxviews, maxclicks) VALUES(%d, %d, '%s', '%s', '%s', %d, %d, %d, %d, %d)", $node->nid, $node->uid, $node->adstatus, $node->adtype, url("ad/redirect/$node->nid", array('absolute' => TRUE)), $node->autoactivate ? strtotime($node->autoactivate) : '', $node->autoexpire ? strtotime($node->autoexpire) : '', $activated, (int)$node->maxviews, (int)$node->maxclicks);... to ...
db_query("INSERT INTO {ads} (aid, uid, adstatus, adtype, redirect, autoactivate, autoexpire, activated, maxviews, maxclicks) VALUES(%d, %d, '%s', '%s', '%s', %d, %d, %d, %d, %d)", $node->nid, $node->uid, $node->adstatus, $node->adtype, url("ad/redirect/$node->nid", array('absolute' => FALSE)), $node->autoactivate ? strtotime($node->autoactivate) : '', $node->autoexpire ? strtotime($node->autoexpire) : '', $activated, (int)$node->maxviews, (int)$node->maxclicks);... that changes links to store as "/ad/redirect/1" instead of using the entire URL.
Comment #11
jeremy commented@dchaffin: please see #6 and #8 for details as to why this is not sufficient.
Comment #12
jeremy commentedThis still needs to happen. Moving to the latest development branch.
Comment #13
liquidcms commentedyup, i'm with sun, although not looked through code, not sure why url() isn't sufficient... but mostly just subscribing.
Comment #14
agileware commentedHere is a patch that assists with this.
It just makes the redirect url get updated on node update as well as node insert.
It doesn't fully address the issue but at least if you then re-save your ads (you can do it with views bulk operations if you have a lot of ads) the redirect url will get fixed.
It is for 5.x-1.x-dev.
I believe the D6 branch already has this functionality.
Comment #15
liquidcms commentednope, this is missing in D6 version - which is why i think rvk posted this issue against 6.x
Comment #16
agileware commentedThis is the sql for the update op in ad_nodeapi()
The part for the redirect field is the same as it is for the insert op - url('ad/redirect/'. $node->nid, array('absolute' => TRUE))
This is in 6.x-2.0 and 6.x-2.x-dev
That is all I fixed for D5 in the patch in #14 and it is already done in D6.
There are still other issues being dealt with in this issue though as I believe the people in here are aiming to have this problem addressed at the point of serving the ad (so that the database doesn't store the full url).
Comment #17
MadOverlord commentedThis issue just bit me when I moved my new site to a live server.
Suggest that in the short term, this behavior should be prominently documented in the README and on /admin/content/ad/list, ie:
Note: The ad module currently stores a complete redirection path in each ad, not a relative path. If you move your site to a new domain, you should edit each ad, then save it; this will update the path.
Another possibility might be a kludge that lets you update all the paths at once. That would make pingponging between the live and test server less of a pain.
Comment #18
sepla commentedIMO it's a critical feature request! subscribing.
Comment #19
joachim commentedThis is a bug report.
This really is a WTF in the module code -- it completely goes against Drupal conventions. Drupal NEVER stores full URLs to the site itself, ALWAYS paths. Otherwise the whole menu system would break.
Comment #20
ccoppen commentedI like this module, but I may have to not use it if this issue isn't fixed soon. This is definitely a no-no for a CMS IMHO. We're about to go live with our revamped site and with the urls pointing back to my test site from the live site, this will hurt. I can't go through each ad and save them individually to get the url to save correctly. There's too many ads and I'm only the developer, not the content editor. I can't expect content editors to edit ads in two places.
Comment #21
john franklin commentedThe redirects can be computed on the fly, but we need to remember the base URL of index.php, not serve.php. Attached patch is a first crack at it. I've tested it with the image and text ad types.
Comment #22
jeremy commentedIt is great to see forward progress on fixing this issue, as it's quite an annoyance that I've been meaning to fix for ages...
Some feedback from an initial read through the patch (I've not tested it yet):
Overall it looks like it should work. Once you cleanup the above, I'd be happy to test it.
Comment #23
john franklin commentedRerolled with cited changes.
Comment #24
john franklin commentedHas anyone else been able to test this?
Comment #25
lrwebks commentedDrupal 6 is EOL and no longer supported. Closing this as outdated for that reason. Thanks for your contribution!