Version 4.7.23

This commit is contained in:
Neo committed 2025-12-19 16:21:27 -08:00
1 parent 7124a02564
commit 25ddeb65d6
1791 files changed
+76990 -44452

No files matched your search

+41 -3
View File
@@ -11,6 +11,9 @@
namespace IPS\Node;
/* To prevent PHP errors (extending class does not exist) revealing path */
use Exception;
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
@@ -233,11 +236,11 @@ trait Statistics
$commentItemField = $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['item'];
$authorColumn = $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['author'];
$where = array();
$memberIds = array();
$deleteWhere = array( array( \IPS\Db::i()->in( 'map_item_id', $inSet ) ) );
if ( \count( $members ) )
{
$memberIds = array();
foreach ( $members as $member )
{
$memberIds[] = $member->member_id;
@@ -272,6 +275,12 @@ trait Statistics
\IPS\Db::i()->replace( 'core_item_member_map', $insertFromSelect, TRUE );
}
/* If forums are being used for Pages comments, we don't want to look at those */
if( mb_substr( $commentClass, 0, 32 ) === 'IPS\\cms\\Records\\CommentTopicSync' )
{
return;
}
/* Do the comments */
if ( isset( $commentClass::$databaseColumnMap['approved'] ) )
{
@@ -291,8 +300,37 @@ trait Statistics
$where[] = array(\IPS\Db::i()->in( $commentItemField, $inSet ));
$insertFromSelect = \IPS\Db::i()->select( "DISTINCT `{$authorColumn}`, `{$commentItemField}`, UNIX_TIMESTAMP(), '" . str_replace( '\\', '\\\\', $contentItemClass ) . "'", $commentClass::$databaseTable, $where );
\IPS\Db::i()->replace( 'core_item_member_map', [ 'map_member_id, map_item_id, map_latest_date, map_class', $insertFromSelect ], TRUE );
try
{
$seen = array();
/* If we don't have member(s) in the where clause, or we have a lot of member ids in the where clause, we can't do individual inserts as this could be 10,000+ inserts on very large topics */
if ( ! count( $memberIds ) or ( count( $memberIds ) > 100 ) )
{
$insertFromSelect = \IPS\Db::i()->select( "DISTINCT `{$authorColumn}`, `{$commentItemField}`, UNIX_TIMESTAMP(), '" . str_replace( '\\', '\\\\', $contentItemClass ) . "'", $commentClass::$databaseTable, $where );
\IPS\Db::i()->replace( 'core_item_member_map', [ 'map_member_id, map_item_id, map_latest_date, map_class', $insertFromSelect ], TRUE );
}
else
{
foreach( \IPS\Db::i()->select( "DISTINCT `{$authorColumn}` as {$authorColumn}, `{$commentItemField}`", $commentClass::$databaseTable, $where ) as $row )
{
$key = $row[ $authorColumn ] . '_' . $row[ $commentItemField ];
if ( isset( $seen[ $key ] ) or ! $row[ $authorColumn ] )
{
continue;
}
$seen[ $key ] = true;
\IPS\Db::i()->insert( 'core_item_member_map', [
'map_member_id' => $row[ $authorColumn ],
'map_item_id' => $row[ $commentItemField ],
'map_latest_date' => time(),
'map_class' => $contentItemClass
] );
}
}
}
catch( Exception ) { }
}
}