Replace global $a with BaseObject::getApp()

This commit is contained in:
Hypolite Petovan 2018-07-09 22:39:59 -04:00
parent d0780ccf7d
commit 820afa2284
17 changed files with 51 additions and 56 deletions

View 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();

View 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);

View 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');

View 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)) {

View 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 == '') {

View 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.

View 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);

View 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';

View 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);
}

View 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);

View 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']]);
}

View 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)) {

View 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:';

View File

@ -15,8 +15,6 @@ class UpdateGContact
{
public static function execute($contact_id)
{
global $a;
logger('update_gcontact: start');
if (empty($contact_id)) {

View 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']);

View 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');

View 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');