]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #6694 from Quix0r/rewrites/added-missing-var-init
authorMichael Vogel <icarus@dabo.de>
Tue, 19 Feb 2019 06:52:36 +0000 (07:52 +0100)
committerGitHub <noreply@github.com>
Tue, 19 Feb 2019 06:52:36 +0000 (07:52 +0100)
Some rewrites

include/api.php
index.php
mod/admin.php
src/Model/ItemDeliveryData.php
src/Model/Photo.php
src/Model/Storage/Database.php
src/Model/Storage/SystemResource.php
src/Worker/Notifier.php

index 13ff75bdb50a81f1f602ea70e445ccae9b05b6c6..e6fd2f22bae9b15aa38a15808b8623a6f8e2849e 100644 (file)
@@ -1528,8 +1528,10 @@ function api_search($type)
 
        if (api_user() === false || $user_info === false) { throw new ForbiddenException(); }
 
-       if (empty($_REQUEST['q'])) { throw new BadRequestException('q parameter is required.'); }
-       
+       if (empty($_REQUEST['q'])) {
+               throw new BadRequestException('q parameter is required.');
+       }
+
        $searchTerm = trim(rawurldecode($_REQUEST['q']));
 
        $data = [];
@@ -4399,6 +4401,7 @@ function api_fr_photo_delete($type)
        if (api_user() === false) {
                throw new ForbiddenException();
        }
+
        // input params
        $photo_id = defaults($_REQUEST, 'photo_id', null);
 
@@ -4407,11 +4410,12 @@ function api_fr_photo_delete($type)
        if ($photo_id == null) {
                throw new BadRequestException("no photo_id specified");
        }
+
        // check if photo is existing in database
-       $r = Photo::exists(['resource-id' => $photo_id, 'uid' => api_user()]);
-       if (!$r) {
+       if (!Photo::exists(['resource-id' => $photo_id, 'uid' => api_user()])) {
                throw new BadRequestException("photo not available");
        }
+
        // now we can perform on the deletion of the photo
        $result = Photo::delete(['uid' => api_user(), 'resource-id' => $photo_id]);
 
index e989872893b2deb01f2966b854ff35da5b1b7797..ddc851cd4e36654e02d6f3d73cf6e68270ffeef1 100644 (file)
--- a/index.php
+++ b/index.php
@@ -15,3 +15,4 @@ require __DIR__ . '/vendor/autoload.php';
 $a = Factory\DependencyFactory::setUp('index', __DIR__, false);
 
 $a->runFrontend();
+
index fcca69644ec85d9020278502aaba664f9afeeb5f..9486f85c98242efb742b8c6ae8e13a0fa215fb67 100644 (file)
@@ -1565,7 +1565,7 @@ function admin_page_site(App $a)
        
        $storage_form = [];
        if (!is_null($storage_current_backend) && $storage_current_backend != "") {
-               foreach($storage_current_backend::getOptions() as $name => $info) {
+               foreach ($storage_current_backend::getOptions() as $name => $info) {
                        $type = $info[0];
                        $info[0] = $storage_form_prefix . '_' . $name;
                        $info['type'] = $type;
index 1cd9c4f448acb897a8817bf507dfe05f12a6fdc1..b1fd28e3cb19b181ade9c168d900b7bd41cb62f5 100644 (file)
@@ -7,6 +7,7 @@
 namespace Friendica\Model;
 
 use Friendica\Database\DBA;
+use \BadMethodCallException;
 
 class ItemDeliveryData
 {
@@ -71,7 +72,7 @@ class ItemDeliveryData
        public static function insert($item_id, array $fields)
        {
                if (empty($item_id)) {
-                       throw new \BadMethodCallException('Empty item_id');
+                       throw new BadMethodCallException('Empty item_id');
                }
 
                $fields['iid'] = $item_id;
@@ -92,7 +93,7 @@ class ItemDeliveryData
        public static function update($item_id, array $fields)
        {
                if (empty($item_id)) {
-                       throw new \BadMethodCallException('Empty item_id');
+                       throw new BadMethodCallException('Empty item_id');
                }
 
                if (empty($fields)) {
@@ -113,7 +114,7 @@ class ItemDeliveryData
        public static function delete($item_id)
        {
                if (empty($item_id)) {
-                       throw new \BadMethodCallException('Empty item_id');
+                       throw new BadMethodCallException('Empty item_id');
                }
 
                return DBA::delete('item-delivery-data', ['iid' => $item_id]);
index 0778bf41969d4ce346c41553e75f1fda79ff2c4a..152e870e8595c57da88a7f14212b9a8131cb173b 100644 (file)
@@ -173,6 +173,8 @@ class Photo extends BaseObject
         */
        public static function getImageForPhoto(array $photo)
        {
+               $data = "";
+
                if ($photo["backend-class"] == "") {
                        // legacy data storage in "data" column
                        $i = self::selectFirst(["data"], ["id" => $photo["id"]]);
@@ -189,6 +191,7 @@ class Photo extends BaseObject
                if ($data === "") {
                        return null;
                }
+
                return new Image($data, $photo["type"]);
        }
 
@@ -219,11 +222,13 @@ class Photo extends BaseObject
        {
                $fields = self::getFields();
                $values = array_fill(0, count($fields), "");
+
                $photo = array_combine($fields, $values);
                $photo["backend-class"] = Storage\SystemResource::class;
                $photo["backend-ref"] = $filename;
                $photo["type"] = $mimetype;
                $photo["cacheable"] = false;
+
                return $photo;
        }
 
index f9ad7fb7d41697c50b1b33204e0839594b0217e0..60bd154e6a863188040134bda3405699244d26e3 100644 (file)
@@ -50,8 +50,14 @@ class Database implements IStorage
        {
                return DBA::delete('storage', ['id' => $ref]);
        }
-       
-       public static function getOptions() { return []; }
-       
-       public static function saveOptions($data) { return []; }
+
+       public static function getOptions()
+       {
+               return [];
+       }
+
+       public static function saveOptions($data)
+       {
+               return [];
+       }
 }
index 718a2e90affc8ffc756d38e2a5a862dc2ed65810..3afe8ee6f5e7f88bc5cf6b2cdbffbfc6179e9513 100644 (file)
@@ -6,6 +6,8 @@
 
 namespace Friendica\Model\Storage;
 
+use \BadMethodCallException;
+
 /**
  * @brief System resource storage class
  *
@@ -32,12 +34,12 @@ class SystemResource implements IStorage
 
        public static function put($data, $filename = "")
        {
-               throw new \BadMethodCallException();
+               throw new BadMethodCallException();
        }
 
        public static function delete($filename)
        {
-               throw new \BadMethodCallException();
+               throw new BadMethodCallException();
        }
 
        public static function getOptions()
index 4492e3ce92fb65c7aa970e0808f711bab37aaee4..57c25a68faa399053485a364af38db6c8acff554 100644 (file)
@@ -498,7 +498,6 @@ class Notifier
                }
                DBA::close($delivery_contacts_stmt);
 
-
                $url_recipients = array_filter($url_recipients);
                // send salmon slaps to mentioned remote tags (@foo@example.com) in OStatus posts
                // They are especially used for notifications to OStatus users that don't follow us.