@@ -97,7 +97,7 @@ |
||
| 97 | 97 | $loader->load($this->getProjectDir() . '/config/services.yml'); |
| 98 | 98 | } |
| 99 | 99 | if ($classes = midcom::get_registered_service_classes()) { |
| 100 | - $loader->load(function (ContainerBuilder $container) use ($classes) { |
|
| 100 | + $loader->load(function(ContainerBuilder $container) use ($classes) { |
|
| 101 | 101 | foreach ($classes as $id => $class) { |
| 102 | 102 | $container->findDefinition($id)->setClass($class); |
| 103 | 103 | } |
@@ -165,7 +165,8 @@ discard block |
||
| 165 | 165 | $response = $this->handle($this->request); |
| 166 | 166 | $response->send(); |
| 167 | 167 | $this->terminate($this->request, $response); |
| 168 | - } catch (Error $e) { |
|
| 168 | + } |
|
| 169 | + catch (Error $e) { |
|
| 169 | 170 | $this->getHttpKernel()->terminateWithException($e); |
| 170 | 171 | } |
| 171 | 172 | } |
@@ -222,14 +223,16 @@ discard block |
||
| 222 | 223 | $this->skip_page_style = true; |
| 223 | 224 | try { |
| 224 | 225 | $response = $this->handle($request, HttpKernelInterface::SUB_REQUEST, false); |
| 225 | - } catch (midcom_error $e) { |
|
| 226 | + } |
|
| 227 | + catch (midcom_error $e) { |
|
| 226 | 228 | if ($e instanceof midcom_error_notfound || $e instanceof midcom_error_forbidden) { |
| 227 | 229 | $e->log(); |
| 228 | 230 | midcom_core_context::leave(); |
| 229 | 231 | return; |
| 230 | 232 | } |
| 231 | 233 | throw $e; |
| 232 | - } finally { |
|
| 234 | + } |
|
| 235 | + finally { |
|
| 233 | 236 | $this->skip_page_style = $backup; |
| 234 | 237 | } |
| 235 | 238 | |
@@ -45,7 +45,8 @@ |
||
| 45 | 45 | break; |
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | - } catch (midcom_error $e) { |
|
| 48 | + } |
|
| 49 | + catch (midcom_error $e) { |
|
| 49 | 50 | } |
| 50 | 51 | |
| 51 | 52 | $path_parts = array_reverse($path_parts); |
@@ -159,7 +159,8 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | try { |
| 161 | 161 | eval('?>' . $preparsed); |
| 162 | - } catch (ParseError $e) { |
|
| 162 | + } |
|
| 163 | + catch (ParseError $e) { |
|
| 163 | 164 | throw new midcom_error("Failed to parse style element '{$path}': " . $e->getMessage() . ' in line ' . $e->getLine()); |
| 164 | 165 | } |
| 165 | 166 | } |
@@ -180,7 +181,8 @@ discard block |
||
| 180 | 181 | if ($root_topic->style) { |
| 181 | 182 | $db_style = midcom_db_style::id_from_path($root_topic->style); |
| 182 | 183 | } |
| 183 | - } catch (midcom_error_forbidden $e) { |
|
| 184 | + } |
|
| 185 | + catch (midcom_error_forbidden $e) { |
|
| 184 | 186 | $e->log(); |
| 185 | 187 | } |
| 186 | 188 | |
@@ -152,7 +152,7 @@ |
||
| 152 | 152 | $preparsed = midcom_helper_formatter::compile($style); |
| 153 | 153 | |
| 154 | 154 | if (midcom_core_context::get()->has_custom_key('request_data')) { |
| 155 | - $data =& midcom_core_context::get()->get_custom_key('request_data'); |
|
| 155 | + $data = & midcom_core_context::get()->get_custom_key('request_data'); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | try { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public static function compile(string $content) : string |
| 54 | 54 | { |
| 55 | - return preg_replace_callback("%&\(([^)]*)\);%i", function ($variable) |
|
| 55 | + return preg_replace_callback("%&\(([^)]*)\);%i", function($variable) |
|
| 56 | 56 | { |
| 57 | 57 | $variable_parts = explode(':', $variable[1]); |
| 58 | 58 | $variable = '$' . $variable_parts[0]; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $variable = $parts[0] . '->' . $parts[1]; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if ( isset($variable_parts[1]) |
|
| 65 | + if (isset($variable_parts[1]) |
|
| 66 | 66 | && array_key_exists($variable_parts[1], self::$_filters)) { |
| 67 | 67 | switch ($variable_parts[1]) { |
| 68 | 68 | case 's': |
@@ -196,7 +196,7 @@ |
||
| 196 | 196 | |
| 197 | 197 | private function resolve_includes(string $content) : string |
| 198 | 198 | { |
| 199 | - return preg_replace_callback("/<\\(([a-zA-Z0-9 _-]+)\\)>/", function (array $matches) { |
|
| 199 | + return preg_replace_callback("/<\\(([a-zA-Z0-9 _-]+)\\)>/", function(array $matches) { |
|
| 200 | 200 | $element = $matches[1]; |
| 201 | 201 | |
| 202 | 202 | switch ($element) { |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $tmp = $this->_object; |
| 93 | 93 | |
| 94 | 94 | $i = 0; |
| 95 | - while ( !empty($tmp->guid) |
|
| 95 | + while (!empty($tmp->guid) |
|
| 96 | 96 | && !is_a($tmp, midcom_db_topic::class) |
| 97 | 97 | && $i < 100) { |
| 98 | 98 | // Get the parent; wishing eventually to get a topic |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $assignees = $this->load_assignees(); |
| 139 | 139 | $this->process_assignees($assignees, $schemadb); |
| 140 | - $assignee_field =& $schemadb->get('privileges')->get_field('add_assignee'); |
|
| 140 | + $assignee_field = & $schemadb->get('privileges')->get_field('add_assignee'); |
|
| 141 | 141 | |
| 142 | 142 | if (!$this->additional_assignee) { |
| 143 | 143 | // Populate additional assignee selector |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | if ($assignee = midcom::get()->auth->get_assignee($privilege->assignee)) { |
| 237 | 237 | $label = $assignee->name; |
| 238 | 238 | } else { |
| 239 | - $label = $this->_l10n->get('ghost assignee for '. $privilege->assignee); |
|
| 239 | + $label = $this->_l10n->get('ghost assignee for ' . $privilege->assignee); |
|
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | return null; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if ( midcom::get()->config->get('auth_check_client_ip') |
|
| 84 | + if (midcom::get()->config->get('auth_check_client_ip') |
|
| 85 | 85 | && $data['clientip'] != $request->getClientIp()) { |
| 86 | 86 | debug_add("The session had mismatching client IP.", MIDCOM_LOG_INFO); |
| 87 | 87 | debug_add("Expected {$data['clientip']}, got {$request->getClientIp()}."); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | return null; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if ( !$this->check_timestamp($data['timestamp'], $user) |
|
| 98 | + if (!$this->check_timestamp($data['timestamp'], $user) |
|
| 99 | 99 | || !$this->authenticate($user->username, '', true)) { |
| 100 | 100 | $this->logout($user); |
| 101 | 101 | return null; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $user = midcom_connection::login($username, $password, $trusted); |
| 142 | 142 | |
| 143 | 143 | if (!$user) { |
| 144 | - debug_add("Failed to authenticate the given user: ". midcom_connection::get_error_string(), |
|
| 144 | + debug_add("Failed to authenticate the given user: " . midcom_connection::get_error_string(), |
|
| 145 | 145 | MIDCOM_LOG_INFO); |
| 146 | 146 | return null; |
| 147 | 147 | } |
@@ -87,7 +87,8 @@ |
||
| 87 | 87 | $param = $param->__object; |
| 88 | 88 | } |
| 89 | 89 | $this->_user_cache[$id] = new midcom_core_user($param); |
| 90 | - } catch (midcom_error $e) { |
|
| 90 | + } |
|
| 91 | + catch (midcom_error $e) { |
|
| 91 | 92 | // Keep it silent while missing user object can mess here |
| 92 | 93 | $this->_user_cache[$id] = null; |
| 93 | 94 | } |
@@ -98,7 +98,7 @@ |
||
| 98 | 98 | { |
| 99 | 99 | if (!isset($this->_modules[$name])) { |
| 100 | 100 | $this->_modules[$name] = $module; |
| 101 | - $this->$name =& $this->_modules[$name]; |
|
| 101 | + $this->$name = & $this->_modules[$name]; |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | if (!$this->_schemadb) { |
| 99 | 99 | $this->_schemadb = schemadb::from_path($this->_config->get('schemadb')); |
| 100 | 100 | |
| 101 | - if ( $this->_config->get('use_captcha') |
|
| 102 | - || ( !midcom::get()->auth->user |
|
| 101 | + if ($this->_config->get('use_captcha') |
|
| 102 | + || (!midcom::get()->auth->user |
|
| 103 | 103 | && $this->_config->get('use_captcha_if_anonymous'))) { |
| 104 | 104 | $fields = $this->_schemadb->get('comment')->get('fields'); |
| 105 | 105 | $fields['captcha'] = [ |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $this->_schemadb->get('comment')->set('fields', $fields); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if ( $this->_config->get('ratings_enable') |
|
| 115 | + if ($this->_config->get('ratings_enable') |
|
| 116 | 116 | && $this->_schemadb->get('comment')->has_field('rating')) { |
| 117 | 117 | $this->_schemadb->get('comment')->get_field('rating')['hidden'] = false; |
| 118 | 118 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | $this->_comments = $this->_comments->execute(); |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if ( midcom::get()->auth->user |
|
| 194 | + if (midcom::get()->auth->user |
|
| 195 | 195 | || $this->_config->get('allow_anonymous')) { |
| 196 | 196 | $this->_init_post_controller($request); |
| 197 | 197 | if ($response = $this->_process_post($request)) { |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | private function _process_post(Request $request) |
| 224 | 224 | { |
| 225 | - if ( !midcom::get()->auth->user |
|
| 225 | + if (!midcom::get()->auth->user |
|
| 226 | 226 | && !midcom::get()->auth->request_sudo('net.nehmer.comments')) { |
| 227 | 227 | throw new midcom_error('We were anonymous but could not acquire SUDO privileges, aborting'); |
| 228 | 228 | } |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | $formdata = $this->_post_controller->get_form_values(); |
| 238 | - if ( $formdata['subscribe'] |
|
| 238 | + if ($formdata['subscribe'] |
|
| 239 | 239 | && midcom::get()->auth->user) { |
| 240 | 240 | // User wants to subscribe to receive notifications about this comments thread |
| 241 | 241 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | */ |
| 270 | 270 | private function _get_last_modified() : int |
| 271 | 271 | { |
| 272 | - return array_reduce($this->_comments, function ($carry, net_nehmer_comments_comment $item) { |
|
| 272 | + return array_reduce($this->_comments, function($carry, net_nehmer_comments_comment $item) { |
|
| 273 | 273 | return max($item->metadata->revised, $carry); |
| 274 | 274 | }, 0); |
| 275 | 275 | } |
@@ -291,8 +291,8 @@ discard block |
||
| 291 | 291 | $data['comment_toolbar'] = $this->populate_post_toolbar($comment); |
| 292 | 292 | midcom_show_style('comments-item'); |
| 293 | 293 | |
| 294 | - if ( midcom::get()->auth->admin |
|
| 295 | - || ( midcom::get()->auth->user |
|
| 294 | + if (midcom::get()->auth->admin |
|
| 295 | + || (midcom::get()->auth->user |
|
| 296 | 296 | && $comment->can_do('midgard:delete'))) { |
| 297 | 297 | midcom_show_style('comments-admintoolbar'); |
| 298 | 298 | } |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | midcom_show_style('comments-nonefound'); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - if ( midcom::get()->auth->user |
|
| 305 | + if (midcom::get()->auth->user |
|
| 306 | 306 | || $this->_config->get('allow_anonymous')) { |
| 307 | 307 | midcom_show_style('post-comment'); |
| 308 | 308 | } else { |