Completed
Branch master (7d3f82)
by Thomas
09:15
created
htdocs/okapi/services/users/by_internal_id.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
     public static function call(OkapiRequest $request)
24 24
     {
25 25
         $internal_id = $request->get_parameter('internal_id');
26
-        if (!$internal_id) throw new ParamMissing('internal_id');
26
+        if (!$internal_id) {
27
+            throw new ParamMissing('internal_id');
28
+        }
27 29
         $fields = $request->get_parameter('fields');
28 30
 
29 31
         # There's no need to validate the fields parameter.
@@ -32,8 +34,9 @@  discard block
 block discarded – undo
32 34
             $request->consumer, $request->token, array('internal_ids' => $internal_id,
33 35
             'fields' => $fields)));
34 36
         $result = $results[$internal_id];
35
-        if ($result == null)
36
-            throw new InvalidParam('internal_id', "There is no user by this internal_id.");
37
+        if ($result == null) {
38
+                    throw new InvalidParam('internal_id', "There is no user by this internal_id.");
39
+        }
37 40
         return Okapi::formatted_response($request, $result);
38 41
     }
39 42
 }
Please login to merge, or discard this patch.
htdocs/okapi/services/users/by_usernames.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
         if (!$usernames) throw new ParamMissing('usernames');
28 28
         $usernames = explode("|", $usernames);
29 29
         if (count($usernames) > 500)
30
-            throw new InvalidParam('usernames', "Maximum allowed number of referenced users ".
31
-                "is 500. You provided ".count($usernames)." usernames.");
30
+            throw new InvalidParam('usernames', "Maximum allowed number of referenced users " .
31
+                "is 500. You provided " . count($usernames) . " usernames.");
32 32
         $fields = $request->get_parameter('fields');
33 33
         if (!$fields)
34 34
             throw new ParamMissing('fields');
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         $rs = Db::query("
40 40
             select username, uuid
41 41
             from user
42
-            where username collate ".Settings::get('DB_CHARSET')."_general_ci in ('".implode("','", array_map('\okapi\Db::escape_string', $usernames))."')
42
+            where username collate ".Settings::get('DB_CHARSET') . "_general_ci in ('" . implode("','", array_map('\okapi\Db::escape_string', $usernames)) . "')
43 43
         ");
44 44
         $lower_username2useruuid = array();
45 45
         while ($row = Db::fetch_assoc($rs))
Please login to merge, or discard this patch.
Braces   +14 added lines, -9 removed lines patch added patch discarded remove patch
@@ -24,14 +24,18 @@  discard block
 block discarded – undo
24 24
     public static function call(OkapiRequest $request)
25 25
     {
26 26
         $usernames = $request->get_parameter('usernames');
27
-        if (!$usernames) throw new ParamMissing('usernames');
27
+        if (!$usernames) {
28
+            throw new ParamMissing('usernames');
29
+        }
28 30
         $usernames = explode("|", $usernames);
29
-        if (count($usernames) > 500)
30
-            throw new InvalidParam('usernames', "Maximum allowed number of referenced users ".
31
+        if (count($usernames) > 500) {
32
+                    throw new InvalidParam('usernames', "Maximum allowed number of referenced users ".
31 33
                 "is 500. You provided ".count($usernames)." usernames.");
34
+        }
32 35
         $fields = $request->get_parameter('fields');
33
-        if (!$fields)
34
-            throw new ParamMissing('fields');
36
+        if (!$fields) {
37
+                    throw new ParamMissing('fields');
38
+        }
35 39
 
36 40
         # There's no need to validate the fields parameter as the 'users'
37 41
         # method does this (it will raise a proper exception on invalid values).
@@ -65,10 +69,11 @@  discard block
 block discarded – undo
65 69
         $results = array();
66 70
         foreach ($usernames as $username)
67 71
         {
68
-            if (!isset($lower_username2useruuid[mb_strtolower($username, 'utf-8')]))
69
-                $results[$username] = null;
70
-            else
71
-                $results[$username] = $id_results[$lower_username2useruuid[mb_strtolower($username, 'utf-8')]];
72
+            if (!isset($lower_username2useruuid[mb_strtolower($username, 'utf-8')])) {
73
+                            $results[$username] = null;
74
+            } else {
75
+                            $results[$username] = $id_results[$lower_username2useruuid[mb_strtolower($username, 'utf-8')]];
76
+            }
72 77
         }
73 78
 
74 79
         return Okapi::formatted_response($request, $results);
Please login to merge, or discard this patch.
htdocs/okapi/services/users/user.php 1 patch
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,8 +33,7 @@  discard block
 block discarded – undo
33 33
                 $tmp = OkapiServiceRunner::call('services/users/by_internal_id', new OkapiInternalRequest(
34 34
                     $request->consumer, null, array('internal_id' => $request->token->user_id, 'fields' => 'uuid')));
35 35
                 $user_uuid = $tmp['uuid'];
36
-            }
37
-            else
36
+            } else
38 37
             {
39 38
                 throw new BadRequest("You must either: 1. supply the user_uuid argument, or "
40 39
                     ."2. sign your request with an Access Token.");
@@ -49,8 +48,9 @@  discard block
 block discarded – undo
49 48
             $request->consumer, $request->token, array('user_uuids' => $user_uuid,
50 49
             'fields' => $fields)));
51 50
         $result = $results[$user_uuid];
52
-        if ($result == null)
53
-            throw new InvalidParam('user_uuid', "There is no user by this ID.");
51
+        if ($result == null) {
52
+                    throw new InvalidParam('user_uuid', "There is no user by this ID.");
53
+        }
54 54
         return Okapi::formatted_response($request, $result);
55 55
     }
56 56
 }
Please login to merge, or discard this patch.
htdocs/okapi/services/oauth/request_token.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 
31 31
         $response = new OkapiHttpResponse();
32 32
         $response->content_type = "text/plain; charset=utf-8";
33
-        $response->body = $new_token."&oauth_callback_confirmed=true";
33
+        $response->body = $new_token . "&oauth_callback_confirmed=true";
34 34
         return $response;
35 35
     }
36 36
 }
Please login to merge, or discard this patch.
htdocs/okapi/services/oauth/authorize.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@
 block discarded – undo
34 34
         # done in the "services" folder. 2) "services" don't display
35 35
         # any interactive webpages, they just return the result.
36 36
 
37
-        return new OkapiRedirectResponse(Settings::get('SITE_URL')."okapi/apps/authorize".
38
-            "?oauth_token=".$token_key.(($langpref != null) ? "&langpref=".$langpref : "").
39
-            "&interactivity=".$interactivity);
37
+        return new OkapiRedirectResponse(Settings::get('SITE_URL') . "okapi/apps/authorize" .
38
+            "?oauth_token=" . $token_key . (($langpref != null) ? "&langpref=" . $langpref : "") .
39
+            "&interactivity=" . $interactivity);
40 40
     }
41 41
 }
Please login to merge, or discard this patch.
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,13 +21,17 @@
 block discarded – undo
21 21
     public static function call(OkapiRequest $request)
22 22
     {
23 23
         $token_key = $request->get_parameter('oauth_token');
24
-        if (!$token_key)
25
-            throw new ParamMissing("oauth_token");
24
+        if (!$token_key) {
25
+                    throw new ParamMissing("oauth_token");
26
+        }
26 27
         $langpref = $request->get_parameter('langpref');
27 28
         $interactivity = $request->get_parameter('interactivity');
28
-        if (!$interactivity) $interactivity = 'minimal';
29
-        if (!in_array($interactivity, array('minimal', 'confirm_user')))
30
-            throw new InvalidParam('interactivity', $interactivity);
29
+        if (!$interactivity) {
30
+            $interactivity = 'minimal';
31
+        }
32
+        if (!in_array($interactivity, array('minimal', 'confirm_user'))) {
33
+                    throw new InvalidParam('interactivity', $interactivity);
34
+        }
31 35
 
32 36
         # Redirect to the "apps" folder. This is done there (not here)
33 37
         # because: 1) we don't want any cookie or session-handling
Please login to merge, or discard this patch.
htdocs/okapi/services/attrs/attribute_index.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,13 +30,19 @@
 block discarded – undo
30 30
         # Read the parameters.
31 31
 
32 32
         $langpref = $request->get_parameter('langpref');
33
-        if (!$langpref) $langpref = "en";
33
+        if (!$langpref) {
34
+            $langpref = "en";
35
+        }
34 36
 
35 37
         $fields = $request->get_parameter('fields');
36
-        if (!$fields) $fields = "name";
38
+        if (!$fields) {
39
+            $fields = "name";
40
+        }
37 41
 
38 42
         $only_locally_used = $request->get_parameter('only_locally_used');
39
-        if (!$only_locally_used) $only_locally_used = "false";
43
+        if (!$only_locally_used) {
44
+            $only_locally_used = "false";
45
+        }
40 46
         $only_locally_used = ($only_locally_used == "true");
41 47
 
42 48
         # Get the list of attributes and filter the A-codes based on the
Please login to merge, or discard this patch.
htdocs/okapi/services/attrs/attributes.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             # Fill some other fields (not kept in the cached attrdict).
91 91
 
92 92
             $attr['is_locally_used'] = ($attr['internal_id'] !== null);
93
-            $attr['is_deprecated'] = $attr['is_discontinued'];  // deprecated and undocumetned field, see issue 70
93
+            $attr['is_deprecated'] = $attr['is_discontinued']; // deprecated and undocumetned field, see issue 70
94 94
 
95 95
             # Add to results.
96 96
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
                 $internal_id = $attr_ref['internal_id'];
120 120
                 if (isset($map[$internal_id])) {
121 121
                     $row = $map[$internal_id];
122
-                    $attr_ref['local_icon_url'] = $prefix.$row['icon_large'];
122
+                    $attr_ref['local_icon_url'] = $prefix . $row['icon_large'];
123 123
                 } else {
124 124
                     $attr_ref['local_icon_url'] = null;
125 125
                 }
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -35,26 +35,36 @@  discard block
 block discarded – undo
35 35
         # Read the parameters.
36 36
 
37 37
         $acodes = $request->get_parameter('acodes');
38
-        if (!$acodes) throw new ParamMissing('acodes');
38
+        if (!$acodes) {
39
+            throw new ParamMissing('acodes');
40
+        }
39 41
         $acodes = explode("|", $acodes);
40 42
 
41 43
         $langpref = $request->get_parameter('langpref');
42
-        if (!$langpref) $langpref = "en";
44
+        if (!$langpref) {
45
+            $langpref = "en";
46
+        }
43 47
         $langpref = explode("|", $langpref);
44 48
 
45 49
         $fields = $request->get_parameter('fields');
46
-        if (!$fields) $fields = "name";
50
+        if (!$fields) {
51
+            $fields = "name";
52
+        }
47 53
         $fields = explode("|", $fields);
48 54
         foreach ($fields as $field)
49 55
         {
50
-            if (!in_array($field, self::$valid_field_names))
51
-                throw new InvalidParam('fields', "'$field' is not a valid field code.");
56
+            if (!in_array($field, self::$valid_field_names)) {
57
+                            throw new InvalidParam('fields', "'$field' is not a valid field code.");
58
+            }
52 59
         }
53 60
 
54 61
         $forward_compatible = $request->get_parameter('forward_compatible');
55
-        if (!$forward_compatible) $forward_compatible = "true";
56
-        if (!in_array($forward_compatible, array("true", "false")))
57
-            throw new InvalidParam('forward_compatible');
62
+        if (!$forward_compatible) {
63
+            $forward_compatible = "true";
64
+        }
65
+        if (!in_array($forward_compatible, array("true", "false"))) {
66
+                    throw new InvalidParam('forward_compatible');
67
+        }
58 68
         $forward_compatible = ($forward_compatible == "true");
59 69
 
60 70
         # Load the attributes (all of them).
@@ -133,8 +143,9 @@  discard block
 block discarded – undo
133 143
                 continue;
134 144
             }
135 145
             $clean_row = array();
136
-            foreach ($fields as $field)
137
-                $clean_row[$field] = $attr_ref[$field];
146
+            foreach ($fields as $field) {
147
+                            $clean_row[$field] = $attr_ref[$field];
148
+            }
138 149
             $attr_ref = $clean_row;
139 150
         }
140 151
 
Please login to merge, or discard this patch.
htdocs/okapi/services/attrs/attribute.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 
31 31
         $acode = $request->get_parameter('acode');
32 32
         if ($acode === null) throw new ParamMissing('acode');
33
-        if (strstr($acode,'|')) throw new InvalidParam('acode', "Only a single A-code must be supplied.");
33
+        if (strstr($acode, '|')) throw new InvalidParam('acode', "Only a single A-code must be supplied.");
34 34
 
35 35
         $langpref = $request->get_parameter('langpref');
36 36
         if (!$langpref) $langpref = "en";
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,17 +29,27 @@
 block discarded – undo
29 29
         # Read the parameters.
30 30
 
31 31
         $acode = $request->get_parameter('acode');
32
-        if ($acode === null) throw new ParamMissing('acode');
33
-        if (strstr($acode,'|')) throw new InvalidParam('acode', "Only a single A-code must be supplied.");
32
+        if ($acode === null) {
33
+            throw new ParamMissing('acode');
34
+        }
35
+        if (strstr($acode,'|')) {
36
+            throw new InvalidParam('acode', "Only a single A-code must be supplied.");
37
+        }
34 38
 
35 39
         $langpref = $request->get_parameter('langpref');
36
-        if (!$langpref) $langpref = "en";
40
+        if (!$langpref) {
41
+            $langpref = "en";
42
+        }
37 43
 
38 44
         $fields = $request->get_parameter('fields');
39
-        if (!$fields) $fields = "name";
45
+        if (!$fields) {
46
+            $fields = "name";
47
+        }
40 48
 
41 49
         $forward_compatible = $request->get_parameter('forward_compatible');
42
-        if (!$forward_compatible) $forward_compatible = "true";
50
+        if (!$forward_compatible) {
51
+            $forward_compatible = "true";
52
+        }
43 53
 
44 54
         # Pass them all to the attributes method.
45 55
 
Please login to merge, or discard this patch.
htdocs/okapi/services/attrs/attr_helper.inc.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     {
52 52
         try
53 53
         {
54
-            $path = $GLOBALS['rootpath']."okapi/services/attrs/attribute-definitions.xml";
54
+            $path = $GLOBALS['rootpath'] . "okapi/services/attrs/attribute-definitions.xml";
55 55
             $xml = file_get_contents($path);
56 56
             self::refresh_from_string($xml);
57 57
         }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
                 # That's bad! We don't have ANY copy of the data AND we failed
68 68
                 # to parse it. We will use a fake, empty data.
69 69
 
70
-                $cache_key = "attrhelper/dict#".Okapi::$git_revision.self::cache_key_suffix();
70
+                $cache_key = "attrhelper/dict#" . Okapi::$git_revision . self::cache_key_suffix();
71 71
                 $cachedvalue = array(
72 72
                     'attr_dict' => array(),
73 73
                 );
@@ -128,12 +128,12 @@  discard block
 block discarded – undo
128 128
 
129 129
                     $internal_id = (int)$ocnode['id'];
130 130
                     if (isset($all_internal_ids[$internal_id]))
131
-                        throw new Exception("The internal attribute ".$internal_id.
131
+                        throw new Exception("The internal attribute " . $internal_id .
132 132
                             " has multiple assigments to OKAPI attributes.");
133 133
                     $all_internal_ids[$internal_id] = true;
134 134
                     if (!is_null($attr['internal_id']))
135
-                        throw new Exception("There are multiple internal IDs for the ".
136
-                            $attr['acode']." attribute.");
135
+                        throw new Exception("There are multiple internal IDs for the " .
136
+                            $attr['acode'] . " attribute.");
137 137
                     $attr['internal_id'] = $internal_id;
138 138
                 }
139 139
             }
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
                 foreach ($langnode->name as $namenode)
144 144
                 {
145 145
                     if (isset($attr['names'][$lang]))
146
-                        throw new Exception("Duplicate ".$lang." name of attribute ".$attr['acode']);
146
+                        throw new Exception("Duplicate " . $lang . " name of attribute " . $attr['acode']);
147 147
                     $attr['names'][$lang] = (string)$namenode;
148 148
                 }
149 149
                 foreach ($langnode->desc as $descnode)
150 150
                 {
151 151
                     if (isset($attr['descriptions'][$lang]))
152
-                        throw new Exception("Duplicate ".$lang." description of attribute ".$attr['acode']);
152
+                        throw new Exception("Duplicate " . $lang . " description of attribute " . $attr['acode']);
153 153
                     $xml = $descnode->asxml(); /* contains "<desc>" and "</desc>" */
154 154
                     $innerxml = preg_replace("/(^[^>]+>)|(<[^<]+$)/us", "", $xml);
155 155
                     $attr['descriptions'][$lang] = self::cleanup_string($innerxml);
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             $cachedvalue['attr_dict'][$attr['acode']] = $attr;
159 159
         }
160 160
 
161
-        $cache_key = "attrhelper/dict#".Okapi::$git_revision.self::cache_key_suffix();
161
+        $cache_key = "attrhelper/dict#" . Okapi::$git_revision . self::cache_key_suffix();
162 162
         Cache::set($cache_key, $cachedvalue, self::ttl());
163 163
         self::$attr_dict = $cachedvalue['attr_dict'];
164 164
     }
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
             ),
178 178
             'descriptions' => array(
179 179
                 'en' => (
180
-                    "This attribute ($acode) is unknown at ".Okapi::get_normalized_site_name().
181
-                    ". It might not exist, or it may be a new attribute, recognized ".
182
-                    "only in newer OKAPI installations. Perhaps ".Okapi::get_normalized_site_name().
180
+                    "This attribute ($acode) is unknown at " . Okapi::get_normalized_site_name() .
181
+                    ". It might not exist, or it may be a new attribute, recognized " .
182
+                    "only in newer OKAPI installations. Perhaps " . Okapi::get_normalized_site_name() .
183 183
                     " needs to have its OKAPI updated?"
184 184
                 )
185 185
             ),
@@ -192,14 +192,14 @@  discard block
 block discarded – undo
192 192
      * loads attribute values from the cache. If they are not present in the
193 193
      * cache, it will read and parse them from attribute-definitions.xml file.
194 194
      */
195
-    private static function init_from_cache($allow_refreshing=true)
195
+    private static function init_from_cache($allow_refreshing = true)
196 196
     {
197 197
         if (self::$attr_dict !== null)
198 198
         {
199 199
             /* Already initialized. */
200 200
             return;
201 201
         }
202
-        $cache_key = "attrhelper/dict#".Okapi::$git_revision.self::cache_key_suffix();
202
+        $cache_key = "attrhelper/dict#" . Okapi::$git_revision . self::cache_key_suffix();
203 203
         $cachedvalue = Cache::get($cache_key);
204 204
         if ($cachedvalue === null)
205 205
         {
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
         if ($mapping !== null)
248 248
             return $mapping;
249 249
 
250
-        $cache_key = "attrhelper/id2acode/".Okapi::$git_revision.self::cache_key_suffix();
250
+        $cache_key = "attrhelper/id2acode/" . Okapi::$git_revision . self::cache_key_suffix();
251 251
         $mapping = Cache::get($cache_key);
252 252
         if (!$mapping)
253 253
         {
Please login to merge, or discard this patch.
Braces   +23 added lines, -18 removed lines patch added patch discarded remove patch
@@ -54,8 +54,7 @@  discard block
 block discarded – undo
54 54
             $path = $GLOBALS['rootpath']."okapi/services/attrs/attribute-definitions.xml";
55 55
             $xml = file_get_contents($path);
56 56
             self::refresh_from_string($xml);
57
-        }
58
-        catch (Exception $e)
57
+        } catch (Exception $e)
59 58
         {
60 59
             # Failed to read or parse the file (i.e. after a syntax error was
61 60
             # commited). Let's check when the last successful parse occured.
@@ -127,13 +126,15 @@  discard block
 block discarded – undo
127 126
                     /* It is used by THIS OC site. */
128 127
 
129 128
                     $internal_id = (int)$ocnode['id'];
130
-                    if (isset($all_internal_ids[$internal_id]))
131
-                        throw new Exception("The internal attribute ".$internal_id.
129
+                    if (isset($all_internal_ids[$internal_id])) {
130
+                                            throw new Exception("The internal attribute ".$internal_id.
132 131
                             " has multiple assigments to OKAPI attributes.");
132
+                    }
133 133
                     $all_internal_ids[$internal_id] = true;
134
-                    if (!is_null($attr['internal_id']))
135
-                        throw new Exception("There are multiple internal IDs for the ".
134
+                    if (!is_null($attr['internal_id'])) {
135
+                                            throw new Exception("There are multiple internal IDs for the ".
136 136
                             $attr['acode']." attribute.");
137
+                    }
137 138
                     $attr['internal_id'] = $internal_id;
138 139
                 }
139 140
             }
@@ -142,14 +143,16 @@  discard block
 block discarded – undo
142 143
                 $lang = (string)$langnode['id'];
143 144
                 foreach ($langnode->name as $namenode)
144 145
                 {
145
-                    if (isset($attr['names'][$lang]))
146
-                        throw new Exception("Duplicate ".$lang." name of attribute ".$attr['acode']);
146
+                    if (isset($attr['names'][$lang])) {
147
+                                            throw new Exception("Duplicate ".$lang." name of attribute ".$attr['acode']);
148
+                    }
147 149
                     $attr['names'][$lang] = (string)$namenode;
148 150
                 }
149 151
                 foreach ($langnode->desc as $descnode)
150 152
                 {
151
-                    if (isset($attr['descriptions'][$lang]))
152
-                        throw new Exception("Duplicate ".$lang." description of attribute ".$attr['acode']);
153
+                    if (isset($attr['descriptions'][$lang])) {
154
+                                            throw new Exception("Duplicate ".$lang." description of attribute ".$attr['acode']);
155
+                    }
153 156
                     $xml = $descnode->asxml(); /* contains "<desc>" and "</desc>" */
154 157
                     $innerxml = preg_replace("/(^[^>]+>)|(<[^<]+$)/us", "", $xml);
155 158
                     $attr['descriptions'][$lang] = self::cleanup_string($innerxml);
@@ -210,8 +213,7 @@  discard block
 block discarded – undo
210 213
                 self::refresh_now();
211 214
                 self::init_from_cache(false);
212 215
                 return;
213
-            }
214
-            else
216
+            } else
215 217
             {
216 218
                 $cachedvalue = array(
217 219
                     'attr_dict' => array(),
@@ -244,8 +246,9 @@  discard block
 block discarded – undo
244 246
     public static function get_internal_id_to_acode_mapping()
245 247
     {
246 248
         static $mapping = null;
247
-        if ($mapping !== null)
248
-            return $mapping;
249
+        if ($mapping !== null) {
250
+                    return $mapping;
251
+        }
249 252
 
250 253
         $cache_key = "attrhelper/id2acode/".Okapi::$git_revision.self::cache_key_suffix();
251 254
         $mapping = Cache::get($cache_key);
@@ -253,8 +256,9 @@  discard block
 block discarded – undo
253 256
         {
254 257
             self::init_from_cache();
255 258
             $mapping = array();
256
-            foreach (self::$attr_dict as $acode => &$attr_ref)
257
-                $mapping[$attr_ref['internal_id']] = $acode;
259
+            foreach (self::$attr_dict as $acode => &$attr_ref) {
260
+                            $mapping[$attr_ref['internal_id']] = $acode;
261
+            }
258 262
             Cache::set($cache_key, $mapping, self::ttl());
259 263
         }
260 264
         return $mapping;
@@ -267,8 +271,9 @@  discard block
 block discarded – undo
267 271
     public static function get_acode_to_name_mapping($langpref)
268 272
     {
269 273
         static $mapping = null;
270
-        if ($mapping !== null)
271
-            return $mapping;
274
+        if ($mapping !== null) {
275
+                    return $mapping;
276
+        }
272 277
 
273 278
         $cache_key = md5(serialize(array("attrhelper/acode2name", $langpref,
274 279
             Okapi::$git_revision, self::cache_key_suffix())));
Please login to merge, or discard this patch.