PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
← All changes | src/model/class-audit-log.php +8 -5 5.8.1 → 6.3.0 View file →
@@ -188,8 +188,9 @@
188 188 * @param array $events Type of the event, e.g. comment, user, system.
189 189 * @param string $user_id Who trigger this event, if it 0, will be guest.
190 190 * @param string $ip IP of who trigger this.
191 191 * @param int|bool $paged Current page.
192 + * @param int $per_page Number of logs per page.
192 193 *
193 194 * @return array
194 195 */
195 196 public static function query(
@@ -197,9 +198,10 @@
197 198 $date_to,
198 199 $events = array(),
199 200 $user_id = '',
200 201 $ip = '',
201 - $paged = 1
202 + $paged = 1,
203 + $per_page = 10
202 204 ): array {
203 205 $orm = self::get_orm();
204 206 $builder = $orm->get_repository( self::class );
205 207 $builder->where( 'timestamp', '>=', $date_from )
@@ -221,9 +223,9 @@
221 223 $builder->order_by( 'timestamp', 'desc' );
222 224
223 225 if ( false !== $paged ) {
224 226 // If paged == false, then it will be no paging.
225 - $per_page = 20;
227 + $per_page = max( 1, (int) $per_page );
226 228 $offset = ( $paged - 1 ) * $per_page;
227 229 $builder->limit( $per_page, $offset );
228 230 }
229 231
@@ -287,19 +289,20 @@
287 289
288 290 /**
289 291 * Mass insert logs, usually fetched from API.
290 292 *
291 - * @param array $data An array of data to be inserted into the Audit_Log table.
293 + * @param array $data An array of data to be inserted into the Audit_Log table.
294 + * @param int $synced Whether the logs have already been synced.
292 295 *
293 296 * @return void
294 297 * @throws ReflectionException If the import method of the Audit_Log class throws a ReflectionException.
295 298 */
296 - public static function mass_insert( $data ) {
299 + public static function mass_insert( $data, $synced = 1 ) {
297 300 // Use raw sql for faster.
298 301 foreach ( $data as $datum ) {
299 302 $item = new Audit_Log();
300 303 $item->import( $datum );
301 - $item->synced = 1;
304 + $item->synced = $synced;
302 305 $item->save();
303 306 }
304 307 }
305 308