]> git.mxchange.org Git - friendica.git/commitdiff
Replaced "requestdata"
authorMichael <heluecht@pirati.ca>
Wed, 24 Nov 2021 21:01:07 +0000 (21:01 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 24 Nov 2021 21:01:07 +0000 (21:01 +0000)
include/api.php
tests/legacy/ApiTest.php

index f85bcf0c89a41b7a388ef7747850b05c4ab1dfed..68544754578b97e307036adf0b28315313f70314 100644 (file)
@@ -683,23 +683,6 @@ function group_create($name, $uid, $users = [])
        return ['success' => true, 'gid' => $gid, 'name' => $name, 'status' => $status, 'wrong users' => $errorusers];
 }
 
        return ['success' => true, 'gid' => $gid, 'name' => $name, 'status' => $status, 'wrong users' => $errorusers];
 }
 
-/**
- * Get data from $_POST or $_GET
- *
- * @param string $k
- * @return null
- */
-function requestdata($k)
-{
-       if (!empty($_POST[$k])) {
-               return $_POST[$k];
-       }
-       if (!empty($_GET[$k])) {
-               return $_GET[$k];
-       }
-       return null;
-}
-
 /**
  * TWITTER API
  */
 /**
  * TWITTER API
  */
@@ -765,7 +748,7 @@ function api_statuses_mediap($type)
 
        $_REQUEST['profile_uid'] = $uid;
        $_REQUEST['api_source'] = true;
 
        $_REQUEST['profile_uid'] = $uid;
        $_REQUEST['api_source'] = true;
-       $txt = requestdata('status') ?? '';
+       $txt = $_REQUEST['status'] ?? '';
 
        if ((strpos($txt, '<') !== false) || (strpos($txt, '>') !== false)) {
                $txt = HTML::toBBCodeVideo($txt);
 
        if ((strpos($txt, '<') !== false) || (strpos($txt, '>') !== false)) {
                $txt = HTML::toBBCodeVideo($txt);
@@ -814,8 +797,8 @@ function api_statuses_update($type)
        $a = DI::app();
 
        // convert $_POST array items to the form we use for web posts.
        $a = DI::app();
 
        // convert $_POST array items to the form we use for web posts.
-       if (requestdata('htmlstatus')) {
-               $txt = requestdata('htmlstatus') ?? '';
+       if (!empty($_REQUEST['htmlstatus'])) {
+               $txt = $_REQUEST['htmlstatus'];
                if ((strpos($txt, '<') !== false) || (strpos($txt, '>') !== false)) {
                        $txt = HTML::toBBCodeVideo($txt);
 
                if ((strpos($txt, '<') !== false) || (strpos($txt, '>') !== false)) {
                        $txt = HTML::toBBCodeVideo($txt);
 
@@ -828,12 +811,12 @@ function api_statuses_update($type)
                        $_REQUEST['body'] = HTML::toBBCode($txt);
                }
        } else {
                        $_REQUEST['body'] = HTML::toBBCode($txt);
                }
        } else {
-               $_REQUEST['body'] = requestdata('status');
+               $_REQUEST['body'] = $_REQUEST['status'] ?? null;
        }
 
        }
 
-       $_REQUEST['title'] = requestdata('title');
+       $_REQUEST['title'] = $_REQUEST['title'] ?? null;
 
 
-       $parent = requestdata('in_reply_to_status_id');
+       $parent = $_REQUEST['in_reply_to_status_id'] ?? null;
 
        // Twidere sends "-1" if it is no reply ...
        if ($parent == -1) {
 
        // Twidere sends "-1" if it is no reply ...
        if ($parent == -1) {
@@ -846,8 +829,8 @@ function api_statuses_update($type)
                $_REQUEST['parent_uri'] = $parent;
        }
 
                $_REQUEST['parent_uri'] = $parent;
        }
 
-       if (requestdata('lat') && requestdata('long')) {
-               $_REQUEST['coord'] = sprintf("%s %s", requestdata('lat'), requestdata('long'));
+       if (!empty($_REQUEST['lat']) && !empty($_REQUEST['long'])) {
+               $_REQUEST['coord'] = sprintf("%s %s", $_REQUEST['lat'], $_REQUEST['long']);
        }
        $_REQUEST['profile_uid'] = $uid;
 
        }
        $_REQUEST['profile_uid'] = $uid;
 
@@ -896,8 +879,8 @@ function api_statuses_update($type)
                }
        }
 
                }
        }
 
-       if (requestdata('media_ids')) {
-               $ids = explode(',', requestdata('media_ids') ?? '');
+       if (!empty($_REQUEST['media_ids'])) {
+               $ids = explode(',', $_REQUEST['media_ids']);
        } elseif (!empty($_FILES['media'])) {
                // upload the image if we have one
                $picture = wall_upload_post($a, false);
        } elseif (!empty($_FILES['media'])) {
                // upload the image if we have one
                $picture = wall_upload_post($a, false);
index c8f0ae914245a6bc07b2da70a1489d2147df9364..03b32d1f3c5c69c4e733e7c7f09a6c9809d9d7b4 100644 (file)
@@ -902,38 +902,6 @@ class ApiTest extends FixtureTest
                api_account_verify_credentials('json');
        }
 
                api_account_verify_credentials('json');
        }
 
-       /**
-        * Test the requestdata() function.
-        *
-        * @return void
-        */
-       public function testRequestdata()
-       {
-               self::assertNull(requestdata('variable_name'));
-       }
-
-       /**
-        * Test the requestdata() function with a POST parameter.
-        *
-        * @return void
-        */
-       public function testRequestdataWithPost()
-       {
-               $_POST['variable_name'] = 'variable_value';
-               self::assertEquals('variable_value', requestdata('variable_name'));
-       }
-
-       /**
-        * Test the requestdata() function with a GET parameter.
-        *
-        * @return void
-        */
-       public function testRequestdataWithGet()
-       {
-               $_GET['variable_name'] = 'variable_value';
-               self::assertEquals('variable_value', requestdata('variable_name'));
-       }
-
        /**
         * Test the api_statuses_mediap() function.
         *
        /**
         * Test the api_statuses_mediap() function.
         *