Split and upload tracks
-
Hi Martijn,
i’m using:
php 8.3, on Ubuntu 22.04.5 with apache 2.4.52 and WordPress 6.6.2
As i mentioned a year ago the split track feature doesn’t create a new track. Yesterday i noticed that tracks i uploaded doesn’t appear in the ‘Mage tracks’- list. But the files are uploadet. If i increment the id by my self, i can show the uploaded tracks on the map. The next recorded track-id starts with a gap (number of uploaded tracks).
I thought the same happens with spitted tracks but i can’t verify this (no gap).
Do you have any idea to avoid this?
Kind regards
Leo
-
Hi,
Sorry for not replying any sooner. However, just from your post I really have no clue as to what could be the problem.
You’re saying you can upload tracks, which you can actually show on the map, but are not present in the ‘Manage tracks’ list? That sounds really weird, not to say near impossible, unless you are using multitple user accounts.
Otherwise, I would start by checking the PHP error log for any issues.
Martijn.
Hi,
maybe it’s easier to show some screenshots:
The track with the ID 1199 seems to be the last one uploaded or created by Trackme.
I upload 2 gpx files (wich i downloaded before, but same behavior withnew tracks).
Upload seems to be ok, but they are not in the filelist
After that i made a new blog entry and incremented the ID by myself (here 2008, because i tried several times)
after that i can see the right track in the preview (and also in my blog)
When i sort all the tracks by numer (twice)…
…the missing tracks are there. But when leaving “Manage tracks” and enter again they dissapear again. At first i thought, it depends on the missing “Source”. But as i tried that is not the reason. This workaround (sorting twice) is ok for me but was a bit difficult to find ??
My very first Question was this: I can not split tracks anymore. In earlier versions of trackserver i choosed split track and after that i had the original ID with one part of the track and the another part with a new id.
Today nothing happens. The original track keeps its numer of points and no new track is generated. This is not an important thing for me, but some days i forget to stop tracking when i enter my car and then i get very long tracks with a high average speed ??
I thank you verry much for your help and for the famous addon.
Leo
Regarding the “missing” tracks… The default sort order is by start time (descending). If you upload an older track, it will not appear at the top of the list, but at the correct place in the sort order. Could that be the issue?
About the splitting issue: when you click “Split track here”, what happens? Does the page reload, or does nothing happen at all? In the first case, please check the PHP error log. If the latter is the case, please check the Javascript console.
Regarding “missing tracks”: The start date ist the same. Because i downloaded the track and uploaded it again for this test.
Regarding “split track”: I found this error in …apache2/error.log
[Thu Oct 17 19:42:34.116873 2024] [php:notice] [pid 131719] [client 188.193.xxx.xxx:37402] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘row, l.id FROM wp_ts_locations l CROSS JOIN (select @row := -1) r WHERE l.trip_i’ at line 1 for query SELECT c.* FROM (SELECT @row := @row + 1 AS row, l.id FROM wp_ts_locations l CROSS JOIN (select @row := -1) r WHERE l.trip_id=1211 ORDER BY occurred) c WHERE c.row IN (’74’) made by do_action(‘admin_post_trackserver_save_track’), WP_Hook->do_action, WP_Hook->apply_filters, Trackserver_Admin->admin_post_save_track, Trackserver_Admin->wpdb_split_track, Trackserver->get_location_ids_by_index, referer: https://xxx.xxx.de/wp-admin/admin.php?page=trackserver-tracks&orderby=id&order=desc
Mysql version is: mysql Ver 8.0.39-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))
- This reply was modified 1 month ago by lmacke.
Hi,
This is an interesting error, as the code where it occurs hasn’t changed in more than 5 years. Does this error occur every time you try to split a track? Does it occur for all tracks, or just specific ones?
Do I understand it correctly that splitting tracks has never worked for you? I never tested Trackserver on MySQL 8. I’ll see if I can try to reproduce it.
Regarding the track uploads, the reason I asked about the sort order is because your track 1199 is of 21 Sept, and your other tracks are of 28, 29 and 30 August, and as such they would appear lower in the list. To me it’s very curious that the tracks will not show in the default sort order, but when you change the order to ID descending, they appear in the list. That would be a very weird bug.I don’t know how confident you are working with PHP and MySQL, but if you are, could you take a look at this code:
https://github.com/tinuzz/wp-plugin-trackserver/blob/master/tracks-list-table.php#L195
and run that query (with all parameters replaced with values that make sense to you), to see what it does?
In a default WordPress install, this would be the query that’s executed for the default sort order (start time, descending):
SELECT t.id, t.name, t.source, t.comment, user_id, COALESCE(MIN(l.occurred), t.created) AS tstart, COALESCE(MAX(l.occurred), t.created) AS tend, COALESCE(COUNT(l.occurred), 0) AS numpoints, t.distance FROM wp_ts_tracks t LEFT JOIN wp_ts_locations l ON l.trip_id = t.id WHERE 1 GROUP BY t.id ORDER BY tstart DESC LIMIT 0,50
Curious if tracks are missing from the results…
Martijn.
- This reply was modified 1 month ago by tinuzz.
And while you’re at it, could you also try this query:
SELECT c.* FROM ( SELECT @row := @row + 1 AS row, l.id FROM wp_ts_locations l CROSS JOIN (select @row := -1) r WHERE l.trip_id=1199 ORDER BY occurred ) c WHERE c.row IN (1,2,3,4,5);
I’d like to know if it results in an SQL error…
Hi Martijn,
i’m sorry for wasting your time. I oriented myself on the daily numbers and disregarded the month. No tracks disappear. I’m going to try my hand at the sql commands now. Unfortunately, I can’t do php, I come from a time when BASIC and Pascal were spoken ??
Leo
The first one:
SELECT t.id, t.name, t.source, t.comment, user_id, COALESCE(MIN(l.occurred), t.created) AS tstart, COALESCE(MAX(l.occurred), t.created) AS tend, COALESCE(COUNT(l.occurred), 0) AS numpoints, t.distance FROM wp_ts_tracks t LEFT JOIN wp_ts_locations l ON l.trip_id = t.id WHERE 1 GROUP BY t.id ORDER BY tstart DESC LIMIT 0,50
works fine. The sort order can be changed by ORDER BY tstart
The second query produces an error:
mysql> SELECT c.* FROM ( SELECT @row := @row + 1 AS row, l.id FROM wp_ts_locations l CROSS JOIN (select @row := -1) r WHERE l.trip_id=1199 ORDER BY occurred ) c WHERE c.row IN (1,2,3,4,5);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘row, l.id FROM wp_ts_locations l CROSS JOIN (select @row := -1) r WHERE l.trip_i’ at line 1
mysql>This is an interesting error, as the code where it occurs hasn’t changed in more than 5 years. Does this error occur every time you try to split a track? Does it occur for all tracks, or just specific ones?
Yes, the error occurs every time and it occurs for all tracks.
Do I understand it correctly that splitting tracks has never worked for you? I never tested Trackserver on MySQL 8. I’ll see if I can try to reproduce it.
On March 2023 i changed from Ubuntu 18.04 LTS to 22.04 LTS with a complete new installation. The data, including the data for track server, came from a backup.
Before that, Split Track definitely worked. But I’m not sure if it still worked with the default version of PHP (8.1) on Ubuntu 22 and only stopped running after the update to PHP 8.3, or if it depends on the cange from mysql 5 to 8.
Kind regards
Leo
The fact that the SQL query produces an error when you execute it outside WordPress is a clear indication that the problem is in the query itself, and it is not related to (the version of) PHP.
This query has worked for me ever since I implemented it, also currently on latest MariaDB 10.x. But apparently it is not compatible with MySQL 8.
Since the query contains a workaround for functionality thas was not present in MySQL back then, but has other solutions nowadays, I will try and see if I can change it into something that works on MySQL 8 as well as MariaDB.
Martijn.
Hello Leo,
I did a quick test with a MySQL 8 server, and I think I found the problem. While the query is old-fashioned, made for MySQL < 8 and ready for replacement by something more modern, the real problem is the use of a the keyword
row
as a colum alias, which seems to work in MariaDB but not in MySQL.So, the quickfix is to use
rownum
as the column alias rather thanrow
.In class-trackserver.php, can you replace this snippet on lines 1357 and 1358:
'SELECT @row := @row + 1 AS row, l.id FROM ' . $this->tbl_locations . ' l CROSS JOIN (select @row := -1) r WHERE l.trip_id=%d ORDER BY occurred' . ') c WHERE c.row IN ' . $sql_in, $track_id );
by this:
'SELECT @row := @row + 1 AS rownum, l.id FROM ' . $this->tbl_locations . ' l CROSS JOIN (select @row := -1) r WHERE l.trip_id=%d ORDER BY occurred' .
') c WHERE c.rownum IN ' . $sql_in, $track_id );And see if it works?
The only actual changes are
AS row
toAS rownum
in the first line, andc.row
toc.rownum
in the second.Hi Martijn,
I just tried it. “Split track” works again.
Thank you for your help and your time.
I mark the post as solved.
Have a nice week and best regards
Leo
- You must be logged in to reply to this topic.