User tests: Successful: Unsuccessful:
Suppose you have a web server using Joomla where this web server is both reachable via http://www.example.org/ and http:/example.org/. With the current implementation of the redirection plugin you need to define two redirections within the redirect manager component for every page you want to automatically redirect from its old location to its new location:
old page: http://www.example.org/path/to/old/page.html
=> new page: http://www.example.org/path/to/new/page.html
old page: http://example.org/path/to/old/page.html
=> new page: http://example.org/path/to/new/page.html
With my proposed file change it would be sufficient to define only one redirection in this case:
old server-relative page: /path/to/old/page.html
=> new server-relative page: /path/to/new/page.html
Labels |
Added:
?
|
The tabs are fine for chained method calls.
thanks @jo-sf
but atm i can't get it work.
First blog post
artikle on the BackendBut never we jump into your if
as $link
contain every time a value.
But also if i force it to use it (place a $link = NULL
bevor the if statment) it don't work well.
Or i miss somthing/do things wrong?
about the tabs at line 75: I removed them a minute ago (they came from editing the file in the github web interface: if you open a new line below an indented line this new line is automatically filled with as much tabs as has the previous line, and these tabs are not removed even if you leave the line apparently empty it still contains the tabs automatically placed there).
about your failed test: I have to investigate and then I'll come back and leave a comment here.
zero-24, are you complete sure that the complete redirection path (http://localhost/cm45/...) is no longer registered in the redirect plugin and that your browser isn't fooling you? If you've tried it before within the same browser session (and maybe even after restarting the browser - depends upon the way your browser caches redirects it received before) your browser probably didn't send the URL to the server but took the redirection information from its cache.
According to the source code in redirect.php this plugin by default searches only for the complete URL including scheme, host, port, path, query and fragment, and only if it finds this complete URL in the database table '#__redirect_links' it will use the new URL found there (currently there is no restriction upon the new URL, it might be a full URL or a server-relative URL).
A query with the where clause
old_url = 'http://localhost/cm45/index.php/park-blog/17-first-blog-post.html'
should never find an entry in the '#__redirect_links' table where the field 'old_url' contains only
/cm45/index.php/park-blog/17-first-blog-post.html
(at least I would expect that the database is not so smart to match these two strings).
zero-24, are you complete sure that the complete redirection path (http://localhost/cm45/...) is no longer registered in the redirect plugin and that your browser isn't fooling you?
Woops my browser was it. I have now try it with Chrome and Opera instead of FireFox and it don't work.
So my setup is the following:
First blog post
is disabled.Without your patch
With your patch
I think the issue is located here
if (!$link)
[...]
We never get in this if
as this condition don't work, it works if we add a line like $link = NULL;
bevor the if
statement.
Well then what is the result of
$link = $db->loadObject();
if the query set up in lines 68ff. returns no results at all?
I looked at the 'if' statement in line 90 (line 77 without my patch)
if ($link and ($link->published == 1))
and assumed that '$db->loadObject()' returns NULL if there is no match in the database. At least I would understand the documentation in
libraries/joomla/database/driver.php
in line 1225ff. in this way.
Is there anything I'm missing here?
I think I finally found what's the problem here: the search might also find a redirect entry which is either not published or even in the trash - but a match is a match, and $link points to an object.
Due to that I changed my code from
if (!$link)
into
if (!$link or ($link->published != 1))
which works well for me even if there is an unpublished redirect or even a trashed redirect in the database and a valid redirect Joomla shall use. The only disadvantage is that for every invalid URL the plugin first checks whether there is an entry in the database with the complete URL, and if there is no such published entry it repeats the search with the server-relative URL.
Can you please test whether this change works for you as well?
thanks @jo-sf it works now good here.
This comment was created with the J!Tracker Application at http://issues.joomla.org/.
Category | ⇒ | Front End Plugins SEF |
Easy | No | ⇒ | Yes |
Category | Front End Plugins SEF | ⇒ | Front End Plugins |
@test all good! Good job.
This comment was created with the J!Tracker Application at http://issues.joomla.org/.
Status | Pending | ⇒ | Ready to Commit |
thanks @b2z moving to RTC
This comment was created with the J!Tracker Application at http://issues.joomla.org/.
Labels |
Added:
?
|
Status | Ready to Commit | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-10-10 12:17:27 |
Labels |
Removed:
?
|
Sorry but what do mean with "here we need to remove the tabs"? The lines 68 through 72 are not part of my patch but were instead the original staging code, and I simply copied this code into the lines 80 through 84, indented it with an additional tab and changed "$current" into "$currRel".
I would even argue that the statement starting with "$query =" and being continued over the next 4 lines is better readable if the continuation lines are indented with one additional tab.