Обновляем зависимости, чиним ошибки продакшена
This commit is contained in:
parent
e1813ad856
commit
fb30646691
|
@ -18,22 +18,17 @@
|
||||||
*/
|
*/
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Addwiki\Mediawiki\Api\Client\Action\MediawikiApi;
|
use Wikimate;
|
||||||
use Addwiki\Mediawiki\Api\Client\Auth\UserAndPassword;
|
|
||||||
use Addwiki\Mediawiki\Api\MediawikiFactory;
|
|
||||||
use Addwiki\Mediawiki\DataModel\Content;
|
|
||||||
use Addwiki\Mediawiki\DataModel\Title;
|
|
||||||
use Addwiki\Mediawiki\DataModel\PageIdentifier;
|
|
||||||
use Addwiki\Mediawiki\DataModel\Revision;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use App\Models\Language;
|
use App\Models\Language;
|
||||||
|
|
||||||
class Wikipage {
|
class Wikipage {
|
||||||
protected $game;
|
protected $game;
|
||||||
|
/**
|
||||||
|
* @var Wikimate
|
||||||
|
**/
|
||||||
protected $api;
|
protected $api;
|
||||||
protected $services;
|
|
||||||
protected $content;
|
protected $content;
|
||||||
protected $fileUploader;
|
|
||||||
protected $covername;
|
protected $covername;
|
||||||
|
|
||||||
public function __construct($game) {
|
public function __construct($game) {
|
||||||
|
@ -42,12 +37,9 @@ class Wikipage {
|
||||||
if (!env('APP_DEBUG') && !empty(env('WIKI'))) {
|
if (!env('APP_DEBUG') && !empty(env('WIKI'))) {
|
||||||
try {
|
try {
|
||||||
// Log in to a wiki
|
// Log in to a wiki
|
||||||
$auth = new UserAndPassword( env('WIKIUSER'), env('WIKIPASSWORD') );
|
$wiki = new Wikimate(env('WIKI'));
|
||||||
$api = MediawikiApi::newFromPage( env('WIKI'), $auth );
|
$wiki->login(env('WIKIUSER'), env('WIKIPASSWORD'));
|
||||||
$services = new MediawikiFactory( $api );
|
$this->api = $wiki;
|
||||||
$this->api = $api;
|
|
||||||
$this->services = $services;
|
|
||||||
$this->fileUploader = $services->newFileUploader();
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
echo 'Ошибка соединения.'.PHP_EOL;
|
echo 'Ошибка соединения.'.PHP_EOL;
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
|
@ -88,16 +80,11 @@ class Wikipage {
|
||||||
$exists = $this->exists($pagetitle);
|
$exists = $this->exists($pagetitle);
|
||||||
if (!env('APP_DEBUG') && !$exists) {
|
if (!env('APP_DEBUG') && !$exists) {
|
||||||
if (!empty($this->game->image_url) && isset($filename)) {
|
if (!empty($this->game->image_url) && isset($filename)) {
|
||||||
if ($this->services->newPageGetter()->getFromTitle($this->covername)) {
|
if (!$this->api->getFile($this->covername)->exists()) {
|
||||||
try {
|
try {
|
||||||
$image = file_get_contents($this->game->image_url);
|
$image = file_get_contents($this->game->image_url);
|
||||||
file_put_contents($filename, $image);
|
file_put_contents($filename, $image);
|
||||||
$extension = mime_content_type($filename);
|
$this->api->uploadFile($filename, $this->covername);
|
||||||
if (strpos($extension, 'image') !== FALSE) {
|
|
||||||
$extension = str_replace('image/', '', $extension);
|
|
||||||
$this->covername = Str::slug($this->game->title, '_').'.'.$extension;
|
|
||||||
$this->fileUploader->upload($this->covername, $filename);
|
|
||||||
}
|
|
||||||
unlink($filename);
|
unlink($filename);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
echo '(Обложка не найдена)'.PHP_EOL;
|
echo '(Обложка не найдена)'.PHP_EOL;
|
||||||
|
@ -109,11 +96,8 @@ class Wikipage {
|
||||||
$this->makeContent();
|
$this->makeContent();
|
||||||
|
|
||||||
if (!env('APP_DEBUG') && !$exists) {
|
if (!env('APP_DEBUG') && !$exists) {
|
||||||
$newContent = new Content( $this->content );
|
$page = $this->api->getPage($pagetitle);
|
||||||
$title = new Title($pagetitle);
|
$page->setText($this->content);
|
||||||
$identifier = new PageIdentifier($title);
|
|
||||||
$revision = new Revision($newContent, $identifier);
|
|
||||||
$this->services->newRevisionSaver()->save($revision);
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if ($exists) {
|
if ($exists) {
|
||||||
|
@ -210,7 +194,7 @@ class Wikipage {
|
||||||
if (env('APP_DEBUG') || empty(env('WIKI'))) {
|
if (env('APP_DEBUG') || empty(env('WIKI'))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$page = $this->services->newPageGetter()->getFromTitle((string) $pagename);
|
$page = $this->api->getPage((string) $pagename);
|
||||||
return !($page->getId() === 0);
|
return $page->exists();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1",
|
"php": "^8.1",
|
||||||
"addwiki/mediawiki-api": "^3.0",
|
"doctrine/dbal": "^3.0",
|
||||||
"addwiki/mediawiki-api-base": "^3.0.0",
|
|
||||||
"doctrine/dbal": "^2.10",
|
|
||||||
"guzzlehttp/guzzle": "^7.0.1",
|
"guzzlehttp/guzzle": "^7.0.1",
|
||||||
"laravel/framework": "^9.0",
|
"hamstar/wikimate": "^1.1",
|
||||||
|
"laravel/framework": "^10.0",
|
||||||
"laravel/tinker": "^2.5",
|
"laravel/tinker": "^2.5",
|
||||||
"longman/telegram-bot": "dev-master",
|
"longman/telegram-bot": "0.82.0",
|
||||||
"revolution/laravel-mastodon-api": "dev-master",
|
"revolution/laravel-mastodon-api": "3.0.3",
|
||||||
"ryakad/pandoc-php": "^1.0",
|
"ryakad/pandoc-php": "^1.0",
|
||||||
"sabre/xml": "^2.0",
|
"sabre/xml": "^2.0",
|
||||||
"symfony/css-selector": "^5.0",
|
"symfony/css-selector": "^5.0",
|
||||||
|
@ -35,9 +34,9 @@
|
||||||
"fakerphp/faker": "^1.9.1",
|
"fakerphp/faker": "^1.9.1",
|
||||||
"laravel/sail": "^1.0.1",
|
"laravel/sail": "^1.0.1",
|
||||||
"mockery/mockery": "^1.4.2",
|
"mockery/mockery": "^1.4.2",
|
||||||
"nunomaduro/collision": "^6.0",
|
"nunomaduro/collision": "^7.0",
|
||||||
"nunomaduro/larastan": "^2.0",
|
"nunomaduro/larastan": "^2.0",
|
||||||
"phpunit/phpunit": "^9.3.3"
|
"phpunit/phpunit": "^10.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
@ -73,6 +72,6 @@
|
||||||
"preferred-install": "dist",
|
"preferred-install": "dist",
|
||||||
"sort-packages": true
|
"sort-packages": true
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "stable",
|
||||||
"prefer-stable": true
|
"prefer-stable": true
|
||||||
}
|
}
|
||||||
|
|
1347
composer.lock
generated
1347
composer.lock
generated
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue