Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
[Fixed] Fixed a statics db error with empty referrers
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Jul 12, 2016
1 parent 1d56b59 commit 7021252
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ Some things to do, and ideas for potential features:
### 1.0.15 -- 2016.07.12

* [Added] Added the ability to import the redirects from a `.htaccess` file into Retour
* [Fixed] Fixed a statics db error with empty referrers
* [Improved] Updated the README.md

### 1.0.14 -- 2016.07.10
Expand Down
1 change: 1 addition & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"date": "2016-07-12T12:00:00-05:00",
"notes": [
"[Added] Added the ability to import the redirects from a `.htaccess` file into Retour",
"[Fixed] Fixed a statics db error with empty referrers",
"[Improved] Updated the README.md"
]
},
Expand Down
7 changes: 5 additions & 2 deletions services/RetourService.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ public function incrementStatistics($url, $handled = false)

$handled = (int) $handled;
$url = substr($url, 0, 255);
$referrer = craft()->request->getUrlReferrer();
if (is_null($referrer))
$referrer = "";

/* -- See if a stats record exists already */

Expand All @@ -326,7 +329,7 @@ public function incrementStatistics($url, $handled = false)
{
$stats = new Retour_StatsRecord;
$stats->redirectSrcUrl = $url;
$stats->referrerUrl = craft()->request->getUrlReferrer();
$stats->referrerUrl = $referrer;
$stats->hitCount = 1;
$stats->hitLastTime = DateTimeHelper::currentUTCDateTime();
$stats->handledByRetour = $handled;
Expand All @@ -341,7 +344,7 @@ public function incrementStatistics($url, $handled = false)
{
$stat['hitCount'] = $stat['hitCount'] + 1;
$stat['hitLastTime'] = DateTimeHelper::currentTimeForDb();
$stat['referrerUrl'] = craft()->request->getUrlReferrer();
$stat['referrerUrl'] = $referrer;

$result = craft()->db->createCommand()
->update('retour_stats', array(
Expand Down

0 comments on commit 7021252

Please sign in to comment.