Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visits Log returned "The date '1970-01-01' is a date before first website was online" #215

Closed
oxcid opened this issue Feb 15, 2020 · 23 comments · Fixed by #253
Closed

Visits Log returned "The date '1970-01-01' is a date before first website was online" #215

oxcid opened this issue Feb 15, 2020 · 23 comments · Fixed by #253
Assignees
Labels
Bug Something isn't working

Comments

@oxcid
Copy link

oxcid commented Feb 15, 2020

Hi,

Starting this evening, when I tried to open Visits Log, or Ecommerce Log, and selecting date February 15-16, I get this error:

Screenshot 2020-02-16 03 44 24

This is the URL:

https://example.com/wp-content/plugins/matomo/app/index.php?module=CoreHome&action=index&idSite=1&period=day&date=yesterday#?idSite=1&period=day&date=2020-02-15&segment=&category=General_Visitors&subcategory=Live_VisitorLog

Also I checked at MySQL log, this is the query executed:

SELECT log_visit.* FROM wp_matomo_log_visit AS log_visit WHERE log_visit.idsite in ('1') AND log_visit.visit_last_action_time >= '2020-02-14 17:00:00' AND log_visit.visit_last_action_time <= '2020-02-15 20:34:43' ORDER BY log_visit.idsite DESC, log_visit.visit_last_action_time DESC LIMIT 0, 102

So I see the dates value are correct (timezone GMT+7), but I got the error above. Other dates from February 14 backward work fine. Other pages also work fine, including Real-time, it keeps tracking visits.

No PHP error at the logs.

Thanks.

@tsteur
Copy link
Member

tsteur commented Feb 17, 2020

Thanks @oxcid

I can't reproduce this here and we have also not heard of a similar issue from other On-Premise users.

Could you maybe post the content of your Matomo => System report here?

Can you also in general still reproduce this issue?

@oxcid
Copy link
Author

oxcid commented Feb 17, 2020

Hi @tsteur , I think I'm on to something here.. My initial report, the problem occurs for February 15-16, but today, the problem occurs for February 15, and 17. February 16 is displayed perfectly.

Also I noticed the problem for date 15 and 17 is gone when I set the "Rows to display" at the bottom to 25, only to reappear when I try to go to the next page (or several next pages). Is it possible that there's a corrupted or invalid row? How to make sure of this?

And may I know where do you trigger the error message above? I want to understand which event caused that, and maybe to pinpoint which field uses the timestamp value stated in the error message.

EDIT: I've found out this is called from Date::factory. Still, I don't know where it got the $datestring value "2020". For now I assume some rows have an invalid date/time value, which only consists of "2020".

System report:

` # Matomo

  • Matomo Plugin Version: 1.0.2
  • Config exists and is writable.: Yes ("$ABSPATH/wp-content/uploads/matomo/config/config.ini.php" )
  • JS Tracker exists and is writable.: Yes ("$ABSPATH/wp-content/uploads/matomo/matomo.js" )
  • Plugin directories: Yes ([{"pluginsPathAbsolute":"$ABSPATH/wp-content/plugins/matomo/plugins","webrootDirRelativeToMatomo":"../"}])
  • Tmp directory writable: Yes ($ABSPATH/wp-content/cache/matomo)
  • Matomo Version: 3.13.2
  • Matomo Blog idSite: 1

Endpoints

  • Matomo JavaScript Tracker URL: (https://example.sgp1.digitaloceanspaces.com/matomo/matomo.js)
  • Matomo JavaScript Tracker - WP Rest API: ($site_url/wp-json/matomo/v1/hit/)
  • Matomo HTTP Tracking API: ($site_url/wp-content/plugins/matomo/app/matomo.php)
  • Matomo HTTP Tracking API - WP Rest API: ($site_url/wp-json/matomo/v1/hit/)

Crons

  • Server time: 2020-02-17 06:47:54
  • Blog time: 2020-02-17 13:47:54 (Below dates are shown in blog timezone)
  • Sync users & sites: Next run: 2020-02-17 15:55:13 (2 hours 7 min) ( Last started: 2020-02-16 15:58:10 (-21 hours 49 min). Last ended: 2020-02-16 15:58:16 (-21 hours 49 min). Interval: daily)
  • Archive: Next run: 2020-02-17 13:55:13 (7 min 19s) ( Last started: 2020-02-17 12:56:12 (-51 min 42s). Last ended: 2020-02-17 12:56:22 (-51 min 32s). Interval: hourly)
  • Update GeoIP DB: Next run: 2020-02-18 15:55:13 (1 days 2 hours) ( Last started: 2020-02-11 16:00:07 (-5 days 21 hours). Last ended: 2020-02-11 16:00:10 (-5 days 21 hours). Interval: matomo_weekly)

Mandatory checks

  • PHP version >= : ok
  • PDO extension: ok
  • PDO\MYSQL extension: ok
  • MYSQLI extension: ok
  • Other required extensions: ok
  • Required functions: ok
  • Required PHP configuration (php.ini): ok
  • Directories with write access: ok
  • Directories with write access for Tag Manager: ok

Optional checks

  • Tracker status: ok
  • Memory limit: ok
  • Time zone: ok
  • Open URL: ok
  • PageSpeed disabled: ok
  • GD > 2.x + Freetype (graphics): ok
  • Other extensions: ok
  • Other functions: ok
  • Filesystem: ok
  • Archive Cron: ok
  • Last Successful Archiving Completion: ok
  • Max Packet Size: ok
  • Geolocation: ok
  • Update over HTTPS: ok
  • Writable JavaScript Tracker ("/matomo.js"): ok
  • Supports Async Archiving: No
  • Had visit in last 5 days: Yes

Matomo Settings

  • Track mode: default
  • Track codeposition: footer
  • Track api endpoint: default
  • Track js endpoint: default
  • Version history: 0.4.1
  • Core version: 3.13.1
  • Last tracking settings update: 1581843490
  • Last settings update: 1581843490
  • Track content: all
  • Track search: Yes
  • Track 404: Yes
  • Track user id: email

Logs

  • None:

WordPress

  • Home URL: $site_url
  • Site URL: $site_url
  • WordPress Version: 5.3.2
  • Number of blogs: 1
  • Multisite Enabled: No
  • Network Enabled: No
  • Debug Mode Enabled: No
  • Cron Enabled: Yes
  • Force SSL Admin: Yes
  • Language: en_US
  • Permalink Structure: /%postname%/
  • Possibly uses symlink: No
  • WP Cache enabled: Yes

WordPress Plugins

MU Plugins

  • WP fail2ban: 3.5.3

Plugins

  • ACF Content Analysis for Yoast SEO: 2.3.0
  • ACF Multi Dates Picker: 1.1.0
  • Advanced Custom Fields: 5.8.7
  • Advanced Database Cleaner PRO: 3.1.0
  • Age Gate: 2.4.0
  • AJAX Login and Registration modal popup - PRO: 1.72
  • AJAX Login and Registration modal popup DEV + inline form: 2.05
  • All-in-One WP Migration: 6.77 (Network enabled)
  • All In One WP Security: 4.4.2
  • AutomateWoo: 4.8.0
  • Bulk remove posts from category: 2.1
  • Cart Insights for WooCommerce: 1.3.0
  • CBX Woo Coupon Referral Affiliate(WCRA): 3.0.2
  • Checkout Address Autocomplete for WooCommerce: 2.0.7
  • DigitalOcean Spaces Sync: 2.1.0
  • EasyParcel: 1.0.0
  • Easy WooCommerce Discounts Pro - WooCommerce Dynamic Pricing & Discounts: 3.10.1
  • Email Log: 2.3.1
  • Google Tag Manager for Wordpress: 1.11.2
  • LiteSpeed Cache: 2.9.9.2
  • Log HTTP Requests: 1.0.4
  • Mailchimp for WooCommerce: 2.3
  • Matomo Analytics - Ethical Stats. Powerful Insights.: 1.0.2
  • Menu Items Visibility Control: 0.3.7
  • Midtrans - WooCommerce Payment Gateway: 2.15.0
  • Ninja Popups: 4.6.3
  • Official Facebook Pixel: 1.8.0
  • Order Delivery Date Pro for WooCommerce: 9.6
  • Prevent Browser Caching: 2.3.1
  • Relevanssi Premium: 2.5.2
  • reSmush.it Image Optimizer: 0.2.4
  • Social Login Buttons by Heateor: 1.1.14
  • SOFT79 Cart Links for WooCommerce: 1.1.4
  • SOFT79 Expiry dates for Woocommerce PRO: 1.3.3
  • SOFT79 Expiry dates for Woocommerce PRO: 1.3.2
  • Stream: 3.4.2
  • Super Socializer: 7.12.37
  • Theme My Login: 6.4.16
  • Theme My Login: 6.4.16
  • TI WooCommerce Wishlist Plugin: 1.16.0
  • UpdraftPlus - Backup/Restore: 2.16.6.24
  • User Role Editor: 4.52.2
  • User Switching: 1.5.3 (Network enabled)
  • WhatsApp Chat WP: 3.2
  • WooCommerce: 3.8.1
  • Woocommerce - Xendit: 2.1.0
  • WooCommerce Checkout Manager: 4.3
  • WooCommerce Dropshippers: 3.0.9
  • WooCommerce Dropshippers Stocks: 1.2
  • WooCommerce EDC Offline Gateway: 1.0.2
  • WooCommerce Extended Coupon Features PRO: 3.1.3
  • WooCommerce Flat Rate Box Shipping: 2.0.6
  • WooCommerce Onsale Page: 1.0.10
  • Woocommerce OpenPos: 3.6.4
  • WooCommerce PDF Invoices & Packing Slips: 2.3.4
  • WooCommerce Product Bundles: 5.14.2
  • WooCommerce Product Filter: 6.6.5
  • WooCommerce Product Table: 2.2.3
  • Woody ad snippets (PHP snippets | Insert PHP): 2.3.1
  • WooReer (formerly WooCommerce Shipping Distance Matrix): 2.0.8
  • WordPress Importer: 0.6.4
  • WP All Export - User Export Add-On Pro: 1.0.3
  • WP All Export Pro: 1.5.10
  • WP All Import - ACF Add-On: 3.2.4
  • WP All Import - Link Cloaking Add-on: 1.1.0
  • WP All Import - User Import Add-On Pro: 1.1.2
  • WP All Import - WooCommerce Add-On Pro: 3.1.0
  • WP All Import Pro: 4.5.8
  • WPC Product Timer for WooCommerce (Premium): 1.3.2
  • WP Crontrol: 1.7.1
  • wpDataTables: 2.8.1
  • WP Mail SMTP: 1.4.2
  • WP Sticky Sidebar: 1.2.6
  • YITH Infinite Scrolling Premium: 1.1.9
  • YITH Pre-Order for WooCommerce Premium: 1.5.0
  • YITH WooCommerce Cart Messages Premium: 1.5.8
  • YITH WooCommerce Mailchimp Premium: 2.0.0
  • YITH WooCommerce Product Add-ons Premium: 1.5.21
  • YITH WooCommerce Product Bundles Premium: 1.3.1
  • Yoast SEO: 12.7.1
  • Yoast SEO: WooCommerce: 11.5
  • Active Plugins: 69 (EasyParcel acf-multi-dates-picker advanced-custom-fields age-gate ajax-login-and-registration-modal-popup-pro all-in-one-wp-security-and-firewall arscode-ninja-popups automatewoo bulk-remove-posts-from-category cbxwoocouponreferral checkout-address-autocomplete-for-woocommerce do-spaces-sync duracelltomi-google-tag-manager email-log heateor-social-login-buttons insert-php litespeed-cache log-http-requests mailchimp-for-woocommerce matomo menu-items-visibility-control midtrans-woocommerce mystickysidebar official-facebook-pixel on-sale-page-for-woocommerce order-delivery-date prdctfltr prevent-browser-caching relevanssi-premium resmushit-image-optimizer soft79-cart-links-for-woocommerce soft79-wc-expiry-dates-pro-1.3.3 stream super-socializer theme-my-login ti-woocommerce-wishlist updraftplus user-role-editor user-switching wcsdm woo-product-timer-premium woo-xendit-virtual-accounts woocommerce-auto-added-coupons-pro woocommerce-cart-insights woocommerce-checkout-manager woocommerce-dropshippers-stock woocommerce-dropshippers woocommerce-pdf-invoices-packing-slips woocommerce-product-bundles woocommerce-product-table woocommerce-shipping-flat-rate-boxes woocommerce $DB_NAME-importer $DB_NAME-seo wp-all-export-pro wp-all-import-pro wp-crontrol wp-mail-smtp wp-whatsapp-chat wpae-user-add-on-pro wpai-acf-add-on wpai-linkcloak-add-on wpai-user-add-on wpai-woocommerce-add-on wpdatatables wpseo-woocommerce yith-woocommerce-advanced-product-options-premium yith-woocommerce-cart-messages-premium yith-woocommerce-mailchimp-premium)

Server

  • Server Info: LiteSpeed
  • PHP OS: Linux
  • PHP Version: 7.3.14-1+bionic
  • PHP SAPI: litespeed
  • Timezone: UTC
  • Locale: en_US
  • Memory Limit: 8191M (At least 128MB recommended. Depending on your traffic 256MB or more may be needed.)
  • Max Memory Limit: 8191M
  • Time: 1581922074
  • Max Execution Time: 60
  • Max Post Size: 33M
  • Max Upload Size: 33554432
  • Max Input Vars: 1000
  • Disabled PHP functions: Yes (pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,)
  • zlib.output_compression is off: Yes
  • Curl Version: 7.58.0, OpenSSL/1.1.1

Database

  • MySQL Version: 5.5.5
  • Mysqli Connect: Yes
  • Force MySQL over Mysqli: No
  • DB Prefix: wp_
  • Uses Socket: No
  • Uses IPv6: No
  • Required permissions: OK

Browser

  • Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0

    `

@oxcid
Copy link
Author

oxcid commented Feb 17, 2020

Hi @tsteur , I found the invalid rows, it's in table "wp_matomo_log_conversion" and "wp_matomo_log_conversion_item", field server_time.

Screenshot 2020-02-17 17 09 39

And here's a comparison between the server_time and the visit first & last action time.

Screenshot 2020-02-17 17 23 24

During those times, there are no PHP errors, and no server downtime etc. I checked the users from 2 of those rows as examples, there are no similarities between the users. 1 is using desktop, Win10, Firefox, while the other is using mobile, iOS, Safari.

When I changed the server_time in table wp_matomo_log_conversion to a time between visit first and last action time, the problem is gone. Nevertheless I also changed the server_time in table wp_matomo_log_conversion_item.

Until now, I don't know what caused the wrong server time at the first place. On 4 separate visits, at different dates, all server_time has the exact same value. I hope this is just a one-time glitch, but is there a way you can add a validation for the server_time field? Or at least throws an error directly when it happens? That way we know what's causing this.

Thanks.

PS: Out of topic, would you mind to take a look at this? Thanks.
https://forum.matomo.org/t/how-to-ignore-visitorreferrer-from-payment-gateways/36002

tsteur added a commit to matomo-org/matomo that referenced this issue Feb 18, 2020
refs matomo-org/matomo-for-wordpress#215

see matomo-org/matomo-for-wordpress#215 (comment)

There should be no harm in this logic. Basically the last visit time is the current timestamp anyway. It be actually probably even more accurate to use the current timestamp there in general.

Eg this could happen if an exception was triggered in https://github.com/matomo-org/matomo/blob/3.13.2/core/Tracker/Visit.php#L192-L194 where the visitor was not found for some reason when updating, or when no value changed I suppose because it was updated within a few ms. 

Another possibility that may be better be to set the `visit_last_action_time ` https://github.com/matomo-org/matomo/blob/3.13.2/core/Tracker/Visit.php#L249 at the beginning of that function or so. Not sure if there is maybe a reason it's set at the end. Or maybe it could be at least moved up one line before `updateExistingVisit` https://github.com/matomo-org/matomo/blob/3.13.2/core/Tracker/Visit.php#L247 so if it triggers an exception then we still have surely a value set. Not sure if it would fix that particular error though. Can't really think of a different way though how this would happen so far.

I was able to trigger the VisitorNotFoundInDb exception when no value changed
@tsteur
Copy link
Member

tsteur commented Feb 18, 2020

Cheers for debugging this @oxcid I have created a PR in matomo-org/matomo#15587 that will hopefully fix this.

@tsteur tsteur added the Bug Something isn't working label Feb 18, 2020
@tsteur tsteur self-assigned this Feb 18, 2020
@oxcid
Copy link
Author

oxcid commented Feb 18, 2020

Thanks @tsteur , really appreciate it! Just to update, this morning I got another invalid server_time value, exactly like the above. For now I'll fix these manually, no worries. This has never happened when I was still using the beta version (0.4 if I remember correctly), so anything causing this must be an update after that.

Thanks.

@tsteur
Copy link
Member

tsteur commented Feb 18, 2020

Cheers for letting us know 👍 I've had a look again and I have kind of an idea what it is related to. Created #217 and we're also generally looking for some additional fix in matomo-org/matomo#15587 on top of the already done fix.

@tsteur
Copy link
Member

tsteur commented Feb 18, 2020

Closing this for now @oxcid I'm hoping it'll be fixed from the next release. Feel free to comment otherwise and I'll be happy to have another look

@tsteur tsteur closed this as completed Feb 19, 2020
tsteur added a commit to matomo-org/matomo that referenced this issue Feb 20, 2020
* Ensure a valid timestamp is set when recording a conversion

refs matomo-org/matomo-for-wordpress#215

see matomo-org/matomo-for-wordpress#215 (comment)

There should be no harm in this logic. Basically the last visit time is the current timestamp anyway. It be actually probably even more accurate to use the current timestamp there in general.

Eg this could happen if an exception was triggered in https://github.com/matomo-org/matomo/blob/3.13.2/core/Tracker/Visit.php#L192-L194 where the visitor was not found for some reason when updating, or when no value changed I suppose because it was updated within a few ms. 

Another possibility that may be better be to set the `visit_last_action_time ` https://github.com/matomo-org/matomo/blob/3.13.2/core/Tracker/Visit.php#L249 at the beginning of that function or so. Not sure if there is maybe a reason it's set at the end. Or maybe it could be at least moved up one line before `updateExistingVisit` https://github.com/matomo-org/matomo/blob/3.13.2/core/Tracker/Visit.php#L247 so if it triggers an exception then we still have surely a value set. Not sure if it would fix that particular error though. Can't really think of a different way though how this would happen so far.

I was able to trigger the VisitorNotFoundInDb exception when no value changed

* throw exception for visit not found only if visit has really not found
@oxcid
Copy link
Author

oxcid commented Feb 28, 2020

Hi @tsteur , I've updated to Matomo ver 1.0.3 probably 2 days ago, but last night this error comes up again, still exactly the same as before. Can you please have another look at this?

Thanks.

@tsteur
Copy link
Member

tsteur commented Feb 28, 2020

@oxcid I've been looking through the code and debugging for quite some time but have no idea how this could potentially happen. Can you double check it happened again in the log_conversion issue and it was indeed a visit that was tracked after the update?

@oxcid
Copy link
Author

oxcid commented Feb 28, 2020

Hi @tsteur , I can confirm it's indeed the log_conversion issue again, with the exact same value "1970-01-01 00:33:40", and tracked after the plugin update. I've traced the visit log based on the action_time and HEX(idvisitor), here's the log:

Screenshot 2020-02-28 13 41 42

EDIT: There is time difference between the log in database and the report, since the database is using GMT, while the report is using GMT+7 (my local time). Not sure if this info can make a difference or not.

@oxcid
Copy link
Author

oxcid commented Mar 2, 2020

Hi @tsteur , just to update, there are no more invalid rows right now, 4 days after my last reply. So I'd guess it's just a cache issue back then. Thanks again, I'll let you know in case this issue is back.

@tsteur
Copy link
Member

tsteur commented Mar 2, 2020

Awesome, thanks. Feel free to comment any time if it happens again.

@oxcid
Copy link
Author

oxcid commented Mar 11, 2020

Hi @tsteur , I've thought this issue as solved, so I didn't check for a few days. But sadly, it does still occurs.. Please find the SQL queries below.

I'm thinking.. could a cache mechanism cause this? I'm not sure how though..?

Thanks.

Screenshot 2020-03-11 16 12 40

@oxcid
Copy link
Author

oxcid commented Mar 18, 2020

Hi @tsteur , I've created some SQL triggers, before INSERT and UPDATE, for those tables (wp_matomo_log_conversion, wp_matomo_log_conversion_item). First purpose is to log which event causes the invalid rows, and second purpose is to fix those invalid rows, so I won't have to do it manually everyday.

Here are the triggers (DATE_SUB is to calculate my local time zone difference with UTC):

CREATE TABLE dp_matomo_err_log (idvisit bigint(10) unsigned,event varchar(6),tbl varchar(4),now datetime, matomo datetime);


DELIMITER $$

CREATE TRIGGER dpMatomoConvUpdTrigger
BEFORE UPDATE
ON wp_matomo_log_conversion
  FOR EACH ROW BEGIN
    IF (NEW.server_time LIKE '1970-01-01%') THEN
      INSERT INTO dp_matomo_err_log VALUES (NEW.idvisit,'UPDATE','CONV',DATE_SUB(now(),INTERVAL 7 HOUR),NEW.server_time);
      SET NEW.server_time = DATE_SUB(now(),INTERVAL 7 HOUR);
    END IF;
  END$$

CREATE TRIGGER dpMatomoConvItemUpdTrigger
BEFORE UPDATE
ON wp_matomo_log_conversion_item
  FOR EACH ROW BEGIN
    IF (NEW.server_time LIKE '1970-01-01%') THEN
      INSERT INTO dp_matomo_err_log VALUES (NEW.idvisit,'UPDATE','ITEM',DATE_SUB(now(),INTERVAL 7 HOUR),NEW.server_time);
      SET NEW.server_time = DATE_SUB(now(),INTERVAL 7 HOUR);
    END IF;
  END$$

DELIMITER ;


DELIMITER $$

CREATE TRIGGER dpMatomoConvInsTrigger
BEFORE INSERT
ON wp_matomo_log_conversion
  FOR EACH ROW BEGIN
    IF (NEW.server_time LIKE '1970-01-01%') THEN
      INSERT INTO dp_matomo_err_log VALUES (NEW.idvisit,'INSERT','CONV',DATE_SUB(now(),INTERVAL 7 HOUR),NEW.server_time);
      SET NEW.server_time = DATE_SUB(now(),INTERVAL 7 HOUR);
    END IF;
  END$$

CREATE TRIGGER dpMatomoConvItemInsTrigger
BEFORE INSERT
ON wp_matomo_log_conversion_item
  FOR EACH ROW BEGIN
    IF (NEW.server_time LIKE '1970-01-01%') THEN
      INSERT INTO dp_matomo_err_log VALUES (NEW.idvisit,'INSERT','ITEM',DATE_SUB(now(),INTERVAL 7 HOUR),NEW.server_time);
      SET NEW.server_time = DATE_SUB(now(),INTERVAL 7 HOUR);
    END IF;
  END$$

DELIMITER ;

And after a few days, here are the log tables:

wp_matomo_log_conversion (so far I see only UPDATE queries causing invalid rows here)

Screenshot 2020-03-18 16 45 54

wp_matomo_log_conversion_item

Screenshot 2020-03-18 16 46 24

Hope this can help you fix this issue.

Thanks.

@tsteur
Copy link
Member

tsteur commented Mar 24, 2020

Thanks for this that's definitely helping. Sorry about replying to late.

I'll try another patch in the next release which is today or tmrw. It might not help though. If that doesn't work though I will try debug again. I'm thinking it might be related to some MySQL setting maybe or so but can't really imagine as it only happens in the log conversion tables but doesn't seem to happen in wp_matomo_log_visit.

@tsteur
Copy link
Member

tsteur commented Mar 24, 2020

BTW can you again confirm this is only happening for some entries but not for all? Wonder if maybe all inserts work but all updates fail or so. Probably not too easy to find out.

@tsteur
Copy link
Member

tsteur commented Mar 24, 2020

And one last thing:

What is the output of show create table wp_matomo_log_conversion_item?

@oxcid
Copy link
Author

oxcid commented Mar 24, 2020

BTW can you again confirm this is only happening for some entries but not for all? Wonder if maybe all inserts work but all updates fail or so. Probably not too easy to find out.

@tsteur Confirmed, only some, and not that many actually. That's why I created the log table, just to find out which ones having invalid values. One thing you may also have noticed, currently we're in year 2020, and in timestamps term, '2020' = '1970-01-01 00:33:40'. Thought maybe there's an issue somewhere during the dates parsing, and only taken the year value?

For table wp_matomo_log_conversion, only updates gives the invalid values, while for table wp_matomo_log_conversion_item, updates and inserts gives invalid values.

Here's the output of show create table wp_matomo_log_conversion_item; :

CREATE TABLE `wp_matomo_log_conversion_item` (
  `idsite` int(10) unsigned NOT NULL,
  `idvisitor` binary(8) NOT NULL,
  `server_time` datetime NOT NULL,
  `idvisit` bigint(10) unsigned NOT NULL,
  `idorder` varchar(100) NOT NULL,
  `idaction_sku` int(10) unsigned NOT NULL,
  `idaction_name` int(10) unsigned NOT NULL,
  `idaction_category` int(10) unsigned NOT NULL,
  `idaction_category2` int(10) unsigned NOT NULL,
  `idaction_category3` int(10) unsigned NOT NULL,
  `idaction_category4` int(10) unsigned NOT NULL,
  `idaction_category5` int(10) unsigned NOT NULL,
  `price` float NOT NULL,
  `quantity` int(10) unsigned NOT NULL,
  `deleted` tinyint(1) unsigned NOT NULL,
  PRIMARY KEY (`idvisit`,`idorder`,`idaction_sku`),
  KEY `index_idsite_servertime` (`idsite`,`server_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

Thanks.

@tsteur
Copy link
Member

tsteur commented Mar 24, 2020

One thing you may also have noticed, currently we're in year 2020, and in timestamps term, '2020' = '1970-01-01 00:33:40'. Thought maybe there's an issue somewhere during the dates parsing, and only taken the year value?

I actually did not notice that. so it uses always 00:33:40? That's indeed 2020 seconds. So somehow time() = 2020.

Almost seems like some PHP bug but I'm doubting that is the case (if so, it likely be in date("Y-m-d H:i:s", $timestamp)). That this occurs randomly makes this really tricky. I've had a look through code again but cannot explain this yet.

@tsteur
Copy link
Member

tsteur commented Mar 25, 2020

@oxcid looked again into things and likely the visit_last_action_time field in the goal manager code might randomly in some edge case end up being 2020-XX-XX XX:XX:XX. I have not yet figured out why but be great if you could confirm the patch in https://github.com/matomo-org/wp-matomo/pull/253/files works?

I have otherwise another idea but be good to see if that works. Looking through the code I have not yet seen though where this happens.

@tsteur
Copy link
Member

tsteur commented Apr 14, 2020

@oxcid be great to let me know if you could give it a try.

@oxcid
Copy link
Author

oxcid commented May 6, 2020

@tsteur Sorry for the late reply, been hectic lately on my side. I probably skipped a few updates, but I noticed since I updated to version 1.0.5 (since last Friday), my trigger events don't catch anything that needed to be fixed anymore. So any fix you've implemented around that version definitely works! Thanks so much!

@tsteur
Copy link
Member

tsteur commented May 6, 2020

Awesome, great to hear and thanks for all your help @oxcid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants