]> git.mxchange.org Git - friendica.git/commitdiff
Replace global $a with BaseObject::getApp()
authorHypolite Petovan <mrpetovan@gmail.com>
Tue, 10 Jul 2018 02:39:59 +0000 (22:39 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Mon, 16 Jul 2018 23:38:17 +0000 (19:38 -0400)
17 files changed:
include/text.php
mod/admin.php
src/Worker/CheckVersion.php
src/Worker/Cron.php
src/Worker/CronJobs.php
src/Worker/DBUpdate.php
src/Worker/DiscoverPoCo.php
src/Worker/Expire.php
src/Worker/ForkHook.php
src/Worker/Notifier.php
src/Worker/OnePoll.php
src/Worker/PubSubPublish.php
src/Worker/Queue.php
src/Worker/UpdateGContact.php
tests/ApiTest.php
tests/src/Core/Cache/CacheTest.php
tests/src/Core/Lock/LockTest.php

index 679873b532997b71a7978710a925cba69e3ff59e..6aa0c9d2dd43208e33464c913d79253b5a04cf4c 100644 (file)
@@ -519,7 +519,6 @@ $LOGGER_LEVELS = [];
  * LOGGER_DATA
  * LOGGER_ALL
  *
- * @global App $a
  * @global array $LOGGER_LEVELS
  * @param string $msg
  * @param int $level
@@ -590,12 +589,10 @@ function logger($msg, $level = 0) {
  * LOGGER_DATA
  * LOGGER_ALL
  *
- * @global App $a
  * @global array $LOGGER_LEVELS
  * @param string $msg
  * @param int $level
  */
-
 function dlogger($msg, $level = 0) {
        $a = get_app();
 
index c90eb3c5eb46779c601aa9249d8eb79a033b721b..da50007131535e5ddcda2c885accb10cdfc5de62 100644 (file)
@@ -944,8 +944,6 @@ function admin_page_site_post(App $a)
 
                function update_table($table_name, $fields, $old_url, $new_url)
                {
-                       global $a;
-
                        $dbold = dbesc($old_url);
                        $dbnew = dbesc($new_url);
 
index a6056ccbc477b08c7a176a737a190eb53daa0c98..e37e37a060341e9583d618424a61bc98a5ca92e6 100644 (file)
@@ -16,10 +16,10 @@ use Friendica\Util\Network;
  * Checking the upstream version is optional (opt-in) and can be done to either
  * the master or the develop branch in the repository.
  */
-class CheckVersion {
-       public static function execute() {
-               global $a;
-
+class CheckVersion
+{
+       public static function execute()
+       {
                logger('checkversion: start');
 
                $checkurl = Config::get('system', 'check_new_version_url', 'none');
index e425c03508330c88a78bfb5cde83bd360e6f4553..a0dfda3309987ceafb0d2e0a7fa549c696d14888 100644 (file)
@@ -13,9 +13,11 @@ use dba;
 
 require_once 'include/dba.php';
 
-Class Cron {
-       public static function execute($parameter = '', $generation = 0) {
-               global $a;
+class Cron
+{
+       public static function execute($parameter = '', $generation = 0)
+       {
+               $a = \Friendica\BaseObject::getApp();
 
                // Poll contacts with specific parameters
                if (!empty($parameter)) {
index 80839874da82074bba215acfae335a1953289bad..8b9d3b9bcf27879f4766952506a02db995b4297c 100644 (file)
@@ -24,7 +24,7 @@ class CronJobs
 {
        public static function execute($command = '')
        {
-               global $a;
+               $a = \Friendica\BaseObject::getApp();
 
                // No parameter set? So return
                if ($command == '') {
index 5f85c8ebefbd2ffb00a39cf477a3f0f2b742991c..ed8e409e987ab0a6c942328b9448051e81f58747 100644 (file)
@@ -7,9 +7,11 @@ namespace Friendica\Worker;
 
 use Friendica\Core\Config;
 
-class DBUpdate {
-       public static function execute() {
-               $a = get_app();
+class DBUpdate
+{
+       public static function execute()
+       {
+               $a = \Friendica\BaseObject::getApp();
 
                // We are deleting the latest dbupdate entry.
                // This is done to avoid endless loops because the update was interupted.
index f0335bc8e443334aa0ac5866775219d812825cb8..c77830d60af7a19742dca670f951999bfccc9fbe 100644 (file)
@@ -15,7 +15,8 @@ use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 use dba;
 
-class DiscoverPoCo {
+class DiscoverPoCo
+{
        /// @todo Clean up this mess of a parameter hell and split it in several classes
        public static function execute($command = '', $param1 = '', $param2 = '', $param3 = '', $param4 = '')
        {
@@ -276,8 +277,6 @@ class DiscoverPoCo {
                // It is not removed since I hope that there will be a successor.
                return false;
 
-               $a = get_app();
-
                $url = "http://gstools.org/api/users_search/".urlencode($search);
 
                $result = Network::curl($url);
index 6cc333dd053f9f9f9b6636559f79218b41869d24..685fad49e8f64fc171946f3600203b26c5489d13 100644 (file)
@@ -15,9 +15,11 @@ use dba;
 
 require_once 'include/dba.php';
 
-class Expire {
-       public static function execute($param = '', $hook_name = '') {
-               global $a;
+class Expire
+{
+       public static function execute($param = '', $hook_name = '')
+       {
+               $a = \Friendica\BaseObject::getApp();
 
                require_once 'include/items.php';
 
index 6c138bace47d3e95b24c7f5d7cd08da3ca27e6e9..3654bdd3cad173aae526a244adfa91a76330cf9c 100644 (file)
@@ -7,9 +7,11 @@ namespace Friendica\Worker;
 
 use Friendica\Core\Addon;
 
-Class ForkHook {
-       public static function execute($name, $hook, $data) {
-               global $a;
+Class ForkHook
+{
+       public static function execute($name, $hook, $data)
+       {
+               $a = \Friendica\BaseObject::getApp();
 
                Addon::callSingleHook($a, $name, $hook, $data);
        }
index 6c3717200bbfdd324197c4ef8f8b1e8f9cc87d8f..385892f9916047ae61931d48cbe1301f8afaa5c1 100644 (file)
@@ -48,9 +48,11 @@ require_once 'include/items.php';
  * and ITEM_ID is the id of the item in the database that needs to be sent to others.
  */
 
-class Notifier {
-       public static function execute($cmd, $item_id) {
-               global $a;
+class Notifier
+{
+       public static function execute($cmd, $item_id)
+       {
+               $a = \Friendica\BaseObject::getApp();
 
                logger('notifier: invoked: '.$cmd.': '.$item_id, LOGGER_DEBUG);
 
index eaef5f252d4404a01217a7618abe3f64e924a498..951a20b0124436a8bea02cb13c0422ddbd34f82a 100644 (file)
@@ -21,8 +21,9 @@ require_once 'include/dba.php';
 
 class OnePoll
 {
-       public static function execute($contact_id = 0, $command = '') {
-               global $a;
+       public static function execute($contact_id = 0, $command = '')
+       {
+               $a = \Friendica\BaseObject::getApp();
 
                require_once 'include/items.php';
 
@@ -634,7 +635,8 @@ class OnePoll
                return;
        }
 
-       private static function RemoveReply($subject) {
+       private static function RemoveReply($subject)
+       {
                while (in_array(strtolower(substr($subject, 0, 3)), ["re:", "aw:"])) {
                        $subject = trim(substr($subject, 4));
                }
@@ -648,7 +650,8 @@ class OnePoll
         * @param array $contact The personal contact entry
         * @param array $fields The fields that are updated
         */
-       private static function updateContact($contact, $fields) {
+       private static function updateContact($contact, $fields)
+       {
                dba::update('contact', $fields, ['id' => $contact['id']]);
                dba::update('contact', $fields, ['uid' => 0, 'nurl' => $contact['nurl']]);
        }
index 0a60e5a5995ffc007598f8ad68a931cb20b61c7e..b90fc11a499810e71f22596932877f040d63a824 100644 (file)
@@ -15,7 +15,8 @@ use dba;
 
 require_once 'include/items.php';
 
-class PubSubPublish {
+class PubSubPublish
+{
        public static function execute($pubsubpublish_id = 0)
        {
                if ($pubsubpublish_id == 0) {
@@ -25,8 +26,9 @@ class PubSubPublish {
                self::publish($pubsubpublish_id);
        }
 
-       private static function publish($id) {
-               global $a;
+       private static function publish($id)
+       {
+               $a = \Friendica\BaseObject::getApp();
 
                $subscriber = dba::selectFirst('push_subscriber', [], ['id' => $id]);
                if (!DBM::is_result($subscriber)) {
index c8ba5795a63a55bb2111e89ce594441fdebd10aa..1ec40905657cb16236862b8c2c53f8530ac4b752 100644 (file)
@@ -25,8 +25,6 @@ class Queue
 {
        public static function execute($queue_id = 0)
        {
-               global $a;
-
                $cachekey_deadguy = 'queue_run:deadguy:';
                $cachekey_server = 'queue_run:server:';
 
index 98a62818e9bed6575155715ee691cb2c7d4197fd..b943d966bec0be6a41dc3aac6fcb0e6800f1fcad 100644 (file)
@@ -15,8 +15,6 @@ class UpdateGContact
 {
        public static function execute($contact_id)
        {
-               global $a;
-
                logger('update_gcontact: start');
 
                if (empty($contact_id)) {
index c33ee6bfaf1d55b479f11ba0169a7e7304906bee..1854c996b0ffbd258e369775744431efca10912b 100644 (file)
@@ -5,12 +5,11 @@
 
 namespace Friendica\Test;
 
-use Friendica\App;
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
-use Friendica\Network\BadRequestException;
+use Friendica\Core\Protocol;
+use Friendica\Core\System;
 use Friendica\Network\HTTPException;
-use Friendica\Render\FriendicaSmarty;
 
 /**
  * Tests for the API functions.
@@ -26,12 +25,10 @@ class ApiTest extends DatabaseTest
         */
        protected function setUp()
        {
-               global $a;
                parent::setUp();
 
                // Reusable App object
-               $this->app = new App(__DIR__.'/../');
-               $a = $this->app;
+               $this->app = \Friendica\BaseObject::getApp();
 
                // User data that the test database is populated with
                $this->selfUser = [
@@ -2164,7 +2161,7 @@ class ApiTest extends DatabaseTest
        public function testApiFormatItemsEmbededImages()
        {
                $this->assertEquals(
-                       'text ' . \Friendica\Core\System::baseUrl() . '/display/item_guid',
+                       'text ' . System::baseUrl() . '/display/item_guid',
                        api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo')
                );
        }
@@ -2338,7 +2335,7 @@ class ApiTest extends DatabaseTest
                                'body' => '',
                                'verb' => '',
                                'author-id' => 43,
-                               'author-network' => \Friendica\Core\Protocol::DFRN,
+                               'author-network' => Protocol::DFRN,
                                'author-link' => 'http://localhost/profile/othercontact',
                                'plink' => '',
                        ]
@@ -2361,7 +2358,7 @@ class ApiTest extends DatabaseTest
                                'body' => '',
                                'verb' => '',
                                'author-id' => 43,
-                               'author-network' => \Friendica\Core\Protocol::DFRN,
+                               'author-network' => Protocol::DFRN,
                                'author-link' => 'http://localhost/profile/othercontact',
                                'plink' => '',
                        ]
@@ -2635,7 +2632,7 @@ class ApiTest extends DatabaseTest
                $result = api_statusnet_config('json');
                $this->assertEquals('localhost', $result['config']['site']['server']);
                $this->assertEquals('default', $result['config']['site']['theme']);
-               $this->assertEquals(\Friendica\Core\System::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
+               $this->assertEquals(System::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
                $this->assertTrue($result['config']['site']['fancy']);
                $this->assertEquals('en', $result['config']['site']['language']);
                $this->assertEquals('UTC', $result['config']['site']['timezone']);
index a2724c12b0bc2ff7a156c6aad940204d172c4f4c..39dc56f301444934cd407a3b7bc5e70f54177b11 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace Friendica\Test\src\Core\Cache;
 
-use Friendica\App;
 use Friendica\Core\Config;
 use Friendica\Test\DatabaseTest;
 use Friendica\Util\DateTimeFormat;
@@ -18,13 +17,11 @@ abstract class CacheTest extends DatabaseTest
 
        protected function setUp()
        {
-               global $a;
                parent::setUp();
                $this->instance = $this->getInstance();
 
                // Reusable App object
                $this->app = \Friendica\BaseObject::getApp();
-               $a = $this->app;
 
                // Default config
                Config::set('config', 'hostname', 'localhost');
index 5e4bebd45cdfc8d04fede2b3ccf3b18057db1a02..79ee023bd8b98b88e5208828c6d7d7d53f2bd0f5 100644 (file)
@@ -2,10 +2,8 @@
 
 namespace Friendica\Test\src\Core\Lock;
 
-use Friendica\App;
 use Friendica\Core\Config;
 use Friendica\Test\DatabaseTest;
-use PHPUnit\Framework\TestCase;
 
 abstract class LockTest extends DatabaseTest
 {
@@ -18,13 +16,11 @@ abstract class LockTest extends DatabaseTest
 
        protected function setUp()
        {
-               global $a;
                parent::setUp();
                $this->instance = $this->getInstance();
 
                // Reusable App object
                $this->app = \Friendica\BaseObject::getApp();
-               $a = $this->app;
 
                // Default config
                Config::set('config', 'hostname', 'localhost');