Двойная проверка перед созданием страниц на вики
This commit is contained in:
parent
90cfb5ca72
commit
2e68a2e624
|
@ -39,7 +39,7 @@ class Wikipage {
|
||||||
public function __construct($game) {
|
public function __construct($game) {
|
||||||
$this->game = $game;
|
$this->game = $game;
|
||||||
|
|
||||||
if (!env('APP_DEBUG')) {
|
if (!env('APP_DEBUG') && !empty(env('WIKI'))) {
|
||||||
try {
|
try {
|
||||||
// Log in to a wiki
|
// Log in to a wiki
|
||||||
$api = new MediawikiApi( env('WIKI') );
|
$api = new MediawikiApi( env('WIKI') );
|
||||||
|
@ -65,6 +65,10 @@ class Wikipage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
|
if (env('APP_DEBUG') || empty(env('WIKI'))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($this->game->image_url)) {
|
if (!empty($this->game->image_url)) {
|
||||||
$filename = preg_replace('/\?.*/', '', basename($this->game->image_url));
|
$filename = preg_replace('/\?.*/', '', basename($this->game->image_url));
|
||||||
$extension = pathinfo($filename, PATHINFO_EXTENSION);
|
$extension = pathinfo($filename, PATHINFO_EXTENSION);
|
||||||
|
@ -201,7 +205,7 @@ class Wikipage {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function exists($pagename) {
|
protected function exists($pagename) {
|
||||||
if (env('APP_DEBUG')) {
|
if (env('APP_DEBUG') || empty(env('WIKI'))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$page = $this->services->newPageGetter()->getFromTitle((string) $pagename);
|
$page = $this->services->newPageGetter()->getFromTitle((string) $pagename);
|
||||||
|
|
Loading…
Reference in a new issue