wordpress: Uncaught Error: Call to undefined function mb_internal_encoding() - wordpress

I have just installed equifax-credit-check plugin in my wordpress site.Now this error displayed
Fatal error: Uncaught Error: Call to undefined function mb_internal_encoding() in /home/uplogictecz/public_html/demo/reportlink/wp-content/plugins/equifax-credit-check/vendor/danielstjules/stringy/src/Stringy.php:58 Stack trace: #0 /home/uplogictecz/public_html/demo/reportlink/wp-content/plugins/equifax-credit-check/vendor/danielstjules/stringy/src/Create.php(17): Stringy\Stringy->__construct('/reportlink/das...', NULL) #1 /home/uplogictecz/public_html/demo/reportlink/wp-content/plugins/equifax-credit-check/class/App.php(179): Stringy\create('/reportlink/das...') #2 /home/uplogictecz/public_html/demo/reportlink/wp-content/plugins/equifax-credit-check/class/PluginCore.php(300): Baerr\App\App::is_dashboard() #3 /home/uplogictecz/public_html/demo/reportlink/wp-includes/class-wp-hook.php(298): Baerr\App\PluginCore->dashboard_access_control('') #4 /home/uplogictecz/public_html/demo/reportlink/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(false, Array) #5 /home/uplogictecz/public_html/demo/reportlink/wp-includes/pl in /home/uplogictecz/public_html/demo/reportlink/wp-content/plugins/equifax-credit-check/vendor/danielstjules/stringy/src/Stringy.php on line 58
In my /home/uplogictecz/public_html/demo/reportlink/wp-content/plugins/equifax-credit-check/vendor/danielstjules/stringy/src/Stringy.php on line 58
Line function is
public function __construct($str = '', $encoding = null)
{
if (is_array($str)) {
throw new InvalidArgumentException(
'Passed value cannot be an array'
);
} elseif (is_object($str) && !method_exists($str, '__toString')) {
throw new InvalidArgumentException(
'Passed object must have a __toString method'
);
}
$this->str = (string) $str;
$this->encoding = $encoding ?: \mb_internal_encoding();
}
This line is $this->encoding = $encoding ?: \mb_internal_encoding(); no 58.
How to fix this issue ?.Kindly check it.

Your PHP environment is missing MBSTRING extension. It is normal, as mbstring is not built-in default extension in some PHP installations. You can install it if you have an access to your server:
For PHP 5.* and Debian
sudo apt-get install php-mbstring
For PHP 5.* and Fedora
yum install php-mbstring
For PHP 7.0, use
sudo apt-get install php7.0-mbstring
And of course, if you don't have server access, you need to ask your hosting provider to enable this extension for your website server.

Related

Laravel 6 cannot run tests "PHPUnit\Runner\BaseTestRunner::getTest() must be of the type string"

I'm trying to write very simple phpunit test
php artisan make:test CarTest
class CarTest extends TestCase
{
/**
* A basic feature test example.
*
* #return void
*/
public function testExample()
{
$response = $this->get('/car');
$response->assertStatus(200);
}
}
Now I run it
phpunit ./tests/Feature/CarTest.php
I get
Fatal error: Uncaught TypeError: Argument 2 passed to PHPUnit\Runner\BaseTestRunner::getTest() must be of the type string, array given, called in C:\Users\yasse\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php on line 125 and defined in C:\xampp\htdocs\lara6\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:60
Stack trace:
#0 C:\Users\{username}\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php(125): PHPUnit\Runner\BaseTestRunner->getTest('C:\\xampp\\htdocs...', Array)
#1 C:\Users\{username}\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php(101): PHPUnit\TextUI\Command->run(Array, true)
#2 C:\Users\{username}\AppData\Roaming\Composer\vendor\phpunit\phpunit\phpunit(61): PHPUnit\TextUI\Command::main()
#3 {main}
I installed phpunit globally and installed it locally (v8) using composer and run composer dump-autoload but issue is not resolved. How to fix this and be able to run this test?

PhpStorm with PHPUnit 8.4 gives exception Uncaught PHPUnit\Runner\Exception class ... could not be found

I tried to use PHPUnit v8. However I was not succeeded with PhpStorm. When I run simple test (class method) in PhpStorm I got the following message:
PHP Fatal error: Uncaught PHPUnit\Runner\Exception: Class 'Mrself\\TreeType\\Tests\\Functional\\BuildingTest' could not be found in '/vagrant/symfony-tree-type/tests/Functional/BuildingTest.php'. in /vagrant/symfony-tree-type/vendor/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php:65
Yes, I have that class and yes I have psr configured properly:
"autoload": {
"psr-4": {
"Mrself\\TreeType\\": "./src/"
}
},
"autoload-dev": {
"psr-4": {
"Mrself\\TreeType\\Tests\\": "./tests/"
}
}
The proof the I have everything correctly setup is that when I run vendor/bin/phpunit it gives me correct result.
When I run method in PhpStorm I got the following call:
/usr/bin/php /vagrant/symfony-tree-type/vendor/phpunit/phpunit/phpunit --configuration /vagrant/symfony-tree-type/phpunit.xml --filter "/(::testFormCanBeBuild)( .*)?$/" Mrself\\TreeType\\Tests\\Functional\\BuildingTest /vagrant/symfony-tree-type/tests/Functional/BuildingTest.php --teamcity
However if I prepend class namespace with \\ everything works correctly as well. I can not get a clue what's going on. PHPUnit version 7 works as well.
Same thing happened to me. All of the sudden I started getting the following error:
PHP Fatal error: Uncaught PHPUnit\Runner\Exception: Class 'Tests\\Feature\\ExampleTest' could not be found
And after I have read #frank-vue's comment I noticed the same thing and he did: If I run tests on the entire folder it runs normally, but if I run test on a specific class/method I get that error.
I tried earlier version of PHPStorm, downgraded PHP plugin etc... and nothing worked.
In my case, when I checked the stacktrace looks like:
#0 /var/www/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php(145): PHPUnit\Runner\StandardTestSuiteLoader->load('Tests\\\\Unit\\\\Ex...', '/var/www/tests/...')
#1 /var/www/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php(105): PHPUnit\Runner\BaseTestRunner->loadSuiteClass('Tests\\\\Unit\\\\Ex...', '/var/www/tests/...')
#2 /var/www/vendor/phpunit/phpunit/src/TextUI/Command.php(177): PHPUnit\Runner\BaseTestRunner->getTest('Tests\\\\Unit\\\\Ex...', '/var/www/tests/...', Array)
#3 /var/www/vendor/phpunit/phpunit/src/TextUI/Command.php(159): PHPUnit\TextUI\Command->run(Array, true)
#4 /var/www/vendor/phpunit/phpunit/phpunit(61): PHPUnit\TextUI\Command::main()
#5 {main}
thrown in /var/www/vendor/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php on line 69
Notice Tests\\\\Unit\\\\Ex... instead of Tests\\Unit\\Ex....
So in the end I broke the rule and I've modified vendor file, which should be avoided at any cost, but as a temporary solution it solves my problem.
So I added 1 line to the vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php on line 98 (PHPUnit version 8.4.1), which replaces unnecessary '\'s.
if (empty($suiteClassFile) && \is_dir($suiteClassName) && !\is_file($suiteClassName . '.php')) {
/** #var string[] $files */
$files = (new FileIteratorFacade)->getFilesAsArray(
$suiteClassName,
$suffixes
);
$suite = new TestSuite($suiteClassName);
$suite->addTestFiles($files);
return $suite;
}
$suiteClassName = str_replace('\\\\', '\\', $suiteClassName); // THIS IS THE LINE I ADDED
try {
$testClass = $this->loadSuiteClass(
$suiteClassName,
$suiteClassFile
);
} catch (Exception $e) {
$this->runFailed($e->getMessage());
return null;
}

Deploy Symfony 4 application but composer has "cache:clear error"

I try to deploy my Symfony application and when I use composer to install dependencies, I get an error.
I saw that there were people who had the same problem but I didn' t find a solution. Like change in .env APP_ENV=dev to APP_ENV=prod.
Here the logs :
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!! PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DoctrineFixturesBundle" from namespace "Doctrine\Bundle\FixturesBundle".
!! Did you forget a "use" statement for another namespace? in /tmp/build.YZSXu7Ir2b/src/Kernel.php:23
I use DoctrineFixturesBundle only in dev environment :
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.1",
"fzaninotto/faker": "^1.8",
"symfony/profiler-pack": "^1.0"
}
Here my config/bundles.php :
...
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
...
And here Line 23 of Kernel.php :
...
public function registerBundles(): iterable
{
$contents = require $this->getProjectDir().'/config/bundles.php';
foreach ($contents as $class => $envs) {
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
yield new $class(); // line 23
}
}
}
...
if I understand your problem, you just have Composer Install, but the best is to do that composer install --no-dev --optimize-autoloader it's explained Here. Otherwise, I do not know
Please check if directory "vendor/doctrine/doctrine-fixtures-bundle" exists and if there are files inside - specifically the "vendor/doctrine/doctrine-fixtures-bundle/DoctrineFixturesBundle.php"
If they are not there then it seems you didnt executed "composer update" to add the package. In such case please try:
COMPOSER_MEMORY_LIMIT=-1 composer update doctrine/doctrine-fixtures-bundle
You should see something like:
- Installing doctrine/data-fixtures (v1.3.1): Loading from cache
- Installing doctrine/doctrine-fixtures-bundle (3.2.2): Loading from cache

PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException

I try to release my web application using Symfony 4.0.6 on Elastic Beanstalk of Amazon Web Service. However, I have a problem about "Script cache:clear returned with error code 255 !! (Executor::NonZeroExitStatus)" when the application is deploying
I have updated the symfony/flex (v1.0.70 => v1.0.71) and I have checked it following.
$ composer install --no-dev --optimize-autoloader
~~~~
- Removing symfony/process (v4.0.6)
Generating optimized autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!! PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DebugBundle" from namespace "Symfony\Bundle\DebugBundle".
!! Did you forget a "use" statement for another namespace? in C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\src\Kernel.php:32
!! Stack trace:
!! #0 C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\vendor\symfony\http-kernel\Kernel.php(403): App\Kernel->registerBundles()
!! #1 C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\vendor\symfony\http-kernel\Kernel.php(122): Symfony\Component\HttpKernel\Kernel->initializeBundles()
!! #2 C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\vendor\symfony\framework-bundle\Console\Application.php(64): Symfony\Component\HttpKernel\Kernel->boot()
!! #3 C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\vendor\symfony\console\Application.php(143): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
!! #4 C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\bin\console(39) in C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\src\Kernel.php on line 32
I think that we need to check three bundles following
class Kernel extends BaseKernel
{
public function registerBundles()
{
$contents = require $this->getProjectDir().'/config/bundles.php';
foreach ($contents as $class => $envs) {
if (isset($envs['all']) || isset($envs[$this->environment])) {
**yield new $class();**
}
}
}
cat /config/bundles.php
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Could you please give me an advice?
I think the problem is you don't pass the APP_ENV environment variable, so the script cache:clear is running in dev mode.
You should run APP_ENV=prod composer install --no-dev --optimize-autoloader
This is also mention on https://symfony.com/doc/current/deployment.html#c-install-update-your-vendors
Another option is to run composer install --no-dev --optimize-autoloader --no-scripts, with the extra flag no scripts will be executed, but I don't know if your application relies on scripts to be run.

Symfony 2.2.1 rsync deploy - not working on remote server

I'm very new to Symfony and I'm trying to automate the deploy process with rsync, while keeping both the local and remote installs of Symfony working.
What I've done so far:
installed Cygwin on my local machine (Windows 7+Apache2.2+PHP 5.3+MySQL 5.1)
done a basic Symfony install on my local machine from shell with the command
php composer.phar create-project symfony/framework-standard-edition [path]/ 2.2.1
set up a remote LAMP Ubuntu server with php-fpm (fastcgi)
set up two different configuration files for local and remote in the app/config/ dir, parameters.yml and parameters.yml.remote
created an app/config/rsync_exclude.txt file containing a list of files not to rsync to the remote server (as suggested in this page)
created a deploy shell script that I run from Cygwin (see below)
The deploy script issues the commands:
rsync -avz /cygdrive/c/[path]/ user#server:[remote-path]/ --exclude-from=/cygdrive/c/[path]/app/config/rsync_exclude.txt
ssh user#server 'cd [remote-path]/ && php app/console --env=prod cache:clear && php app/console cache:clear'
ssh user#server 'mv [remote-path]/app/config/parameters.yml.remote ~/[remote-path]/app/config/parameters.yml'
The rsync, ssh and mv commands work, but the deployed site shows always a HTTP 500 error (both app.php and app_dev.php).
Looking at server error log the error is:
Fatal error: Class 'Composer\\Autoload\\ClassLoader' not found in /[remote-path]/vendor/composer/autoload_real.php on line 23
Any clue would be more than welcome.
Edit - here is my vendor/composer/autoload_real.php file (sorry for the making the question longer!):
<?php
// autoload_real.php generated by Composer
class ComposerAutoloaderInit9d50f07556e53717271b583e52c7de25
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit9d50f07556e53717271b583e52c7de25', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
// ^^^^^^ this is line 23 and gives the error ^^^^^^^^^^^
spl_autoload_unregister(array('ComposerAutoloaderInit9d50f07556e53717271b583e52c7de25', 'loadClassLoader'));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->add($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
$loader->register(true);
require $vendorDir . '/kriswallsmith/assetic/src/functions.php';
require $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php';
return $loader;
}
}
If there is an error with the autoloader generated by composer, performing ...
composer update
... will update your dependencies and create a new one.
You should invoke the command with the -o flag if you are deploying to a production system.
This way composer generates a classmap autoloader ( which performs way better ) instead of the classic autoloader.
composer update -o
I guess re-generating the autoloader will solve the issue :)

Resources