DiegoPino / islandora_piwik

Piwik integration module for Islandora
GNU General Public License v3.0
5 stars 3 forks source link

More Undefined Offset errors #22

Open bondjimbond opened 6 years ago

bondjimbond commented 6 years ago

Apparently the Piwik module is responsible for more problems, when viewing all kinds of pages (Manage page, collection browse, etc.)

screen shot 2017-10-30 at 3 09 39 pm

Not sure whether related to #19 or not, but we should start by getting some PRs merged.

mjordan commented 6 years ago

@bondjimbond what kind of page is this specifically? Also can you confirm what branch you're on?

bondjimbond commented 6 years ago

This screenshot came from enabling the Devel module to see where this Undefined Offset: 1 in drupal_http_request error had been coming from. The error appears intermittently, often repeats many times on a single page. They traced it to Piwik. Apparently the response the module is receiving from the Piwik endpoint is causing the problem -- I don't know the details or if there's something wrong with the config for my endpoint, but 12 Undefined Offset errors on a page is still a bug.

DiegoPino commented 6 years ago

@bondjimbond this is coming from here. I feel (since I have this running in production for more than a year with Solr) this fixed on the Solr impl. but I need to retest, maybe there is something else in your Site that breaks this (not blaming your site, the issue is for sure here in the lack of some sanitization of URI). Will let you know once I rebase my pull #20

bondjimbond commented 6 years ago

@DiegoPino Looks like this is still an issue. My site logs are absolutely flooded with Undefined Offset notices, and they all come from Islandora Piwik. Did you ever manage to sort that out?

DiegoPino commented 6 years ago

@bondjimbond we have it running without issues for 2 years already, can you test this pull? https://github.com/DiegoPino/islandora_piwik/pull/20 If that one solves it for you can merge into main one. Please let me know, i have been checking our logs pretty close and we never had that issue after upgrading to Solr driven

bondjimbond commented 6 years ago

@DiegoPino OK, I've pulled in your changes from #20 -- but I'm still getting the same Undefined Offset errors. Are there settings that I need to change in order to make the switch happen?

screen shot 2018-08-13 at 2 09 02 pm

DiegoPino commented 6 years ago

@bondjimbond almost the same. On our site we do have collection specific side ids too, we track parent collections,we have the PIWIK API Key enabled, + timeout 0.5 but rest is same... i feel you need to clean your cache / run update. Reason is if "javascript" processing is enabled, then "islandora_piwik_use_javascript", drupal_http_request should never ever be called (there is a pretty expressive IF there at line 128 https://github.com/DiegoPino/islandora_piwik/pull/20/files#diff-153d11378c390cf5ad9636f5fa03b92aR128 )

Is your Matomo Analytics module enabled? The one that adds JS main scripts to each page? Just wondering, used to be called PIWIK analytics. Can you also check that drupal_add_js i added is working? (add some error_log statement somewhere to check for that or look at the page source code)

Is there anything unusual in your site (multi site with subdomains or subpaths?) I would also, in case JS is not being detected at all in your side and JS is not working, check for the value of $URI at https://github.com/DiegoPino/islandora_piwik/pull/20/files#diff-153d11378c390cf5ad9636f5fa03b92aR142.

Basically in your case that one is malformed and failing badly.

Good luck and let me know

bondjimbond commented 6 years ago

i feel you need to clean your cache / run update

Tried that; no dice.

Is your Matomo Analytics module enabled?

Didn't have one; it's not listed as a dependency. Tried installing it -- even without enabling it, now, the offset errors are gone. My logs show undefined offset errors right up until the moment I installed the Drupal Matomo module.

That's... weird?

DiegoPino commented 6 years ago

Maybe by installing it something got cleared up (like cleaning a dirty pipe)? Are you running some type of frontend caching? Mine is enabled but does little. Just provides the includes for the JS, i should add it as an dependency, but then i also should update everything to "matomo" because libraries will probably also change. Still, to be sure, can you check if tracking is working now for you? I would love to see why your http request was failing, makes me wonder what is happening there.

bondjimbond commented 6 years ago

Yep, tracking is working. Is islandora_piwik perhaps looking for a file that lives in the matomo directory, or some other weird interaction?

bondjimbond commented 6 years ago

Note that the http request was not failing - tracking was still happening - just getting "undefined offset" warnings.

bondjimbond commented 6 years ago

Nope, I spoke too soon - undefined offset errors are back. So installing the Drupal Matomo module did not do anything.

bondjimbond commented 6 years ago

Is there anything unusual in your site (multi site with subdomains or subpaths?)

We're a multi-site, so each site has its own subdomain, but I'm only tracking one subdomain per instance, so there shouldn't be anything weird there.

DiegoPino commented 6 years ago

@bondjimbond ok, let me get back to blueprinting on this. Can you in the meantime share the value of $URI at https://github.com/DiegoPino/islandora_piwik/pull/20/files#diff-153d11378c390cf5ad9636f5fa03b92aR142. with me, i want to see what is malformed there? I don't understand why your site is even calling that piece of code if JS enabled always bypasses the http request completely. Are you sure you updated the module on that particular multi site right? Will get back to you tomorrow with a fix if i find what is wrong of course

bondjimbond commented 6 years ago

Can you in the meantime share the value of $URI

Do you mean my piwik endpoint? http://analytics.bceln.ca/piwik.php

Are you sure you updated the module on that particular multi site right?

Yep. Code for all modules is shared in the multisite. And update.php had nothing to update. I've got all the new settings you added.

DiegoPino commented 6 years ago

With $URI i mean if you can echo/dump/save to log somewhere and share with me the output of this line https://github.com/DiegoPino/islandora_piwik/pull/20/files#diff-153d11378c390cf5ad9636f5fa03b92aR142 (see the one highlighted)

Because that is the only URI that is passed from this module to drupal´s http request, so if PIWIKI module is the culprit, that $URI variable value is the culprit

bondjimbond commented 6 years ago

Ah, OK. Here's the output of print_r($uri) from rdc.arcabc.ca:

http://analytics.bceln.ca/piwik.php?apiv=1&rec=1&idsite=24&url=https://rdc.arcabc.ca/islandora/object/rdc:root&urlref=https%3A%2F%2Frdc.arcabc.ca%2F

DiegoPino commented 6 years ago

@bondjimbond hey,

i just tested that URI on one of my islandora sites (devel php block) without any issues ore warning (not saying it is working).

I have xdebug enabled so i would end having some larger issues if it would be failing. But, maybe my drupal core is never/php 7 different than yours? Maybe also 1) I suspect that specific URL is not failing for you but longer ones, because drupal_http_request has a size limit for get requests. We could test with POIST 2) BUT:your PIWIK server is not responding correctly neither, look (curl -iv "yoururl") 👀 maybe the endpoint is totally wrong? Or is it because i'm outside?

* TCP_NODELAY set
* Connected to analytics.bceln.ca (65.39.189.152) port 80 (#0)
> GET /piwik.php?apiv=1&rec=1&idsite=24&url=https://rdc.arcabc.ca/islandora/object/rdc:root&urlref=https%3A%2F%2Frdc.arcabc.ca%2F HTTP/1.1
> Host: analytics.bceln.ca
> User-Agent: curl/7.54.0
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
HTTP/1.1 301 Moved Permanently
< Content-Type: text/html
Content-Type: text/html
< Content-Length: 1147
Content-Length: 1147
< Date: Tue, 14 Aug 2018 19:37:11 GMT
Date: Tue, 14 Aug 2018 19:37:11 GMT
< Accept-Ranges: bytes
Accept-Ranges: bytes
< Server: LiteSpeed
Server: LiteSpeed
< Location: https://analytics.bceln.ca/piwik.php?apiv=1&rec=1&idsite=24&url=https://rdc.arcabc.ca/islandora/object/rdc:root&urlref=https%3A%2F%2Frdc.arcabc.ca%2F
Location: https://analytics.bceln.ca/piwik.php?apiv=1&rec=1&idsite=24&url=https://rdc.arcabc.ca/islandora/object/rdc:root&urlref=https%3A%2F%2Frdc.arcabc.ca%2F
< Connection: Keep-Alive
Connection: Keep-Alive

< 
<!DOCTYPE html>
<html style="height:100%">
<head><title> 301 Moved Permanentl
DiegoPino commented 6 years ago

@bondjimbond maybe i can try a patch using POST in this tone https://www.drupal.org/files/spambot-post.patch

But then again, something is wrong with your deployment, seems like js options is being ignored completely, do you have some time tomorrow for a quick chat on IRC? Cheers

bondjimbond commented 6 years ago

The "Moved Permanently" response is weird, because there is a piwik.php file directly in the root of my Analytics site. And if you go to https://analytics.bceln.ca/piwik.php in the browser you get a result. Is it simply because my URL is set to http://analytics.bceln.ca/piwik.php? Is it somehow rejecting it because it's not https?

bondjimbond commented 6 years ago

And sure, we could chat in IRC tomorrow. What time is good for you?

DiegoPino commented 6 years ago

11:00 EST would be perfect, will be around in case i see you there. Yes, HTTP and HTTPS are totally different protocols, so differen servers too! That is probably the issue. make your piwik endpoint HTTPS and try again. And let me know because i get sweet code 200 after testing your endpoint with HTTPS

bondjimbond commented 6 years ago

OK, I've made the Piwik endpoints HTTPS in all my sites... will check tomorrow to see whether the errors are gone.

If that's the case, possible solution to this ticket (and something that should be done regardless): Can we introduce some validation to that endpoint URL field on the config form?

DiegoPino commented 6 years ago

Totally! A 200 code check would not hurt

El El mar, 14 de ago. de 2018 a las 16:23, Brandon Weigel < notifications@github.com> escribió:

OK, I've made the Piwik endpoints HTTPS in all my sites... will check tomorrow to see whether the errors are gone.

If that's the case, possible solution to this ticket (and something that should be done regardless): Can we introduce some validation to that endpoint URL field on the config form?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DiegoPino/islandora_piwik/issues/22#issuecomment-413003498, or mute the thread https://github.com/notifications/unsubscribe-auth/AGn85x7F4Srhkk_zymfuQeDsNPTU9xwRks5uQzHAgaJpZM4QLqz2 .

-- Diego Pino Navarro Digital Repositories Developer Metropolitan New York Library Council (METRO)