Процесс сдвинулся стремительно с мертвой точки и вставил в таблицу event 2873 записей одинаковых "тестирую событие" на локальном
и выдает ошибку
PHP Fatal Error – yii\base\ErrorException
Maximum execution time of 30 seconds exceeded
Код: Выделить всё
1. in /Users/svetlanailina/Sites/yii2_bz_events/vendor/yiisoft/yii2/log/Logger.php at line 148
139140141142143144145146147148149150151152153154155156157 * `Logger::LEVEL_PROFILE_BEGIN`, `Logger::LEVEL_PROFILE_END`.
* @param string $category the category of the message.
*/
public function log($message, $level, $category = 'application')
{
$time = microtime(true);
$traces = [];
if ($this->traceLevel > 0) {
$count = 0;
$ts = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
array_pop($ts); // remove the last trace since it would be the entry script, not very useful
foreach ($ts as $trace) {
if (isset($trace['file'], $trace['line']) && strpos($trace['file'], YII2_PATH) !== 0) {
unset($trace['object'], $trace['args']);
$traces[] = $trace;
if (++$count >= $this->traceLevel) {
break;
}
}
2. yii\base\ErrorHandler::handleFatalError()
$_POST = [
'_csrf' => 'PGufsxVqqLB214SdLf3-7uEWoM6Utm5kcUPz824fPaFIKdjDUi2f3wG27fR-m7LevmLrlNrfPi4_Mb2KFil85A==',
'Article' => [
'name' => 'оо',
'description' => 'оо',
],
];
$_COOKIE = [
'PHPSESSID' => 'mih734mjfnn2h3khqjepdc2101',
'_csrf' => '8946c09f1e67ae68c3ae223e81a87a3a17d9ce56304208c71d1424e9ab5bb87ca:2:{i:0;s:5:"_csrf";i:1;s:32:"tBGpGG7owaiiSfL0_tKZNiPJNrNyx6AE";}',
'advanced' => 'uva7rlvbdk3ckqnfhabav4f0in',
'_csrf-frontend' => 'f6a02f99fc6fa0922c68d462510876e80094e5ecf7931ef4406a4d89a49cc25fa:2:{i:0;s:14:"_csrf-frontend";i:1;s:32:"jkSfkPcGSh_vMGDfRI5RdLL_B7Bs9tUr";}',
];
$_SESSION = [
'__flash' => [],
];
Yii Framework
2019-08-13, 18:51:06
Apache/2.4.37 (Unix) PHP/7.1.24
https://github.com/svil1502/yii2_bz_events
На удаленном хостинге выдает 502 ошибку
web.php
Код: Выделить всё
<?php
$params = require __DIR__ . '/params.php';
$db = require __DIR__ . '/db.php';
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => [
'log',
ShopNotificator::class,
],
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
],
'components' => [
'ShopNotificator' => [
'class' => 'app\components\ShopNotificator'],
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'tATR8OV7ELA9FeQYX3fCDoKk_tmG6Egn',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
//'useFileTransport' => true,
'useFileTransport' => false,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => $db,
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
],
'params' => $params,
];
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
// uncomment the following to add your IP if you are not connecting from localhost.
//'allowedIPs' => ['127.0.0.1', '::1'],
];
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
// uncomment the following to add your IP if you are not connecting from localhost.
//'allowedIPs' => ['127.0.0.1', '::1'],
];
}
return $config;
components/
Код: Выделить всё
<?php
namespace app\components;
use yii\base\Application;
use yii\base\BootstrapInterface;
use yii\base\Event;
use yii\db\ActiveRecord;
class ShopNotificator implements BootstrapInterface
{
/**
* Bootstrap method to be called during application bootstrap stage.
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
// Event::on(
// ActiveRecord::className(),
// ActiveRecord::EVENT_AFTER_INSERT, function ($event) {
// [$this, 'opinionCreated'];
// });
Event::on(
ActiveRecord::className(),
ActiveRecord::EVENT_AFTER_INSERT,
[$this, 'opinionCreated']
);
// Event::on(ActiveRecord::className(), ActiveRecord::EVENT_AFTER_INSERT, function ($event) {
// Yii::debug(get_class($event->sender) . ' добавлен');
// $ev = new \app\models\Event();
// $ev->title = "текстовочка";
// //$event->sender;
// $ev->save();
// });
}
public function opinionCreated(Event $event)
{
$ev = new \app\models\Event();
$ev->title = "тестирую событие";
//$event->sender;
$ev->save();
}
}