Project

General

Profile

Actions

Bug #1429

closed

UpdateViews: Duplicate entry bug + error rendering bug

Added by beat almost 15 years ago. Updated almost 15 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
04 February 2010
Due date:
% Done:

100%

Estimated time:
0:18 h

Description

As reported by dansari here:
http://www.joomlapolis.com/component/option,com_joomlaboard/Itemid,38/func,view/id,123549/catid,100

Say jos_comprofiler_views has the following rows:

viewer_id profile_id lastip lastview viewscount vote lastvote
62 261 127.0.0.1 2010-02-02 15:07:34 8 NULL 0000-00-00 00:00:00
62 261 72.137.56.31 2009-02-04 21:42:40 3 NULL 0000-00-00 00:00:00

The UPDATE statement in the recordViewHit function (administrator/components/com_comprofiler/comprofiler.class.php ln 2912) causes the following DB error:

Duplicate entry '62-261-127.0.0.1' for key 1 SQL=UPDATE jos_comprofiler_views
SET viewscount = (viewscount+1),
lastview = NOW,
lastip = '127.0.0.1'
WHERE viewer_id = 62 AND profile_id = 261

It's trying to update both rows to the same lastip value, which would violate the PK.

Related: the javascript popup is missing cleanup for display (see reply).


Files

1429.patch (5.55 KB) 1429.patch krileon, 04 February 2010 20:35
1429-beat.patch (6.09 KB) 1429-beat.patch beat, 21 February 2010 19:19
Actions #1

Updated by krileon almost 15 years ago

  • File 1429.patch 1429.patch added
  • Status changed from New to Assigned
  • Assignee set to beat
  • % Done changed from 0 to 80

Updated function to load object list in order to grab list of duplicates, delete duplicates, and update latest. Errors also escaped in order to prevent fatal JS errors. Code cleaned for legibility.

Actions #2

Updated by beat almost 15 years ago

While the patch works, it does do one DELETE per duplicate in a PHP loop, instead of using the SQL WHERE to delete all at once.

If the database has loots of duplicates, that can be a problem.

I also fixed an issue that a user on a always changing IP address was counted as having viewed a profile at each page load with a different IP address.

Attached alternate patch that is applied after CB 1.2.2 b3.

Btw: proper Javascript escaping is addslashes(), not htmlspecialchars( cbGetEscaped( )) : changed before committing.

Fixed in r887 .

Actions

Also available in: Atom PDF