We've set up autocomplete entity reference fields. These work fine on the default domain, but when using them in a subdomain we get the following error:

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: http://example.com/entityreference/autocomplete/single/field_name/node/c...
StatusText: error
ResponseText:
ReadyState: 0

We've tried adding both node/add/* and entityreference/autocomplete/* as special page requests to no effect.

We also have an Image field using Media file selector. Users can complete the upload photo process in the main domain, but not in subdomains.

1. User clicks on "Add"
2. From the dialog box browses for an image on their computer and uploads
3. User clicks on "Submit"
4. Sees message "The file filename.jpg was uploaded", but the rest of the dialog box is blank

The only way to get out of the dialog box is to click away and then hit Esc. The image did upload, and the user can then click on "Add" again and choose it from My Files. Unfortunately it's adding steps and there's no way to let the user know they need to do this.

These may be two completely different issues, but since they're both happening only on subdomains I thought they might be related.

Thanks!

Comments

agentrickard’s picture

Category: bug » support
Status: Active » Postponed (maintainer needs more info)

I think they are related. Do your primary and subdomains share a cookie? That is, are you using example.com and one.example.com?

Otherwise, this looks like a cross-domain JavaScript issue.

A list of the domains (even obscured) will help in debugging.

agentrickard’s picture

Do you have any idea why the argument in the path error is NULL?

agentrickard’s picture

The request should be something like:

http://example.com/drupal-7/entityreference/autocomplete/single/field_er...

If you typed 'a' into the box. This smells like an error somewhere else.

agentrickard’s picture

What version of Media may matter as well. I couldn't replicate the error using 7.x-2.x-dev. I could not replicate the Entity Reference error at all.

I like using the Firefox extension "Live HTTP Headers" to examine the AJAX requests that are being sent. Those may give you a clue as to the issue.

thelocaltourist’s picture

@agentrickard Thank you for the prompt response. I was unable to check back yesterday.

#1 Yes, they do share cookies. At this point I have just two. thelocaltourist.com (default) and chicago.thelocaltourist.com

#2 No. It happens as soon as I start to type something in to the entityreference field when I'm on the subdomain

#3 Looks like it might be an entityreference issue? Except it's working on the main domain.

#4 Using Media 7.x.-2.x-dev. I'll install that extension and check back!

agentrickard’s picture

I couldn't replicate either issue locally. I suggest examining the headers to see where the requests are going.

thelocaltourist’s picture

Done. There are TONS of requests. What should I be looking for?

(Sorry for the noob questions.)

I think I found it.

Headers for entityreference field from main domain:

http://example.com/entityreference/autocomplete/single/field_where_multiple/node/article/NULL/rockit

GET /entityreference/autocomplete/single/field_where_multiple/node/article/NULL/rockit HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 AlexaToolbar/alxf-2.17
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
X-Requested-With: XMLHttpRequest
Referer: http://example.com/node/add/article
Cookie: OAID=a58543dcc469f8314b267f6b907279a6; __qca=P0-1970356046-1316437228444; __utma=118790934.930275272.1326040707.1362175911.1362232382.373; __utmz=118790934.1343603832.206.5.utmcsr=d7.example.com|utmccn=(referral)|utmcmd=referral|utmcct=/admin/content/backup_migrate; hubspotdt=2011-09-30%2013%3A01%3A10; hubspotutk=ffbe581638a74d979b90bbdb86e614d2; __utma_a2a=5823167385.1348166668.1316609742.1319894200.1320073170.44; __utmv=118790934.authenticated%20user%2Ccontributor%2Cadmin%2Cintern%2Caffiliate|1=User%20roles=authenticated%20user%2Ccontributor%2Cadmin%2Cintern=1; awpopup_1244465735=1; Drupal.tableDrag.showWeight=0; __atuvc=0%7C5%2C95%7C6%2C25%7C7%2C330%7C8%2C285%7C9; __gads=ID=ee3f5552c033a46d:T=1357510968:S=ALNI_MYI5N1MUkyqnIlwWu0nraOadlJbaw; SESSa67d953d369045837cbb0425f638a638=7KoFW0klWOhd-W35vTrw-FnHSVzTn0qnvrOETf6DeZk; SESS417d140cf07b146b89d99969df7920af=ntiViT6poXMQS6Sv5YZFMva40MpSg5dlLRPGjoa0Kzk; DRUPAL_UID=1; has_js=1; __utmb=118790934.7.9.1362232882980; __utmc=118790934
Connection: keep-alive

HTTP/1.1 200 OK
Date: Sat, 02 Mar 2013 14:24:25 GMT
Server: Apache
Vary: Cookie
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Sat, 02 Mar 2013 14:24:25 +0000
Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0
Etag: "1362234265"
Content-Language: en
X-Powered-By: PleskLin
Content-Length: 247
Connection: close
Content-Type: application/json

Header for entityreference field for subdomain:

http://example.com/entityreference/autocomplete/single/field_where_multiple/node/article/NULL/rockit

GET /entityreference/autocomplete/single/field_where_multiple/node/article/NULL/rock HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 AlexaToolbar/alxf-2.17
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://subdomain.example.com/node/add/article
Origin: http://subdomain.example.com
Connection: keep-alive

HTTP/1.1 200 OK
Date: Sat, 02 Mar 2013 14:28:30 GMT
Server: Apache
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Sat, 02 Mar 2013 14:28:30 +0000
Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0
Etag: "1362234510"
Content-Language: en
Set-Cookie: SESS417d140cf07b146b89d99969df7920af=z6SVUEJQ5ELFKgojYiIk8Do7Rb5cFVSexBwVTNGXCew; expires=Mon, 25-Mar-2013 18:01:51 GMT; path=/; domain=.thelocaltourist.com; HttpOnly
X-Powered-By: PleskLin
Content-Length: 1345
Connection: close
Content-Type: application/json
thelocaltourist’s picture

UPDATE on Media Browser issue.

It appears this is an issue with the Media module. When I try to upload photos using the Media File Selector in a subdomain I get this error:

Error: Permission denied to access property 'Drupal'
http://example.com/sites/all/modules/media/js/media.popups.js?v=7.x-2.0-...

There's a new dev version of Media out today so I'll update and report back.

UPDATE:
Updated Media Module to latest dev version and no effect.

I'm using EntityConnect module and when I try to add a new node from the subdomain it redirects to the main domain. It seems that what's happening is when I try to connect to any content using the Media and entityreference modules from the subdomain it's redirecting to the main domain.

I'm using the Domain Variable module instead of Domain Settings, Configuration, and Theme and I'm wondering if that is what's causing these issues?

UPDATE:
Disabling and uninstalling Domain Variable and enabling Domain Settings, Configuration, and Theme had no effect.

UPDATE:
The Ajax error pops up on ANY autocomplete field, not just entityreference fields.

agentrickard’s picture

Status: Postponed (maintainer needs more info) » Active

That Media module error is a JavaScript cross-domain request issue.

The entity reference issue is odd, as the request should not be going to the default domain.

Is it possible that your domains / DNS simply isn't responding properly? What does the provided Server Information block tell you when you think you are on a subdomain?

I'm suspecting something in your server environment, otherwise this issue would be more prevalent. (And I would know, since I work with one of the maintainers of Media module,)

thelocaltourist’s picture

According to the server block everything points to the subdomain. HTTP_HOST request and subdomain both have proper subdomain.example.com, and the machine name is correct also.

Is it possible that your domains / DNS simply isn't responding properly?

Definitely, but I wasn't sure what to look for. I have a dedicated Centos server running Parallels Plesk. I thought wildcard DNS was enabled, but I think I'm going to have to treat it like a VPS and specifically create subdomains. I tried creating a wildcard subdomain and it broke files directory access!

Thanks for your help troubleshooting this.

thelocaltourist’s picture

I tried treating this as a shared hosting environment. I created a wildcard subdomain that directed to the root drupal installation. I also created the specific subdomains and pointed them to the root drupal installation. I updated VirtualHost in the httpd.conf. I've cleared caches.

All content is being served properly on the subdomain. The problem is when there are any ajax requests they're terminated abnormally, the path is to the main domain, and the end of the path is NULL and the media upload isn't working as mentioned above.

I'm stumped! It would seem I need expert help to figure out what's wrong with my DNS setup, but I'm not even sure how/where to ask.

agentrickard’s picture

Well, if the AJAX request is being sent to the primary domain, that would suggest that some piece of Drupal code is forcing that absolute URL. Check for modules that implement hook_form_alter() or hook_menu_alter() or hook_url_rewrite_outbound_alter(). (Aside from domain access of course).

Failing that, you could put a debug into the function making the AJAX request. That should tell you something.

agentrickard’s picture

Status: Active » Closed (cannot reproduce)
duaelfr’s picture

For people looking for this issue I ran into and lost a lot of time to understand it.
My settings.php was defining $base_url = 'http://www.example.com'; while my webserver was redirecting all to example.com. Changing my $base_url fixed the issue.

chanac_hares’s picture

Hi all,
I have the same problem ...
How exactly should i change my $base_url on settings.php
actualy : $base_url = 'http://monsite.fr'