Jump to content

Jumplinks


Mike Rockett

Recommended Posts

New commits to the dev branch synced. Fixed the select statements, as mentioned above (still working here). Also, if the import from ProcessRedirects gets botched somehow, you can now try again. It doesn't keep track of the state of ProcessRedirects, so if you uninstall and reinstall it, the importer will still offer you the opportunity. However, that isn't an issue in my eyes as such a process-flow is not practical.

Hoping to merge into master as soon as possible. I'll give it another day (or just less, keeping in mind the severity of the issues encountered with the current 1.1.3) for more feedback until I merge.

  • Like 1
Link to comment
Share on other sites

Before I merge, I'd actually like to discuss the behaviour of the new selectors feature.

In its current state, you specify a selector in your destination path using square brackets ([[your-selector-goes-here]]). However, you can also use multiple selectors, and prepend and append to them, which I don't think it actually the right way to do it. Prepending a string to a selector will cause a redirect to a non-existent page. As such, I propose the following:

Instead of using double-square brackets to return the URL of the new destination page (using $page->url), I think it should return the name. This is handy when you want to redirect /blog/2015/<oldname> to /journal/<newname>/, for example.

Then, to return a full URL, we should use use find: as a prefix to the selector - find: template=basic-page, legacy_name={name}, for example.

post-2289-0-13332000-1429352189_thumb.pn

What do you think?

  • Like 1
Link to comment
Share on other sites

@Mike - this is really great, especially the new features;

and a lot of care went into the documentation, and is much appreciated.. i hope others will find this useful!

will be upgrading that site i was testing on and report back any issues.

  • Like 1
Link to comment
Share on other sites

@Macrura

Thanks - I'm glad you're liking it. Yeah, documentation is pretty important to me, and so I make sure I do it to the best of my ability. Originally, I wanted to host the documentation myself, but thought the GH wiki system would be perfect enough for the task.

Regarding the selectors, I'm going to leave the implementation as-is for now (as mentioned in the docs).

  • Like 2
Link to comment
Share on other sites

Small update committed to dev branch: Debug Mode now shows conversion notes for each wildcard, as in the example below. This gives a little more insight, which I think is quite useful.

Page not found; scanning for jumplinks...
- Checked at: Fri, 24 Apr 2015 12:18:16 +0200
- Requested URL: http://processwire.dev.local/Articles/2015/4/24/Hello%20World.HTML
- PW Version: 2.5.27

== START ==

[Checking jumplink #12]
- Original Source Path:         Articles/{year}/{month}/{day}/{all}.{ext}
- After Smart Wildcards:        Articles/{year:num}/{month:num}/{day:num}/{all:all}.{ext:ext}
- Compiled Source Path:         Articles/(\d+)/(\d+)/(\d+)/(.*).(aspx|asp|cfm|cgi|fcgi|dll|html|htm|shtml|shtm|jhtml|phtml|xhtm|xhtml|rbml|jspx|jsp|phps|php4|php)
- > Wildcard Check:             1> year = 2015 -> 2015
- > Wildcard Check:             2> month = 4 -> 4
- > Wildcard Check:             3> day = 24 -> 24
- > Wildcard Check:             4> all = Hello%20World -> hello-world
- > Wildcard Check:             5> ext = HTML -> html
- Original Destination Path:    blog/{all}/
- Compiled Destination Path:    http://processwire.dev.local/blog/hello-world/

Match found! We'll do the following redirect (301, permanent) when Debug Mode has been turned off:

- From URL:   http://processwire.dev.local/Articles/2015/4/24/Hello%20World.HTML
- To URL:     http://processwire.dev.local/blog/hello-world/

I have a few plans in the pipeline, such as the ability to use your own expressions, but not decided yet.

Lastly, an issue came up a few days ago, where a jumplink is not working. I'm sure it has something to do with timed activation, and will look into it when I have more information. Seems that the end time (when not specified) is not being calculated properly. Normally, it would create a dummy time. I may actually need to look at redoing the whole timed activation feature...

Link to comment
Share on other sites

Hi Mike, all of my jumplinks have:

2015 years ago

in the start AND end column;

but the fields are all empty, no timed activation. None of the jumplinks work, even though in debug mode it shows

Match found! We'll do the following redirect (302, temporary) when Debug Mode has been turned off:

- From URL:   http://www.ohmspeaker.com/1/Bookshelf-Speakers.html
- To URL:     http://www.ohmspeaker.com/speakers/walsh-bookshelf/
- Timed:      From Wed, 30 Nov -001 00:00:00 -0500 to Wed, 30 Nov -001 00:00:00 -0500

if i go in and set a start and end date for the jumplink, it does work! but i guess this needs to be fixed?

Link to comment
Share on other sites

yes, linux/apache

- mySQL  5.5.40-36.1-log

- PHP 5.4.3

also, i have another site on the same server and on that one everything works fine; no dates are show in the columns, they are empty.

on the problem site which is using the dev version of the module (latest, downloaded today) these were all imported from ProcessRedirects, but then some were added after that and all of the rows show the 2015 years ago;

Link to comment
Share on other sites

also, i have another site on the same server and on that one everything works fine; no dates are show in the columns, they are empty.

Those columns shouldn't be empty at all. If no date is specified, it should use 0000-00-00 00:00:00.

on the problem site which is using the dev version of the module (latest, downloaded today) these were all imported from ProcessRedirects, but then some were added after that and all of the rows show the 2015 years ago;

Also finding that to be quite strange because both the importer and the 'editor' use the same function (commitJumplink) to insert the jumplink.

Going to test this out on my Linux server to see if I can reproduce this.

Update: Okay, I'm able to reproduce this in CloudLinux running LightSpeed (and, thus, I'm sure many other nix setups will be the same). However, in my case, the date columns are not empty, but contain the zero date. I'll try and figure out what's going on.

Link to comment
Share on other sites

Mike, just curious why you are saving a zero dates? Shouldn't empty suffice and just check if $date_start and $date_end are empty?

At first, I was using NULL dates, but that seemed to break on some systems. I then saw that PW uses zero dates, and so used them instead. As the column type is TIMESTAMP, can I even save empty strings?

Edit: Although, I see where I am perhaps wrong. PW uses the following schema

Type          Not Null   Default
TIMESTAMP     TRUE       0000-00-00 00:00:00

Whereas Jumplinks uses:

Type          Not Null   Default
TIMESTAMP     FALSE      NULL

Whilst the default is NULL, Jumplinks sends a zero date to the database.

Will work on this shortly.

Link to comment
Share on other sites

Seemingly, PW compares dates in the database to the $lowestDate of 1974-10-10.

I've updated the dev branch to do pretty much the same thing. Also, I have changed the schema of the date_start and date_end columns. The schema will update automatically. To me, this seems to be the better approach. Sure, I could use NULL dates, but recall that giving me problems before.

I have tested on Windows, CloudLinux and CentOS. I'm sure the fix will work just fine on OS X and other nix variants, but please can those affected confirm for me?

As soon as this is confirmed to be fixed, I'll push 1.2.1 to master.

Thanks.

Link to comment
Share on other sites

In the context of dates, what I really would find useful, is a date for the latest hit.

So I could, after a period of time, delete those redirects, which had no hits since that period, so those links don't seem to matter any more. That helps to keep my list short. :-)

Link to comment
Share on other sites

In the context of dates, what I really would find useful, is a date for the latest hit.

So I could, after a period of time, delete those redirects, which had no hits since that period, so those links don't seem to matter any more. That helps to keep my list short. :-)

Indeed, that could be quite useful, and is better than a full-on hit log, as I wanted to do at the beginning. This will also be helpful for an upcoming site migration, so will implement this soon.

Link to comment
Share on other sites

Those columns shouldn't be empty at all. If no date is specified, it should use 0000-00-00 00:00:00.

Update: Okay, I'm able to reproduce this in CloudLinux running LightSpeed (and, thus, I'm sure many other nix setups will be the same). However, in my case, the date columns are not empty, but contain the zero date. I'll try and figure out what's going on.

I meant that the columns in the PW admin are blank; i didn't check the dates in the database, for the particular site that works...

Link to comment
Share on other sites

I'm getting an error with mysql version: 5.6.24

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: 'null' for column 'date_start' at row 1

the error occurs when you don't populate either the start or end dates for a new jumplink.

Elsewhere it has been caused by mysql v5.6 being a lot stricter with datetime fields. Where previous versions have just ignored certain data, v5.6 now raises an error.

Starting mysql with the switch: --sql-mode=ALLOW_INVALID_DATES

removes the issue.

Link to comment
Share on other sites

When using mysql v5.6 with the switch: --sql-mode=ALLOW_INVALID_DATES

blank start and end dates get set to 2015 years ago, the dev branch solved this but unfortunately didn't fix the sql error.

Link to comment
Share on other sites

I'm getting an error with mysql version: 5.6.24

the error occurs when you don't populate both either the start or end dates for a new jumplink.

Elsewhere it has been caused by mysql v5.6 being a lot stricter with datetime fields. Where previous versions have just ignored certain data, v5.6 now raises an error.

Starting mysql with the switch: --sql-mode=ALLOW_INVALID_DATES

removes the issue.

Hi guy, and thanks for bringing that up - will sort that out this afternoon.

my issues appear to be solved.. thanks Mike! looking forward to using this a lot now!!

You're very welcome. :-)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...