Broken Links on Sub-Directory Installations

Bug #240041 reported by Phillip Barnes
2
Affects Status Importance Assigned to Milestone
ideatorrent
New
Undecided
Unassigned

Bug Description

The "QA-Website top navigation bar" and possibly other links within the module do not load the correct URL's in sub-directory installations. All links in the module include the domain name without the sub-directory.

For example, the sub-directory installation's login links should be:
http://www.example.com/sub-directory/user

...when Brainstorm is installed in "sub-directory". Currently, the broken link is:
http://www.example.com/user

Revision history for this message
Phillip Barnes (pbarnes) wrote :

I don't know bzr enough to create a patch, but here are the edits I made to "qawebsite.block.php". I basically added the global $base_url to every link:

----------------
function qawebsite_block_navigation() {
 global $user, $base_url;
 $site=QAWebsiteSite::getInstance();

.....
     <table class=\"qawebsite_topbar\">
      <tr>";
       if ($user->uid != 0) {
        $content.="<td><b>Welcome, " . $user->name . "!</b></td>";
        if (user_access("Administrator"))
         $content.="<td><a href=\"" . $base_url . "/admin\">Admin</a></td>";
        $content.="<td><a href=\"" . $base_url . "/qawebsite/profile\">My profile</a></td>
             <td><a href=\"" . $base_url . "/logout\">Log out</a></td>";
       }
       elseif (variable_get("user_register",1))
        $content.="<td><a href=\"" . $base_url . "/user\">Log in</a></td>";

----------------------

Revision history for this message
Phillip Barnes (pbarnes) wrote :

I used the command "bzr bundle > subdirectory-install.diff" to create what I believe to be a patch of my edits. Please let me know if this is how I'm supposed to make patches.

Revision history for this message
Nicolas Deschildre (ndeschildre) wrote :

Hi!

Thanks for hacking Brainstorm a bit!
Concerning patches, you have two choices: you can either make "bzr diff > patch_name.patch", or the command you found, but you will have to commit first (otherwise your bundle is empty :) )

Concerning your changes, unfortunately, while they are working OK, they are not good by design : $base_url is a variable specific to the qapoll module, while qawebsite is a module used by qapoll, but also qatracker : that means that if you use qatracker, the $base_url will be empty, and your changes will not work.
In fact, qawebsite was not designed to be accessed via sub-directory. It can be *hosted* in a subdirectory (like the current Brainstorm setup), but we are using a htaccess file so that brainstorm.ubuntu.com/path is linked to brainstorm.ubuntu.com/some/subdir/paths.

So you have three possibilities:
- Either you decide to use an htaccess file to do the above described trick. No more need of this change.
- Either you want to let brainstorm use a sub-directory URL
 - You can just use the hack you did, no problem, it look fine for a brainstorm-only installation
 - You can try to adapt qawebsite (including its SQL table) to handle correctly a sub-directory, in a way that will work with qapoll and qatracker. Harder, if you don't know the code.
Any solution is fine with me!

Thanks, if you have others patches idea, please give a try!

Nicolas

Revision history for this message
Phillip Barnes (pbarnes) wrote :

I read somewhere that the $base_url is a variable should work on all modules and themes because it is part of Drupal's.

Researching this, I just discovered the base path API. This will only include the directories of the drupal installation, making webpages smaller than usin $base_url.

See Link Below for More Info:
http://api.drupal.org/?q=api/function/base_path

Revision history for this message
Nicolas Deschildre (ndeschildre) wrote :

Oh, sorry, I read quickly the code, and I though the $base_url referenced the base_url column of the qapoll_entry_point variable.
Indeed you're right, the global variable $base_url points to the base of the installation specified in the drupal setting file. So it does work for a single domain drupal installation.

But it's still not good :=)
The problem is that the same drupal installation is used for multiple websites (listed in the qawebsite SQL table). For now, we have brainstorm.ubuntu.com, blog.qa.ubuntu.com, iso.qa.ubuntu.com, and later some more. So for each of these domains, the links shall use the corresponding domains.

Something I see to correct this issue would be to add a "base_url" field to the qawebsite_site table, and here, you would set the complete base path for each of the websites.

Revision history for this message
Stéphane Graber (stgraber) wrote :

Moving to ideatorrent even though it looks like a qawebsite issue. The qawebsite module has been deprecated on all websites besides brainstorm.ubuntu.com.

affects: ubuntu-qa-website → ideatorrent
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.