I have created an update script in hook_update_N where I have to create relative urls from absolute url.
For eg :
relative url = /files/test1.jpg
absolute url should be http://localhost.mysite/files/test1.jpg
I know these possible solutions,
- file_create_url()
- url()
- $_SERVER['host'], $_SERVER['server_name']
But none of them is working in the update script.
Possible Reason : Script isn't executed from browser. So there isn't request from which you can resolve server name etc.
The above solutions work fine if I run the script from browser instead of terminal.
Is there any other way we can create absolute urls in hook_update_N so that it works when I run the script from terminal?