Browse Source

Rewrites:

- converted single-line if() block to multi-line and with curly braces
- "imported" SPL classes to have unified code style
- always initialize your variables ... :-/
- added some empty lines/spaces for better readability

Signed-off-by: Roland Häder <roland@mxchange.org>
tags/2019.03^2
Roland Häder 5 months ago
parent
commit
9fa812b35d
No account linked to committer's email address

+ 8
- 4
include/api.php View File

@@ -1528,8 +1528,10 @@ function api_search($type)
1528 1528
 
1529 1529
 	if (api_user() === false || $user_info === false) { throw new ForbiddenException(); }
1530 1530
 
1531
-	if (empty($_REQUEST['q'])) { throw new BadRequestException('q parameter is required.'); }
1532
-	
1531
+	if (empty($_REQUEST['q'])) {
1532
+		throw new BadRequestException('q parameter is required.');
1533
+	}
1534
+
1533 1535
 	$searchTerm = trim(rawurldecode($_REQUEST['q']));
1534 1536
 
1535 1537
 	$data = [];
@@ -4399,6 +4401,7 @@ function api_fr_photo_delete($type)
4399 4401
 	if (api_user() === false) {
4400 4402
 		throw new ForbiddenException();
4401 4403
 	}
4404
+
4402 4405
 	// input params
4403 4406
 	$photo_id = defaults($_REQUEST, 'photo_id', null);
4404 4407
 
@@ -4407,11 +4410,12 @@ function api_fr_photo_delete($type)
4407 4410
 	if ($photo_id == null) {
4408 4411
 		throw new BadRequestException("no photo_id specified");
4409 4412
 	}
4413
+
4410 4414
 	// check if photo is existing in database
4411
-	$r = Photo::exists(['resource-id' => $photo_id, 'uid' => api_user()]);
4412
-	if (!$r) {
4415
+	if (!Photo::exists(['resource-id' => $photo_id, 'uid' => api_user()])) {
4413 4416
 		throw new BadRequestException("photo not available");
4414 4417
 	}
4418
+
4415 4419
 	// now we can perform on the deletion of the photo
4416 4420
 	$result = Photo::delete(['uid' => api_user(), 'resource-id' => $photo_id]);
4417 4421
 

+ 1
- 0
index.php View File

@@ -15,3 +15,4 @@ require __DIR__ . '/vendor/autoload.php';
15 15
 $a = Factory\DependencyFactory::setUp('index', __DIR__, false);
16 16
 
17 17
 $a->runFrontend();
18
+

+ 1
- 1
mod/admin.php View File

@@ -1565,7 +1565,7 @@ function admin_page_site(App $a)
1565 1565
 	
1566 1566
 	$storage_form = [];
1567 1567
 	if (!is_null($storage_current_backend) && $storage_current_backend != "") {
1568
-		foreach($storage_current_backend::getOptions() as $name => $info) {
1568
+		foreach ($storage_current_backend::getOptions() as $name => $info) {
1569 1569
 			$type = $info[0];
1570 1570
 			$info[0] = $storage_form_prefix . '_' . $name;
1571 1571
 			$info['type'] = $type;

+ 4
- 3
src/Model/ItemDeliveryData.php View File

@@ -7,6 +7,7 @@
7 7
 namespace Friendica\Model;
8 8
 
9 9
 use Friendica\Database\DBA;
10
+use \BadMethodCallException;
10 11
 
11 12
 class ItemDeliveryData
12 13
 {
@@ -71,7 +72,7 @@ class ItemDeliveryData
71 72
 	public static function insert($item_id, array $fields)
72 73
 	{
73 74
 		if (empty($item_id)) {
74
-			throw new \BadMethodCallException('Empty item_id');
75
+			throw new BadMethodCallException('Empty item_id');
75 76
 		}
76 77
 
77 78
 		$fields['iid'] = $item_id;
@@ -92,7 +93,7 @@ class ItemDeliveryData
92 93
 	public static function update($item_id, array $fields)
93 94
 	{
94 95
 		if (empty($item_id)) {
95
-			throw new \BadMethodCallException('Empty item_id');
96
+			throw new BadMethodCallException('Empty item_id');
96 97
 		}
97 98
 
98 99
 		if (empty($fields)) {
@@ -113,7 +114,7 @@ class ItemDeliveryData
113 114
 	public static function delete($item_id)
114 115
 	{
115 116
 		if (empty($item_id)) {
116
-			throw new \BadMethodCallException('Empty item_id');
117
+			throw new BadMethodCallException('Empty item_id');
117 118
 		}
118 119
 
119 120
 		return DBA::delete('item-delivery-data', ['iid' => $item_id]);

+ 5
- 0
src/Model/Photo.php View File

@@ -173,6 +173,8 @@ class Photo extends BaseObject
173 173
 	 */
174 174
 	public static function getImageForPhoto(array $photo)
175 175
 	{
176
+		$data = "";
177
+
176 178
 		if ($photo["backend-class"] == "") {
177 179
 			// legacy data storage in "data" column
178 180
 			$i = self::selectFirst(["data"], ["id" => $photo["id"]]);
@@ -189,6 +191,7 @@ class Photo extends BaseObject
189 191
 		if ($data === "") {
190 192
 			return null;
191 193
 		}
194
+
192 195
 		return new Image($data, $photo["type"]);
193 196
 	}
194 197
 
@@ -219,11 +222,13 @@ class Photo extends BaseObject
219 222
 	{
220 223
 		$fields = self::getFields();
221 224
 		$values = array_fill(0, count($fields), "");
225
+
222 226
 		$photo = array_combine($fields, $values);
223 227
 		$photo["backend-class"] = Storage\SystemResource::class;
224 228
 		$photo["backend-ref"] = $filename;
225 229
 		$photo["type"] = $mimetype;
226 230
 		$photo["cacheable"] = false;
231
+
227 232
 		return $photo;
228 233
 	}
229 234
 

+ 10
- 4
src/Model/Storage/Database.php View File

@@ -50,8 +50,14 @@ class Database implements IStorage
50 50
 	{
51 51
 		return DBA::delete('storage', ['id' => $ref]);
52 52
 	}
53
-	
54
-	public static function getOptions() { return []; }
55
-	
56
-	public static function saveOptions($data) { return []; }
53
+
54
+	public static function getOptions()
55
+	{
56
+		return [];
57
+	}
58
+
59
+	public static function saveOptions($data)
60
+	{
61
+		return [];
62
+	}
57 63
 }

+ 4
- 2
src/Model/Storage/SystemResource.php View File

@@ -6,6 +6,8 @@
6 6
 
7 7
 namespace Friendica\Model\Storage;
8 8
 
9
+use \BadMethodCallException;
10
+
9 11
 /**
10 12
  * @brief System resource storage class
11 13
  *
@@ -32,12 +34,12 @@ class SystemResource implements IStorage
32 34
 
33 35
 	public static function put($data, $filename = "")
34 36
 	{
35
-		throw new \BadMethodCallException();
37
+		throw new BadMethodCallException();
36 38
 	}
37 39
 
38 40
 	public static function delete($filename)
39 41
 	{
40
-		throw new \BadMethodCallException();
42
+		throw new BadMethodCallException();
41 43
 	}
42 44
 
43 45
 	public static function getOptions()

+ 0
- 1
src/Worker/Notifier.php View File

@@ -498,7 +498,6 @@ class Notifier
498 498
 		}
499 499
 		DBA::close($delivery_contacts_stmt);
500 500
 
501
-
502 501
 		$url_recipients = array_filter($url_recipients);
503 502
 		// send salmon slaps to mentioned remote tags (@foo@example.com) in OStatus posts
504 503
 		// They are especially used for notifications to OStatus users that don't follow us.

Loading…
Cancel
Save