My job sometimes throws an exception:
Undefined index: job
#1 D:\home\site\repository\vendor\laravel\framework\src\Illuminate\Queue\Jobs\Job.php(192): Illuminate\Queue\Jobs\Job->failed(Object(Exception))
#2 D:\home\site\repository\vendor\laravel\framework\src\Illuminate\Queue\InteractsWithQueue.php(47): Illuminate\Queue\Jobs\Job->fail(Object(Exception))
The corresponding function in the framework (Job.php):
protected function failed($e)
{
$payload = $this->payload();
[$class, $method] = JobName::parse($payload['job']);
...
So it seems that job is not set in payload. Where and how does it get set? I never do this manually and I think this should always be set automatically by laravel!?
I did not have this issue before I upgraded to laravel 8 from 5.8
Related
I am trying to send email using laravel queue and database jobs table. In one of my file which is generating pdf which is attached with email has helper request()->organization, however it is throwing some sort of exception does laravel queue supports request() helper with queue?
Error:
#0 /var/www/app/Http/Services/Payslip.php(18): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Trying to get p...', '/var/www/app/Ht...', 18, Array)
Send the request data in the __construct function
so I got this code:
public static function postAllTasks()
{
$allTasks = Tasks::getTasksForToday();
foreach ($allTasks as $task) {
$delay = DB::table('jobs')->count()*20;
PostTasks::dispatch((string)$task->task)->delay($delay);
}
}
It is working fine on my computer just fine, but as soon as it is on the server it returns the error:
Error: Call to undefined function App\Http\Controllers\Traits\curl_init() in /var/www/html/app/Http/Controllers/Traits/TaskTrait.php:89
Stack trace:
#0 /var/www/html/app/Http/Controllers/Traits/TaskTrait.php(224)...
The problem is, that the PHP curl extension is active and visible + when I run exactly the same PHP artisan command, which doesn't use the dispatch/worker but just execute the Job (so it is using curl anyway) right away, everything works.
When I use:
QUEUE_CONNECTION=sync
instead of
QUEUE_CONNECTION=database
It works too, but I need it to use the database in order to calculate the delay between each job.
Laravel Framework 8.55.0
PHP 7.4.3
I'm giving Laravel 5 (4.3) a go and have tried writing some simple controller tests like so:
public function testIndex()
{
$this->call('GET', 'posts');
$this->assertResponseOk();
}
When I run the test I get an error:
ErrorException: Undefined property: PostsControllerTest::$client
Why has the client attribute disappeared from the test class in Laravel 5?
Functions like
$this->assertResponseOk();
are not available in the current build of Laravel 5. I'm not sure if Taylor plans to reintroduce them.
I think you can add the following package to get back some of the functionality
https://github.com/orchestral/testbench
I'm consuming json requests from an outside server to update products and such in Magento (please don't ask why we didn't just use the the api's ... ) and I'm now trying to update the attribute information and it seems to be failing the _uniqueCheck() method in the resource abstract. The problem is i don't know how to fix it. The following code
$attribute_model = Mage::getModel('eav/entity_attribute');
$attributeId = $attribute_model->getIdByCode('catalog_product', $attribute_code);
$attribute = $attribute_model->load($attributeId);
$attribute->setData($data)->save();
results in the following error:
[29-May-2013 16:32:00 UTC] PHP Fatal error: Uncaught exception 'Mage_Core_Exception' with message 'Attribute with the same code already exists.' in .../app/Mage.php:594
Stack trace:
#0 .../app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(676): Mage::throwException('Attribute with ...')
#1 .../app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(424): Mage_Core_Model_Resource_Db_Abstract->_checkUnique(Object(Mage_Eav_Model_Entity_Attribute))
#2 .../app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Core_Model_Resource_Db_Abstract->save(Object(Mage_Eav_Model_Entity_Attribute))
#3 .../app/code/local/Valoran/Import/Model/Attribute.php(25): Mage_Core_Model_Abstract->save()
#4 .../app/code/local/Valoran/Harmony/Model/Messaging/Attributeset.php(115): Valoran_Import_Model_Attribute->_create(Array)
#5 .../app/code/local/Valoran/Harmony/Model/Messaging/Attributeset.php(23): Valoran_Harmony_Model_Messaging_Attribut in .../app/Mage.php on line 594
This is frustrating for me because I know the code all ready exists, I'm trying to do an update that's why I called ->load($id) ....
Does anyone have any thoughts on what I'm missing here? I'm now exploring using the Mage_Eav_Model_Entity_Setup::updateAttribute method to accomplish this but so far I'm running into the same error.
I see two possible reasons why this is happening. Both of them are related with the use of setData() method. When you call it with an array as argument it will just replace the protected property $_data of the model. This property contains all information that are loaded/saved to the database.
I suspect that in your $data variable you do not have entity_attribute_id key. If this is the case when calling setData() you are removing id of the loaded attribute. You might be using attribute_code that is already used by another attribute in the system.
Anyway when you are saving the attribute magento checks for entity_attribute_id and if it is empty magento assumes that you want to create new attribute so it performs validation for the new attribute. This results in finding an attribute with the same code which is illegal and throws error. This attribute might be the one you loaded but you have removed the entity_attribute_id property or another with the same attribute_code
If you do not want to use Mage_Eav_Model_Entity_Setup::updateAttribute you could try calling
$attribute = $attribute_model->load($attributeId);
$data['entity_attribute_id'] = $attribute->getEntityAttributeId();
$attribute->setData($data)->save();
Receiving this fatal error when trying to access my planner.php and shared.php controllers. Any thoughts?
Fatal error: Uncaught exception 'Exception' with message 'Undefined method Ion_auth::get_user() called' in
/application/libraries/Ion_auth.php:88 Stack trace: #0
/application/core/MY_Controller.php(50): Ion_auth->__call('get_user', Array) #1
/application/core/MY_Controller.php(50): Ion_auth->get_user() #2
/application/controllers/user/planner.php(9): Common_Auth_Controller->__construct() #3
/system/core/CodeIgniter.php(288): Planner->__construct() #4 /index.php(202): require_once('/Users/lrussell...') #5 {main} thrown in/application/libraries/Ion_auth.php on line 88
Library Extension I'm Using for Ion Auth:
http://jondavidjohn.com/blog/2011/01/scalable-login-system-for-codeigniter-ion_auth
Planner Controller:
http://pastie.org/private/wc1bq6eiqb9hn8iubwdgq
Shared Controller:
http://pastie.org/private/uj3ta8dw3jl7kqxizs9n1a
Ion_auth Library Line 88 Segment:
http://pastie.org/private/mhgwdzjyhatwsdrux4gqpa
CRUD Model:
http://pastie.org/private/m2nhfqzabdsx5eiz6xqupw
Events Model:
http://pastie.org/private/b6ksjoowl7wde9errow
Shared Model:
http://pastie.org/private/f741jfnf8o2l5oxphnrl5w
Uhm, it happened to me the same exact thing. In the latest releases of this library, Ben Edmunds used php magic method __call() so that you don't have to call a model's method by using the regular syntax $this->ion_auth_model->method() but using instead $this->ion_auth->method(), as if it was a method belonging to the library.
But, actually, that method belongs to the model. So, if you go have a look at the model, you'll see that there's no get_user() method (nor is there in the library!), or at least in the version I talk about (the latest or the one just before. I downloaded a fresh copy one or two weeks ago).
I think there are some errors in the documentation he provided (though the overall work he did is awesome, kudos to Ben).
You can try using the user() model method, which should yield to the same result (it's the closer in functionality). So call $this->ion_auth->user() and see if that fits your needs.
EDIT
To clarify... instead of this...
$this->end_user = $this->ion_auth->current()->row();
do this...
$this->end_user = $this->ion_auth->user()->row();