Skip to content

Commit

Permalink
Update composer name to nethergamesmc/libasynql
Browse files Browse the repository at this point in the history
  • Loading branch information
dries-c committed Mar 27, 2024
1 parent 7893751 commit 1abb8f1
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "sof3/libasynql",
"name": "nethergamesmc/libasynql",
"type": "library",
"require": {
"sof3/await-generator": "^2.0.0 || ^3.0.0"
},
"require-dev": {
"pocketmine/pocketmine-mp": "^5.0.0-BETA4"
"nethergamesmc/pocketmine-mp": "dev-stable"
},
"license": "Apache-2.0",
"autoload": {
Expand All @@ -19,6 +19,9 @@
"email": "[email protected]"
}
],
"repositories": [
{ "type": "vcs", "url": "[email protected]:NetherGamesMC/PocketMine-MP.git" }
],
"bin": [
"libasynql/cli/def.php",
"libasynql/cli/fx.php"
Expand Down
20 changes: 20 additions & 0 deletions libasynql/src/poggit/libasynql/CoreConstants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace poggit\libasynql;

use function define;
use function defined;
use function dirname;
use function var_dump;

// composer autoload doesn't use require_once and also pthreads can inherit things
if (defined('libasynql\_CORE_CONSTANTS_INCLUDED')) {
return;
}
define('libasynql\_CORE_CONSTANTS_INCLUDED', true);

define('libasynql\COMPOSER_AUTOLOADER_PATH', dirname(__FILE__, 6) . '/autoload.php');

var_dump(dirname(__FILE__, 6));
16 changes: 13 additions & 3 deletions libasynql/src/poggit/libasynql/base/SqlSlaveThread.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
use poggit\libasynql\SqlError;
use poggit\libasynql\SqlResult;
use poggit\libasynql\SqlThread;
use const libasynql\COMPOSER_AUTOLOADER_PATH;

abstract class SqlSlaveThread extends Thread implements SqlThread{
private SleeperHandlerEntry $sleeperEntry;

private static $nextSlaveNumber = 0;
private $autoloaderPath = null;

protected $slaveNumber;
protected $bufferSend;
Expand All @@ -53,14 +55,22 @@ protected function __construct(SleeperHandlerEntry $entry, QuerySendQueue $buffe

if(!libasynql::isPackaged()){
/** @noinspection NullPointerExceptionInspection */
/** @var ClassLoader $cl */
$cl = Server::getInstance()->getPluginManager()->getPlugin("DEVirion")->getVirionClassLoader();
$this->setClassLoaders([Server::getInstance()->getLoader(), $cl]);
/** @var ?ClassLoader $cl */
$cl = Server::getInstance()->getPluginManager()->getPlugin("DEVirion")?->getVirionClassLoader();
if($cl === null){
$this->autoloaderPath = COMPOSER_AUTOLOADER_PATH;
}else{
$this->setClassLoaders([Server::getInstance()->getLoader(), $cl]);
}
}
$this->start(NativeThread::INHERIT_INI);
}

protected function onRun() : void{
if ($this->autoloaderPath !== null) {
require $this->autoloaderPath;
}

$error = $this->createConn($resource);
$this->connCreated = true;
$this->connError = $error;
Expand Down
4 changes: 3 additions & 1 deletion libasynql/src/poggit/libasynql/libasynql.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
use function strtolower;
use function usleep;

require_once 'CoreConstants.php';

/**
* An utility class providing convenient access to the API
*/
Expand Down Expand Up @@ -144,7 +146,7 @@ public static function create(PluginBase $plugin, $configData, array $sqlMap, bo
throw new SqlError(SqlError::STAGE_CONNECT, $pool->getConnError());
}

$connector = new DataConnectorImpl($plugin, $pool, $placeHolder, $logQueries ?? !libasynql::isPackaged());
$connector = new DataConnectorImpl($plugin, $pool, $placeHolder, $logQueries ?? false);
foreach(is_string($sqlMap[$dialect]) ? [$sqlMap[$dialect]] : $sqlMap[$dialect] as $file){
$resource = $plugin->getResource($file);
if($resource===null){
Expand Down

0 comments on commit 1abb8f1

Please sign in to comment.