@@ -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)) { |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | while ($parent = $object->get_parent()) { |
| 341 | 341 | // Verify that this topic is within the current sites tree, if it is not, |
| 342 | 342 | // we ignore it. |
| 343 | - if ( $parent instanceof midcom_db_topic |
|
| 343 | + if ($parent instanceof midcom_db_topic |
|
| 344 | 344 | && $this->is_node_in_tree($parent->id, $this->get_root_node())) { |
| 345 | 345 | return $parent; |
| 346 | 346 | } |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | $entry = "<span class=\"{$current_class}\">{$entry}</span>"; |
| 395 | 395 | } |
| 396 | 396 | } else { |
| 397 | - if ( !empty($data['napobject'][MIDCOM_NAV_GUID]) |
|
| 397 | + if (!empty($data['napobject'][MIDCOM_NAV_GUID]) |
|
| 398 | 398 | && in_array($data['napobject'][MIDCOM_NAV_GUID], $skip_guids)) { |
| 399 | 399 | continue; |
| 400 | 400 | } |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | $id = "custom-{$key}"; |
| 509 | 509 | |
| 510 | 510 | $url = "{$prefix}{$entry[MIDCOM_NAV_URL]}"; |
| 511 | - if ( str_starts_with($entry[MIDCOM_NAV_URL], '/') |
|
| 511 | + if (str_starts_with($entry[MIDCOM_NAV_URL], '/') |
|
| 512 | 512 | || preg_match('|^https?://|', $entry[MIDCOM_NAV_URL])) { |
| 513 | 513 | $url = $entry[MIDCOM_NAV_URL]; |
| 514 | 514 | } |
@@ -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 | |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | { |
| 263 | 263 | if (in_array($key, $this->field_config['timebased'])) { |
| 264 | 264 | // This is ugly, but seems the only possible way... |
| 265 | - if ( isset($this->__metadata->$key) |
|
| 265 | + if (isset($this->__metadata->$key) |
|
| 266 | 266 | && (string) $this->__metadata->$key !== "0001-01-01T00:00:00+00:00") { |
| 267 | 267 | return (int) $this->__metadata->$key->format('U'); |
| 268 | 268 | } |
@@ -323,11 +323,11 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | $now = time(); |
| 326 | - if ( $this->get('schedulestart') |
|
| 326 | + if ($this->get('schedulestart') |
|
| 327 | 327 | && $this->get('schedulestart') > $now) { |
| 328 | 328 | return false; |
| 329 | 329 | } |
| 330 | - if ( $this->get('scheduleend') |
|
| 330 | + if ($this->get('scheduleend') |
|
| 331 | 331 | && $this->get('scheduleend') < $now) { |
| 332 | 332 | return false; |
| 333 | 333 | } |
@@ -343,9 +343,9 @@ discard block |
||
| 343 | 343 | public function is_object_visible_onsite() : bool |
| 344 | 344 | { |
| 345 | 345 | return |
| 346 | - ( ( midcom::get()->config->get('show_hidden_objects') |
|
| 346 | + ((midcom::get()->config->get('show_hidden_objects') |
|
| 347 | 347 | || $this->is_visible()) |
| 348 | - && ( midcom::get()->config->get('show_unapproved_objects') |
|
| 348 | + && (midcom::get()->config->get('show_unapproved_objects') |
|
| 349 | 349 | || $this->is_approved()) |
| 350 | 350 | ); |
| 351 | 351 | } |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | $guid = $source; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - if ( $object === null |
|
| 405 | + if ($object === null |
|
| 406 | 406 | && mgd_is_guid($guid)) { |
| 407 | 407 | try { |
| 408 | 408 | $object = midcom::get()->dbfactory->get_object_by_guid($guid); |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | // Lock was created by the user, return "not locked" |
| 438 | - if ( !empty(midcom::get()->auth->user->guid) |
|
| 438 | + if (!empty(midcom::get()->auth->user->guid) |
|
| 439 | 439 | && $this->get('locker') === midcom::get()->auth->user->guid) { |
| 440 | 440 | return false; |
| 441 | 441 | } |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | */ |
| 463 | 463 | public function can_unlock() : bool |
| 464 | 464 | { |
| 465 | - return ( $this->__object->can_do('midcom:unlock') |
|
| 465 | + return ($this->__object->can_do('midcom:unlock') |
|
| 466 | 466 | || midcom::get()->auth->can_user_do('midcom:unlock', null, midcom_services_auth::class)); |
| 467 | 467 | } |
| 468 | 468 | |
@@ -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; |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | // Get parent from DB and compare to catch moves |
| 55 | 55 | if ($parent = $napobject[MIDCOM_NAV_OBJECT]->get_parent()) { |
| 56 | 56 | $parent_entry = $this->get_guid($parent->guid); |
| 57 | - if ( $parent_entry |
|
| 57 | + if ($parent_entry |
|
| 58 | 58 | && $parent_entry[MIDCOM_NAV_ID] != $cached_node_id) { |
| 59 | 59 | $this->backend->deleteItem($parent_entry[MIDCOM_NAV_ID] . '-leaves'); |
| 60 | 60 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $parent_id = $napobject[MIDCOM_NAV_NODEID]; |
| 70 | 70 | $parent_entry = $this->get_node($parent_id); |
| 71 | 71 | |
| 72 | - if ( $parent_entry |
|
| 72 | + if ($parent_entry |
|
| 73 | 73 | && array_key_exists(MIDCOM_NAV_SUBNODES, $parent_entry)) { |
| 74 | 74 | unset($parent_entry[MIDCOM_NAV_SUBNODES]); |
| 75 | 75 | $this->put_node($parent_id, $parent_entry); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | if ($parent = $napobject[MIDCOM_NAV_OBJECT]->get_parent()) { |
| 80 | 80 | $parent_entry_from_object = $this->get_guid($parent->guid); |
| 81 | 81 | |
| 82 | - if ( !empty($parent_entry_from_object[MIDCOM_NAV_ID]) |
|
| 82 | + if (!empty($parent_entry_from_object[MIDCOM_NAV_ID]) |
|
| 83 | 83 | && !empty($parent_entry[MIDCOM_NAV_ID]) |
| 84 | 84 | && $parent_entry_from_object[MIDCOM_NAV_ID] != $parent_entry[MIDCOM_NAV_ID]) { |
| 85 | 85 | unset($parent_entry_from_object[MIDCOM_NAV_SUBNODES]); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $nav = new midcom_helper_nav; |
| 106 | 106 | if ($object instanceof midcom_db_topic) { |
| 107 | 107 | $napobject = $nav->get_node($object->id); |
| 108 | - } elseif ( ($node = $nav->find_closest_topic($object)) |
|
| 108 | + } elseif (($node = $nav->find_closest_topic($object)) |
|
| 109 | 109 | && $nodeobject = $nav->get_node($node->id)) { |
| 110 | 110 | $napobject = $nav->get_leaf($nodeobject[MIDCOM_NAV_ID] . '-' . $object->id); |
| 111 | 111 | } |
@@ -72,7 +72,8 @@ |
||
| 72 | 72 | |
| 73 | 73 | try { |
| 74 | 74 | $object = midcom::get()->dbfactory->get_object_by_guid($guid); |
| 75 | - } catch (midcom_error $e) { |
|
| 75 | + } |
|
| 76 | + catch (midcom_error $e) { |
|
| 76 | 77 | debug_add("Failed to resolve the GUID {$guid}, this is most probably an access denied error.", MIDCOM_LOG_ERROR); |
| 77 | 78 | debug_add('Last MidCOM error string: ' . $e->getMessage()); |
| 78 | 79 | return null; |
@@ -109,7 +109,7 @@ |
||
| 109 | 109 | */ |
| 110 | 110 | public function members_to_fields() |
| 111 | 111 | { |
| 112 | - if ( empty($this->topic_guid) |
|
| 112 | + if (empty($this->topic_guid) |
|
| 113 | 113 | || empty($this->topic_url) |
| 114 | 114 | || empty($this->component)) { |
| 115 | 115 | //if one of those is missing, we override all three to ensure consistency |
@@ -104,7 +104,7 @@ |
||
| 104 | 104 | $this->add('Setting: upload_max_filesize', self::OK, ini_get('upload_max_filesize')); |
| 105 | 105 | } else { |
| 106 | 106 | $this->add('Setting: upload_max_filesize', |
| 107 | - self::WARNING, "To make bulk uploads (for exampe in the Image Gallery) useful, you should increase the Upload limit to something above 50 MB. (Current setting: {$upload_limit})"); |
|
| 107 | + self::WARNING, "To make bulk uploads (for exampe in the Image Gallery) useful, you should increase the Upload limit to something above 50 MB. (Current setting: {$upload_limit})"); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $post_limit = $this->ini_get_filesize('post_max_size'); |
@@ -81,7 +81,8 @@ |
||
| 81 | 81 | $class = $config->get_backend_class(); |
| 82 | 82 | new $class(new midcom_db_topic, $config); |
| 83 | 83 | $this->add("MidCOM RCS", self::OK, $class); |
| 84 | - } catch (midcom_error $e) { |
|
| 84 | + } |
|
| 85 | + catch (midcom_error $e) { |
|
| 85 | 86 | $this->add("MidCOM RCS", self::ERROR, $e->getMessage()); |
| 86 | 87 | } |
| 87 | 88 | } else { |