@@ -152,7 +152,8 @@ |
||
152 | 152 | try { |
153 | 153 | $topic = new midcom_db_topic($id); |
154 | 154 | $id = $topic->id; |
155 | - } catch (midcom_error $e) { |
|
155 | + } |
|
156 | + catch (midcom_error $e) { |
|
156 | 157 | $e->log(); |
157 | 158 | break; |
158 | 159 | } |
@@ -19,8 +19,8 @@ |
||
19 | 19 | public function _on_initialize() |
20 | 20 | { |
21 | 21 | // Match / |
22 | - if ( $this->_config->get('redirection_type') === null |
|
23 | - || ( $this->_topic->can_do('net.nemein.redirector:noredirect') |
|
22 | + if ($this->_config->get('redirection_type') === null |
|
23 | + || ($this->_topic->can_do('net.nemein.redirector:noredirect') |
|
24 | 24 | && !$this->_config->get('admin_redirection'))) { |
25 | 25 | $this->_request_switch['redirect'] = [ |
26 | 26 | 'handler' => [net_nemein_redirector_handler_tinyurl::class, 'list'], |
@@ -66,7 +66,8 @@ |
||
66 | 66 | try { |
67 | 67 | $author = new midcom_db_person($wikipage->metadata->revisor); |
68 | 68 | $item->author = $author->name; |
69 | - } catch (midcom_error $e) { |
|
69 | + } |
|
70 | + catch (midcom_error $e) { |
|
70 | 71 | $e->log(); |
71 | 72 | } |
72 | 73 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | return; |
51 | 51 | } |
52 | 52 | |
53 | - if ( $history['date'] < $from |
|
53 | + if ($history['date'] < $from |
|
54 | 54 | || $history['date'] > $to) { |
55 | 55 | // We can ignore revisions outside the timeframe |
56 | 56 | continue; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $this->_seek_updated($from); |
94 | 94 | |
95 | 95 | $i = 0; |
96 | - while ( $this->_updated_pages < $this->_max_pages |
|
96 | + while ($this->_updated_pages < $this->_max_pages |
|
97 | 97 | && $i < 20) { |
98 | 98 | // Expand seek by another two weeks |
99 | 99 | $to = $from; |
@@ -61,7 +61,7 @@ |
||
61 | 61 | public function get_link($key = 0, $rel = 'alternate') |
62 | 62 | { |
63 | 63 | $link = parent::get_link($key, $rel); |
64 | - if ( $rel !== 'alternate' |
|
64 | + if ($rel !== 'alternate' |
|
65 | 65 | || $key !== 0) { |
66 | 66 | return $link; |
67 | 67 | } |
@@ -296,7 +296,8 @@ |
||
296 | 296 | // the tree. This is, for example, used by the on-delete cache invalidation. |
297 | 297 | try { |
298 | 298 | $object = midcom::get()->dbfactory->get_object_by_guid($guid); |
299 | - } catch (midcom_error $e) { |
|
299 | + } |
|
300 | + catch (midcom_error $e) { |
|
300 | 301 | debug_add("Could not load GUID {$guid}, trying to continue anyway. Last error was: " . $e->getMessage(), MIDCOM_LOG_WARN); |
301 | 302 | } |
302 | 303 | if (!empty($object)) { |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | while ($parent = $object->get_parent()) { |
337 | 337 | // Verify that this topic is within the current sites tree, if it is not, |
338 | 338 | // we ignore it. |
339 | - if ( is_a($parent, midcom_db_topic::class) |
|
339 | + if (is_a($parent, midcom_db_topic::class) |
|
340 | 340 | && $this->is_node_in_tree($parent->id, $this->get_root_node())) { |
341 | 341 | return $parent; |
342 | 342 | } |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | $entry = "<span class=\"{$current_class}\">{$entry}</span>"; |
391 | 391 | } |
392 | 392 | } else { |
393 | - if ( !empty($data['napobject'][MIDCOM_NAV_GUID]) |
|
393 | + if (!empty($data['napobject'][MIDCOM_NAV_GUID]) |
|
394 | 394 | && in_array($data['napobject'][MIDCOM_NAV_GUID], $skip_guids)) { |
395 | 395 | continue; |
396 | 396 | } |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | $id = "custom-{$key}"; |
505 | 505 | |
506 | 506 | $url = "{$prefix}{$entry[MIDCOM_NAV_URL]}"; |
507 | - if ( str_starts_with($entry[MIDCOM_NAV_URL], '/') |
|
507 | + if (str_starts_with($entry[MIDCOM_NAV_URL], '/') |
|
508 | 508 | || preg_match('|^https?://|', $entry[MIDCOM_NAV_URL])) { |
509 | 509 | $url = $entry[MIDCOM_NAV_URL]; |
510 | 510 | } |
@@ -52,7 +52,8 @@ |
||
52 | 52 | } elseif (!empty($this->data[MIDCOM_NAV_GUID])) { |
53 | 53 | try { |
54 | 54 | $this->data[MIDCOM_NAV_OBJECT] = midcom::get()->dbfactory->get_object_by_guid($this->data[MIDCOM_NAV_GUID]); |
55 | - } catch (midcom_error $e) { |
|
55 | + } |
|
56 | + catch (midcom_error $e) { |
|
56 | 57 | } |
57 | 58 | } else { |
58 | 59 | debug_add("Warning: The leaf {$this->leafid} of topic {$topic->id} does set neither a GUID nor an object."); |
@@ -28,7 +28,7 @@ |
||
28 | 28 | |
29 | 29 | public function is_readable_by(string $user_id) : bool |
30 | 30 | { |
31 | - return ( empty($this->object) |
|
31 | + return (empty($this->object) |
|
32 | 32 | || !$this->guid |
33 | 33 | || !$user_id |
34 | 34 | || midcom::get()->auth->acl->can_do_byguid('midgard:read', $this->guid, $this->object->__midcom_class_name__, $user_id)); |
@@ -658,7 +658,8 @@ |
||
658 | 658 | && mgd_is_guid($guid)) { |
659 | 659 | try { |
660 | 660 | $object = midcom::get()->dbfactory->get_object_by_guid($guid); |
661 | - } catch (midcom_error $e) { |
|
661 | + } |
|
662 | + catch (midcom_error $e) { |
|
662 | 663 | debug_add("Failed to create a metadata instance for the GUID {$guid}: " . $e->getMessage(), MIDCOM_LOG_WARN); |
663 | 664 | debug_print_r("Source was:", $source); |
664 | 665 |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | { |
293 | 293 | if (in_array($key, $this->field_config['timebased'])) { |
294 | 294 | // This is ugly, but seems the only possible way... |
295 | - if ( isset($this->__metadata->$key) |
|
295 | + if (isset($this->__metadata->$key) |
|
296 | 296 | && (string) $this->__metadata->$key !== "0001-01-01T00:00:00+00:00") { |
297 | 297 | return (int) $this->__metadata->$key->format('U'); |
298 | 298 | } |
@@ -354,11 +354,11 @@ discard block |
||
354 | 354 | } |
355 | 355 | |
356 | 356 | $now = time(); |
357 | - if ( $this->get('schedulestart') |
|
357 | + if ($this->get('schedulestart') |
|
358 | 358 | && $this->get('schedulestart') > $now) { |
359 | 359 | return false; |
360 | 360 | } |
361 | - if ( $this->get('scheduleend') |
|
361 | + if ($this->get('scheduleend') |
|
362 | 362 | && $this->get('scheduleend') < $now) { |
363 | 363 | return false; |
364 | 364 | } |
@@ -374,9 +374,9 @@ discard block |
||
374 | 374 | public function is_object_visible_onsite() : bool |
375 | 375 | { |
376 | 376 | return |
377 | - ( ( midcom::get()->config->get('show_hidden_objects') |
|
377 | + ((midcom::get()->config->get('show_hidden_objects') |
|
378 | 378 | || $this->is_visible()) |
379 | - && ( midcom::get()->config->get('show_unapproved_objects') |
|
379 | + && (midcom::get()->config->get('show_unapproved_objects') |
|
380 | 380 | || $this->is_approved()) |
381 | 381 | ); |
382 | 382 | } |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | $guid = $source; |
435 | 435 | } |
436 | 436 | |
437 | - if ( $object === null |
|
437 | + if ($object === null |
|
438 | 438 | && mgd_is_guid($guid)) { |
439 | 439 | try { |
440 | 440 | $object = midcom::get()->dbfactory->get_object_by_guid($guid); |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | } |
468 | 468 | |
469 | 469 | // Lock was created by the user, return "not locked" |
470 | - if ( !empty(midcom::get()->auth->user->guid) |
|
470 | + if (!empty(midcom::get()->auth->user->guid) |
|
471 | 471 | && $this->get('locker') === midcom::get()->auth->user->guid) { |
472 | 472 | return false; |
473 | 473 | } |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | */ |
501 | 501 | public function can_unlock() : bool |
502 | 502 | { |
503 | - return ( $this->__object->can_do('midcom:unlock') |
|
503 | + return ($this->__object->can_do('midcom:unlock') |
|
504 | 504 | || midcom::get()->auth->can_user_do('midcom:unlock', null, midcom_services_auth::class)); |
505 | 505 | } |
506 | 506 | |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | */ |
512 | 512 | public function unlock() : bool |
513 | 513 | { |
514 | - if ( $this->can_unlock() |
|
514 | + if ($this->can_unlock() |
|
515 | 515 | && $this->__object->unlock()) { |
516 | 516 | $this->_cache = []; |
517 | 517 | return true; |
@@ -69,7 +69,8 @@ |
||
69 | 69 | // Use the DB Factory to resolve the class and to get the object |
70 | 70 | try { |
71 | 71 | $object = midcom::get()->dbfactory->get_object_by_guid($identifier); |
72 | - } catch (midcom_error $e) { |
|
72 | + } |
|
73 | + catch (midcom_error $e) { |
|
73 | 74 | // This is probably a pseudo leaf, store the score to the current node |
74 | 75 | $this->_topic->set_parameter('midcom.helper.nav.score', $identifier, $score); |
75 | 76 | return true; |
@@ -89,7 +89,7 @@ |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | // Approve if possible |
92 | - if ( $approval_status |
|
92 | + if ($approval_status |
|
93 | 93 | && $object->can_do('midcom:approve')) { |
94 | 94 | $object->metadata->approve(); |
95 | 95 | } |
@@ -132,7 +132,8 @@ |
||
132 | 132 | && $nodeobject = $nav->get_node($node->id)) { |
133 | 133 | $napobject = $nav->get_leaf($nodeobject[MIDCOM_NAV_ID] . '-' . $object->id); |
134 | 134 | } |
135 | - } catch (midcom_error $e) { |
|
135 | + } |
|
136 | + catch (midcom_error $e) { |
|
136 | 137 | $e->log(); |
137 | 138 | } |
138 | 139 | return $napobject; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | // Get parent from DB and compare to catch moves |
72 | 72 | if ($parent = $napobject[MIDCOM_NAV_OBJECT]->get_parent()) { |
73 | 73 | $parent_entry = $this->get_guid($parent->guid); |
74 | - if ( $parent_entry |
|
74 | + if ($parent_entry |
|
75 | 75 | && $parent_entry[MIDCOM_NAV_ID] != $cached_node_id) { |
76 | 76 | $this->backend->delete($parent_entry[MIDCOM_NAV_ID] . '-leaves'); |
77 | 77 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $parent_id = $napobject[MIDCOM_NAV_NODEID]; |
87 | 87 | $parent_entry = $this->get_node($parent_id); |
88 | 88 | |
89 | - if ( $parent_entry |
|
89 | + if ($parent_entry |
|
90 | 90 | && array_key_exists(MIDCOM_NAV_SUBNODES, $parent_entry)) { |
91 | 91 | unset($parent_entry[MIDCOM_NAV_SUBNODES]); |
92 | 92 | $this->put_node($parent_id, $parent_entry); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | if ($parent = $napobject[MIDCOM_NAV_OBJECT]->get_parent()) { |
97 | 97 | $parent_entry_from_object = $this->get_guid($parent->guid); |
98 | 98 | |
99 | - if ( !empty($parent_entry_from_object[MIDCOM_NAV_ID]) |
|
99 | + if (!empty($parent_entry_from_object[MIDCOM_NAV_ID]) |
|
100 | 100 | && !empty($parent_entry[MIDCOM_NAV_ID]) |
101 | 101 | && $parent_entry_from_object[MIDCOM_NAV_ID] != $parent_entry[MIDCOM_NAV_ID]) { |
102 | 102 | unset($parent_entry_from_object[MIDCOM_NAV_SUBNODES]); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $nav = new midcom_helper_nav; |
123 | 123 | if ($object instanceof midcom_db_topic) { |
124 | 124 | $napobject = $nav->get_node($object->id); |
125 | - } elseif ( ($node = $nav->find_closest_topic($object)) |
|
125 | + } elseif (($node = $nav->find_closest_topic($object)) |
|
126 | 126 | && $nodeobject = $nav->get_node($node->id)) { |
127 | 127 | $napobject = $nav->get_leaf($nodeobject[MIDCOM_NAV_ID] . '-' . $object->id); |
128 | 128 | } |