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