Parse error: syntax error, unexpected $end in /sites/all/modules/search_api/search_api.admin.inc on line 1924
I tried using php version 5.3.2 and 5.2.5. I'm not sure how this is happening, since that line is actually the end of the file. Strangely enough on my mac the module works with only minor indexing problems. I only installed the module and activated the database search engine.
I even tried this with a clean install I did have some other modules installed though.
ctools
date
email_registration
entity
field_group
libraries
pathauto
profile2
search_api
superfish
token
views
If you need more info just let me know.
Comments
Comment #1
drunken monkeyThis is really weird. Syntax error practically can't be the result of special configuration or such things, they are actual errors in the file itself. The one you posted refers to a quoted string or a control structure not correctly closed.
However, if this would be the case, no one else could use that version, including me. Since it worked for everyone else, this has to be some weird bug on your end. Maybe downloading didn't work correctly for some reason? Could you maybe control the checksum of the downloaded release archive, and/or re-download the module?
You could also try to only parse the one PHP file, on the command line (with "php search_api.admin.inc") to see if this also produces the error. Otherwise, it would probably be a malfunction of yyour web server, though I don't know what could cause such a thing.
In any case, I'm very sure that the module itself isn't guilty here.
Comment #2
emagus commentedi am getting the same error.
actually with any version i tried, i.e. beta 7 & 8 as well as the latest dev
Comment #3
drunken monkeyOK, that's really bad. Then there probably really is something the problem with the file itself …
Could you execute the file on the command line, as suggested above?
If this triggers the error, you could then incrementally remove functions from the end of the file to see which is the one containing the error. (When doing this with the web server, you should do it on the Search API overview page, as that reduces the chance that you'll get a "function not found" error before the other one disappears.)
Comment #4
emagus commentedthe error disappears when i remove this function: search_api_admin_index_fields_submit
when executing the file outside of its environment.
Comment #5
emagus commentedi found this weird line in that function:
line 1759: $name_prefix .= $wrapper_info['label'] . ' » ';
Could that be related to the problem?
Comment #6
drunken monkeyThanks for finding this out! Now I spotted the problem – it's the two characters "%>" in the comment, which will end the PHP block for some (deprecated) php.ini configurations (i.e., "asp_tags = On").
The attached patch should fix this.
The "»" merely means you are viewing the file with a wrong file encoding (right is UTF-8).
Comment #7
emagus commentedworks! Thank you :-)
Comment #8
emagus commentedhm getting the same error, when I try to set db server now:
Parse error: syntax error, unexpected $end in .../sites/all/modules/search_api/contrib/search_api_db/service.inc on line 676
turned asp_tags off btw
Comment #9
drunken monkeyGreat – committed.
Comment #11
danielnolde commentedFor any passers-by who struggle with similar "unexpected $end" PHP errors: This is a very very ver strange error which happens sometimes in conjunction with vm images, with php files that live in a mounted host system directory but are programmatically created/downloaded inside of a vm image (like "drush dl"-downloaded or "drush fu"-updated files). Can't explain what's actually going on there, but the workaround is easy: Delete and Re-Enter the file's last line (jump to the end of the erroneous file, press backspace, then press return).
If anybody knows more about this, contact me!!!