Array to string conversion - Project Crash [Laravel] - php

I am getting an error like this:
Array to string conversion
Inside:
/var/.../vendor/cartalyst/sentry/src/Cartalyst/Sentry/SentryServiceProvider.php
Code snippet where the error was thrown:
throw new \InvalidArgumentException("Invalid hasher [$hasher] chosen for Sentry.");
I was doing ordianry work in one of my controllers and this error occured when I clicked on one of the buttons inside my blade.
I have commented the code out but the error still is being displayed, not only on this one page but on every single one in my project. I can't even go to my /home/index.php page.
I have done
composer update
inside my project but that did not help. What can fix the problem?
#update
Yes I have checked sentry config file before I've made a new topic. I have the same problem when I load older versions (which do not contain the latest changes I've made today) of my project on to apache server which is running on Ubuntu 14.04.
Ideas what causes the problem?

In the config for Sentry you have to define a hasher.
It has to be a string. It can be 'native', 'bcrypt', 'sha256' or 'whirlpool'. Apparently in your app, it's not a string, but an array. Check your configuration. It's probably in app/config/packages/cartalyst/sentry/config.php

Related

Cannot find name for "en_UK" locale code - error in Sylius

So I'm setting up a sylius project using docker and am getting an error when I first tried to load the page. The docker set up on sylius website didn't seem to work so I made my own docker files and can successfully start the docker containers. The error is below:
An exception has been thrown during the rendering of a template ("Cannot find name for "en_UK" locale code").
During the installation, sylius asks whether you want en_US or something different so I typed en_UK, presuming that was the notation required. Upon setup completion, I tried to load root page and I get the error message above. However, strangely, on the symfony toolbar on the error page it says US web store.
If anyone could help at all it would be greatly appreciated. Thank you in advance.
Possible ways:
go to localhost/admin, enter your login/password which you entered at the install moment, open Channels section, and there add change default locale/add new to locale list;
modify a <project-root>/config/services.yaml and change locale value to another;
in the worst case try to run php bin/console sylius:install command and reinstall database with a en_US at the beginning, then edit Admin section to en_UK
en_UK means "English (Ukraine)". No wonder it was missing. What you wanted was probably en_GB.

Symfony messenger can't consume messages

Few weeks ago I set up a Message system with Symfony Messenger and it worked great.
Today I wanted to create new object through message, so I went to my server and type the command to consume message
First I had this result
$ bin/console messenger:consume-messages amqp_notifications
/usr/bin/env: ‘php\r’: No such file or directory
It never happened before with my files, and I never changed the line ending or encoding of my file sin PHPstorm.
I tried to use $ php bin/console messenger:consume-messages amqp_notifications
but then I had this error.
Attempted to load class "AMQPConnection" from the global namespace.
Did you forget a "use" statement?
Pretty weird, because I have have the php-amqp ext installed as you can see on the screenshot of my phpinfo
I didn't change anything in my Message class or Handler.
Also, I tried to call new AMQPConnection() on a random action, just to try, and I didn't get the error.
I'm completely lost with this error this time, as everything is installed.
I use PHP 7.3.1 and symfony Messenger 4.2.2
It seems your second issue was already solved by ccKep on his comment.
The first one is that the specific shebang line #!/usr/bin/env php executes the first php found in the $PATH. So if you already have uninstalled it, which seems the case, or it has a symbolic link to another php version, you can get a wrong result.
Tries to check what is inside the $PATH and replace the PHP path for the correct one. You might get the place running which php.

Laravel - Auth getting stuck on reading session file

hope you're good
I was trying to add a profile table to my Laravel 5.6 project, and I'm also using the spatie\Laravel-Permission package. It was working fine, but after I ran some migrations (that have nothing to do with users), it started failing on the login. The curious thing is that, if I register a new user, it gets logged in properly, but never with the /login route (I'm using the Laravel's Auth scaffolding).
After debugging the project, I came up with the method that's failing, it's something reading the sessions:
MyProject\vendor\laravel\framework\src\Illuminate\Filesystem\Filesystem.php
<?php
namespace Illuminate\Filesystem;
use ErrorException;
use FilesystemIterator;
use Symfony\Component\Finder\Finder;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
class Filesystem{
// ...
public function get($path, $lock = false)
{
if ($this->isFile($path)) {
return $lock ? $this->sharedGet($path) : file_get_contents($path); // <-- The failing line
}
throw new FileNotFoundException("File does not exist at path {$path}");
}
// ...
}
Once it gets to that line, the debugger stops, the browser doesnt get a response, the dd() function does not get triggered... I also tried to debug the sharedGet($path) method, and it returns the value, but back to the method above, it stops.
Also, the php_error.log file gets absurdly increased on every request (up to 500MB/request), so much that none of the editors I use can open it (SublimeText, NetBeans).
My thoughts are that apache may be running out of memory when reading the files, but the session file barely weights 1k, so it wouldn't make much sense.
Can someone throw any clue? Thanks
--EDIT:
I tried installing a fresh laravel proyect with only the Auth module and the spatie/laravel-permission package, and I noticed the same behaviour: it registers and logs users, but after logging it out, I'm no longer able to log in with any user.
In case someonw gets to the same error:
I could manage to solve this by backing up all my projects/databases and reinstalling wampserver with the last version of php (by the moment of this answer, it is 7.2.4) and reinstalling Laravel (luckily the proyect was barely starting), which only updated vlucas/phpdotenv package from 2.4.0 to 2.5.0 and phpunittest.
Whith this update now I can log in users normally, now let's see if it works as it should with spatie/laravel-permission package and the profile table I need to add.

Unable to create package in module builder or Deploy a new package in SuiteCRM

I am unable to create a new package from module builder. In module builder, when I enter a package name and key and hit save, it does nothing.
When I inspect in chrome, the console logs the following error:
Uncaught TypeError: Cannot read property 'value' of undefined
at validate_form (sugar_grp1.js:228)
at check_form (sugar_grp1.js:160)
at Object.handleSave (ModuleBuilder.js:905)
at HTMLInputElement.onclick (/XXXXXX/index.php?module=ModuleBuilder&action=index&type=mb#ajaxUILoc=&mbContent=module%3DModuleBuilder%26action%3Dpackage%26new%3D1:1)
Any suggestions on what I can look at or do to debug?
I'm using SuiteCRM 7.7.8
Php 7
I thought this might be a permissions issue, so i made sure all folders and files are 755 and tried to create the package again but got the same error.
I do not have any custom modules. this was the first one im trying to build.
I get similar errors if i try to export a module in studio also.
When I dig deeper, the exact line that fails in sugar_grp1.js is var current_module=document.getElementsByName("view_module")[0].value;
There is no element with name view_module on the page. It appears that this is happening to other users also. Please see: https://suitecrm.com/community/forum/suitecrm-7-0-discussion/12418-unable-to-create-package-in-module-builder#42665
UPDATE: I have done the usual repair and rebuild everything along with JS groupings and JS. Still the same.
An easy solution, see following steps:
Open /cache/include/javascript/sugar_grp1.js
Go to line 228 or find the next text:
var current_fields='';var current_module=document.getElementsByName("view_module")[0].value;$.ajax({type:"GET",url:"index.php?to_pdf=1&module=ModuleBuilder&action=getModuleFields&current_module="+current_module,async:false,success:function(result){current_fields=JSON.parse(result);},error:function(xhr,status,error){var err=eval("("+xhr.responseText+")");}});for(k=0;k<current_fields.length;k++){if(isError!=true){val=current_fields[k].toUpperCase();if((operator=="=="&&val==item1)||(operator=="!="&&val!=item1)){isError=true;add_error_style(formname,validate[formname][i][nameIndex],'Invalid Value: Field Name already exists');}}}
Remove this line.
QuickRepair.
Clear your Browser Cache and try again.

Laravel Framework not showing errors

Can anyone explain if there is a way to catch or log errors when the following code is executed?
//This has example has no semicolon.
Route::get('user/{id}', function($id)
{
return View::make('profile')
});
or
//This example has no dollar sign (part of a blade template).
Welcome {{ userName }}
I end up with an empty page for these and there have been a few other times this has happened where I can't remember the details.
I have debug set to true in app/config/app.php and I don't get any errors in the log files at app/storage/logs
Is this normal or do I have a problem with my setup?
Thanks
UPDATE
Laravel log commands aren't working for me. See the comment in reply to msturdy.
Sorted this now. I downloaded the latest Laravel and still had identical issues. Eventually I found out that Apache was pointing at a old version of php (5.3.0) that lived on a different drive (no idea how I've done that), anyway I had my command line pointed at the correct version of php, so that's why I've had no issues when installing/updating Laravel.
Small chance anyone would see similar issues as it was a bit of a random situation (my apologies). I now get the prettiest runtime exception page I've ever seen when running the examples :). Thanks msturdy

Categories