Passed
Branch development (176841)
by Elk
07:58
created

Logging.php ➔ writeLog()   F

Complexity

Conditions 26
Paths 2888

Size

Total Lines 104

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 702

Importance

Changes 0
Metric Value
cc 26
nc 2888
nop 1
dl 0
loc 104
rs 0
c 0
b 0
f 0
ccs 0
cts 46
cp 0
crap 702

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * This file concerns itself with logging, whether in the database or files.
5
 *
6
 * @package   ElkArte Forum
7
 * @copyright ElkArte Forum contributors
8
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file)
9
 *
10
 * This file contains code covered by:
11
 * copyright:	2011 Simple Machines (http://www.simplemachines.org)
12
 *
13
 * @version 2.0 dev
14
 *
15
 */
16
17
use ElkArte\User;
18
19
/**
20
 * Put this user in the online log.
21
 *
22
 * @param bool $force = false
23
 */
24
function writeLog($force = false)
25
{
26
	global $context, $modSettings, $settings, $topic, $board;
27
28
	// If we are showing who is viewing a topic, let's see if we are, and force an update if so - to make it accurate.
29
	if (!empty($settings['display_who_viewing']) && ($topic || $board))
30
	{
31
		// Take the opposite approach!
32
		$force = true;
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $force. This often makes code more readable.
Loading history...
33
34
		// Don't update for every page - this isn't wholly accurate but who cares.
35
		if ($topic)
36
		{
37
			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic)
38
				$force = false;
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $force. This often makes code more readable.
Loading history...
39
			$_SESSION['last_topic_id'] = $topic;
40
		}
41
	}
42
43
	// Are they a spider we should be tracking? Mode = 1 gets tracked on its spider check...
44
	if (!empty(User::$info->possibly_robot) && !empty($modSettings['spider_mode']) && $modSettings['spider_mode'] > 1)
0 ignored issues
show
Documentation introduced by
The property possibly_robot does not exist on object<ElkArte\ValuesContainer>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
45
	{
46
		require_once(SUBSDIR . '/SearchEngines.subs.php');
47
		logSpider();
48
	}
49
50
	// Don't mark them as online more than every so often.
51
	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force)
52
		return;
53
54
	if (!empty($modSettings['who_enabled']))
55
	{
56
		$serialized = $_GET;
57
58
		// In the case of a dlattach action, session_var may not be set.
59
		if (!isset($context['session_var']))
60
			$context['session_var'] = $_SESSION['session_var'];
61
62
		unset($serialized['sesc'], $serialized[$context['session_var']]);
63
		$serialized = serialize($serialized);
64
	}
65
	else
66
		$serialized = '';
67
68
	// Guests use 0, members use their session ID.
69
	$session_id = User::$info->is_guest ? 'ip' . User::$info->ip : session_id();
0 ignored issues
show
Documentation introduced by
The property is_guest does not exist on object<ElkArte\ValuesContainer>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property ip does not exist on object<ElkArte\ValuesContainer>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
70
71
	$cache = \ElkArte\Cache\Cache::instance();
72
73
	// Grab the last all-of-Elk-specific log_online deletion time.
74
	$do_delete = $cache->get('log_online-update', 30) < time() - 30;
75
76
	require_once(SUBSDIR . '/Logging.subs.php');
77
78
	// If the last click wasn't a long time ago, and there was a last click...
79
	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= time() - $modSettings['lastActive'] * 20)
80
	{
81
		if ($do_delete)
82
		{
83
			deleteLogOnlineInterval($session_id);
84
85
			// Cache when we did it last.
86
			$cache->put('log_online-update', time(), 30);
87
		}
88
89
		updateLogOnline($session_id, $serialized);
90
	}
91
	else
92
		$_SESSION['log_time'] = 0;
93
94
	// Otherwise, we have to delete and insert.
95
	if (empty($_SESSION['log_time']))
96
		insertdeleteLogOnline($session_id, $serialized, $do_delete);
97
98
	// Mark your session as being logged.
99
	$_SESSION['log_time'] = time();
100
101
	// Well, they are online now.
102
	if (empty($_SESSION['timeOnlineUpdated']))
103
		$_SESSION['timeOnlineUpdated'] = time();
104
105
	// Set their login time, if not already done within the last minute.
106
	if (ELK != 'SSI' && !empty(User::$info->last_login) && User::$info->last_login < time() - 60)
0 ignored issues
show
Documentation introduced by
The property last_login does not exist on object<ElkArte\ValuesContainer>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
107
	{
108
		// We log IPs the request came with, around here
109
		$req = request();
110
111
		// Don't count longer than 15 minutes.
112
		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15)
113
			$_SESSION['timeOnlineUpdated'] = time();
114
115
		\ElkArte\User::$settings->updateTotalTimeLoggedIn($_SESSION['timeOnlineUpdated']);
0 ignored issues
show
Documentation Bug introduced by
The method updateTotalTimeLoggedIn does not exist on object<ElkArte\ValuesContainerReadOnly>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
116
		require_once(SUBSDIR . '/Members.subs.php');
117
		updateMemberData(User::$info->id, array('last_login' => time(), 'member_ip' => User::$info->ip, 'member_ip2' => $req->ban_ip(), 'total_time_logged_in' => \ElkArte\User::$settings['total_time_logged_in']));
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<ElkArte\ValuesContainer>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property ip does not exist on object<ElkArte\ValuesContainer>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
118
119
		if ($cache->levelHigherThan(1))
120
		{
121
			$cache->put('user_settings-' . User::$info->id, \ElkArte\User::$settings->toArray(), 60);
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<ElkArte\ValuesContainer>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
122
		}
123
124
		User::$info->total_time_logged_in += time() - $_SESSION['timeOnlineUpdated'];
0 ignored issues
show
Documentation introduced by
The property total_time_logged_in does not exist on object<ElkArte\ValuesContainer>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
125
		$_SESSION['timeOnlineUpdated'] = time();
126
	}
127
}
128
129
/**
130
 * Logs the last database error into a file.
131
 *
132
 * What it does:
133
 *
134
 * - Attempts to use the backup file first, to store the last database error
135
 * - only updates db_last_error.txt if the first was successful.
136
 */
137
function logLastDatabaseError()
138
{
139
	// Make a note of the last modified time in case someone does this before us
140
	$last_db_error_change = @filemtime(BOARDDIR . '/db_last_error.txt');
141
142
	// Save the old file before we do anything
143
	$file = BOARDDIR . '/db_last_error.txt';
144
	$dberror_backup_fail = !@is_writable(BOARDDIR . '/db_last_error_bak.txt') || !@copy($file, BOARDDIR . '/db_last_error_bak.txt');
145
	$dberror_backup_fail = !$dberror_backup_fail ? (!file_exists(BOARDDIR . '/db_last_error_bak.txt') || filesize(BOARDDIR . '/db_last_error_bak.txt') === 0) : $dberror_backup_fail;
146
147
	clearstatcache();
148
	if (filemtime(BOARDDIR . '/db_last_error.txt') === $last_db_error_change)
149
	{
150
		// Write the change
151
		$write_db_change = time();
152
		$written_bytes = file_put_contents(BOARDDIR . '/db_last_error.txt', $write_db_change, LOCK_EX);
153
154
		// Survey says ...
155
		if ($written_bytes !== strlen($write_db_change) && !$dberror_backup_fail)
156
		{
157
			// Oops. maybe we have no more disk space left, or some other troubles, troubles...
158
			// Copy the file back and run for your life!
159
			@copy(BOARDDIR . '/db_last_error_bak.txt', BOARDDIR . '/db_last_error.txt');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
160
			return false;
161
		}
162
		return true;
163
	}
164
165
	return false;
166
}
167
168
/**
169
 * Track Statistics.
170
 *
171
 * What it does:
172
 *
173
 * - Caches statistics changes, and flushes them if you pass nothing.
174
 * - If '+' is used as a value, it will be incremented.
175
 * - It does not actually commit the changes until the end of the page view.
176
 * - It depends on the trackStats setting.
177
 *
178
 * @param mixed[] $stats = array() array of array => direction (+/-)
179
 *
180
 * @return boolean|array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array|boolean.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
181
 */
182 26
function trackStats($stats = array())
183 26
{
184
	global $modSettings;
185 26
	static $cache_stats = array();
186
187
	if (empty($modSettings['trackStats']))
188 26
		return false;
189 26
190
	if (!empty($stats))
191
		return $cache_stats = array_merge($cache_stats, $stats);
192
	elseif (empty($cache_stats))
193 1
		return false;
194 1
195
	$setStringUpdate = array();
196 1
	$insert_keys = array();
197
198 1
	$date = strftime('%Y-%m-%d', forum_time(false));
199
	$update_parameters = array(
200
		'current_date' => $date,
201 1
	);
202
203 1
	foreach ($cache_stats as $field => $change)
204
	{
205 1
		$setStringUpdate[] = $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}');
206 1
207
		if ($change === '+')
208
			$cache_stats[$field] = 1;
209
		else
210 1
			$update_parameters[$field] = $change;
211
212
		$insert_keys[$field] = 'int';
213 1
	}
214
215 1
	$setStringUpdate = implode(',', $setStringUpdate);
216 1
217
	require_once(SUBSDIR . '/Logging.subs.php');
218
	updateLogActivity($update_parameters, $setStringUpdate, $insert_keys, $cache_stats, $date);
219 1
220
	// Don't do this again.
221 1
	$cache_stats = array();
222
223
	return true;
224
}
225
226
/**
227
 * This function logs a single action in the respective log. (database log)
228
 *
229
 * - You should use {@link logActions()} instead if you have multiple entries to add
230
 *
231
 * @example logAction('remove', array('starter' => $id_member_started));
232
 *
233
 * @param string $action The action to log
234
 * @param string[] $extra = array() An array of extra data
235
 * @param string $log_type options: 'moderate', 'admin', ...etc.
236
 *
237
 * @return int
238
 */
239
function logAction($action, $extra = array(), $log_type = 'moderate')
240 2
{
241 2
	// Set up the array and pass through to logActions
242 2
	return logActions(array(array(
243 2
		'action' => $action,
244
		'log_type' => $log_type,
245
		'extra' => $extra,
246
	)));
247
}
248
249
/**
250
 * Log changes to the forum, such as moderation events or administrative changes.
251
 *
252
 * - This behaves just like logAction() did, except that it is designed to
253
 * log multiple actions at once.
254
 *
255
 * @event integrate_log_types allows to add additional log types for integrations
256
 * @param mixed[] $logs array of actions to log [] = array(action => log_type=> extra=>)
257
 *   - action => A code for the log
258
 *   - extra => An associated array of parameters for the item being logged.
259
 *     This will include 'topic' for the topic id or message for the message id
260
 *   - log_type => A string reflecting the type of log, moderate for moderation actions,
261
 *     admin for administrative actions, user for user
262
 *
263
 * @return int the last logged ID
264
 */
265 2
function logActions($logs)
266
{
267 2
	global $modSettings;
268
269 2
	$inserts = array();
270
	$log_types = array(
271
		'moderate' => 1,
272
		'user' => 2,
273
		'admin' => 3,
274 2
	);
275
276
	call_integration_hook('integrate_log_types', array(&$log_types));
277 2
278 2
	// No point in doing anything, if the log isn't even enabled.
279
	if (empty($modSettings['modlog_enabled']))
280
		return false;
281
282
	foreach ($logs as $log)
283
	{
284
		if (!isset($log_types[$log['log_type']]))
285
			return false;
286
287
		// Do we have something to log here, after all?
288
		if (!is_array($log['extra']))
289
			trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
290
291
		// Pull out the parts we want to store separately, but also make sure that the data is proper
292
		if (isset($log['extra']['topic']))
293
		{
294
			if (!is_numeric($log['extra']['topic']))
295
				trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
296
297
			$topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic'];
298
			unset($log['extra']['topic']);
299
		}
300
		else
301
			$topic_id = 0;
302
303
		if (isset($log['extra']['message']))
304
		{
305
			if (!is_numeric($log['extra']['message']))
306
				trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
307
			$msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message'];
308
			unset($log['extra']['message']);
309
		}
310
		else
311
			$msg_id = 0;
312
313
		// @todo cache this?
314
		// Is there an associated report on this?
315
		if (in_array($log['action'], array('move', 'remove', 'split', 'merge')))
316
		{
317
			require_once(SUBSDIR . '/Logging.subs.php');
318
			if (loadLogReported($msg_id, $topic_id))
319
			{
320
				require_once(SUBSDIR . '/Moderation.subs.php');
321
				updateSettings(array('last_mod_report_action' => time()));
322
				recountOpenReports(true, allowedTo('admin_forum'));
323
			}
324
		}
325
326
		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member']))
327
			trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
328
329
		if (isset($log['extra']['board']))
330
		{
331
			if (!is_numeric($log['extra']['board']))
332
				trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
333
334
			$board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board'];
335
			unset($log['extra']['board']);
336
		}
337
		else
338
			$board_id = 0;
339
340
		if (isset($log['extra']['board_to']))
341
		{
342
			if (!is_numeric($log['extra']['board_to']))
343
				trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
344
345
			if (empty($board_id))
346
			{
347
				$board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to'];
348
				unset($log['extra']['board_to']);
349
			}
350
		}
351
352
		if (isset($log['extra']['member_affected']))
353
			$memID = $log['extra']['member_affected'];
354
		else
355
			$memID = User::$info->id;
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<ElkArte\ValuesContainer>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
356
357
		$inserts[] = array(
358
			time(), $log_types[$log['log_type']], $memID, User::$info->ip, $log['action'],
0 ignored issues
show
Documentation introduced by
The property ip does not exist on object<ElkArte\ValuesContainer>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
359
			$board_id, $topic_id, $msg_id, serialize($log['extra']),
360
		);
361
	}
362
363
	require_once(SUBSDIR . '/Logging.subs.php');
364
365
	return insertLogActions($inserts);
366
}
367