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/component/audit/class-audit-event.php +39 -15 5.4.0 → 6.3.0 View file →
@@ -23,9 +23,9 @@
23 23
24 24 use User;
25 25 use IP;
26 26
27 - public const ACTION_DELETED = 'deleted', ACTION_TRASHED = 'trashed', ACTION_RESTORED = 'restored', ACTION_UPDATED = 'updated';
27 + public const ACTION_CREATED = 'created', ACTION_DELETED = 'deleted', ACTION_TRASHED = 'trashed', ACTION_RESTORED = 'restored', ACTION_UPDATED = 'updated';
28 28
29 29 /**
30 30 * Return an array of hooks.
31 31 *
@@ -112,10 +112,14 @@
112 112 // We will iterate over the links and use each link to access a nested property or array element of the $obj.
113 113 foreach ( $links as $link ) {
114 114 if ( is_array( $obj ) && array_key_exists( $link, $obj ) ) {
115 115 $obj = $obj[ $link ];
116 - } elseif ( is_object( $obj ) && isset( $obj->$link ) ) {
117 - $obj = $obj->$link;
116 + } elseif ( is_object( $obj ) ) {
117 + $vars = get_object_vars( $obj );
118 + if ( ! array_key_exists( $link, $vars ) ) {
119 + return false;
120 + }
121 + $obj = $vars[ $link ];
118 122 } else {
119 123 return false;
120 124 }
121 125 }
@@ -134,9 +138,9 @@
134 138 private static function recursive_look_array( $data, $links ) {
135 139 $links_array = explode( '->', $links );
136 140
137 141 // Check if the first link exists and is valid.
138 - if ( empty( $links_array ) || ! isset( $data[ $links_array[0] ] ) ) {
142 + if ( ! isset( $data[ $links_array[0] ] ) ) {
139 143 return false;
140 144 }
141 145
142 146 // If the first link exists and is valid, retrieve the value of the first link from the data array.
@@ -277,9 +281,9 @@
277 281
278 282 /**
279 283 * Build log data based on the provided hook data and parameters.
280 284 *
281 - * @return mixed Returns false if the log data cannot be built, otherwise an array of log data.
285 + * @return bool Returns false if the log data cannot be built, otherwise true.
282 286 * @throws ReflectionException If the class or method does not exist.
283 287 */
284 288 public function build_log_data() {
285 289 $args = func_get_args();
@@ -289,24 +293,42 @@
289 293 $hook_data = $args[2];
290 294 // Have to build iup params first.
291 295 if ( ( is_array( $hook_data['args'] ) || $hook_data['args'] instanceof Countable ? count( $hook_data['args'] ) : 0 ) !== ( is_array( $params ) || $params instanceof Countable ? count( $params ) : 0 ) ) {
292 296 return false;
293 - } elseif ( empty( $hook_data['args'] ) && empty( $params ) ) {
297 + } elseif (
298 + ( ! isset( $hook_data['args'] ) || ! is_array( $hook_data['args'] ) || array() === $hook_data['args'] )
299 + && ( ! is_array( $params ) || array() === $params )
300 + ) {
294 301 $params = array();
295 302 } else {
296 303 $params = array_combine( $hook_data['args'], $params );
297 304 }
298 305
299 - if ( isset( $hook_data['callback'] ) && ! empty( $hook_data['callback'] ) ) {
306 + if ( isset( $hook_data['callback'] ) && is_array( $hook_data['callback'] ) && count( $hook_data['callback'] ) > 1 ) {
300 307 // Custom callback provided, call it.
301 308 $reflection_method = new ReflectionMethod( $hook_data['callback'][0], $hook_data['callback'][1] );
302 - $ret = $reflection_method->invokeArgs(
303 - new $hook_data['callback'][0](),
304 - array(
305 - $hook_name,
306 - $params,
307 - )
309 + $new_hooks = array(
310 + 'add_user_to_blog',
311 + 'user_profile_update_errors',
312 + 'profile_update',
313 + 'password_reset',
314 + 'user_register',
315 + 'wpmu_new_user',
308 316 );
317 + if ( in_array( $hook_name, $new_hooks, true ) ) {
318 + $ret = $reflection_method->invokeArgs(
319 + new $hook_data['callback'][0](),
320 + $params
321 + );
322 + } else {
323 + $ret = $reflection_method->invokeArgs(
324 + new $hook_data['callback'][0](),
325 + array(
326 + $hook_name,
327 + $params,
328 + )
329 + );
330 + }
309 331
310 332 if ( is_array( $ret ) && 2 === count( $ret ) ) {
311 333 [ $text, $context ] = $ret;
312 334 } elseif ( is_array( $ret ) && 3 === count( $ret ) ) {
@@ -339,9 +361,9 @@
339 361 }
340 362 // Now we got all params as key=>value, just build the text.
341 363 $text = self::get_text( $hook_data['text'], $params );
342 364
343 - if ( empty( $text ) ) {
365 + if ( ! is_string( $text ) || '' === $text ) {
344 366 return false;
345 367 }
346 368
347 369 foreach ( $params as $key => $val ) {
@@ -400,9 +422,9 @@
400 422 }
401 423 }
402 424
403 425 // We don't get text. Return.
404 - if ( ! $text ) {
426 + if ( ! is_string( $text ) || '' === trim( $text ) ) {
405 427 return false;
406 428 }
407 429
408 430 // Build data.
@@ -428,8 +450,10 @@
428 450 'ttl' => $ttl,
429 451 );
430 452 Array_Cache::append( 'logs', $post, 'audit' );
431 453 }
454 +
455 + return true;
432 456 }
433 457
434 458 /**
435 459 * Retrieves default parameters for building log data.