Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Typed property Ehann\RedisRaw\AbstractRedisRawClient::$logger must not be accessed before initialization AbstractRedisRawClient.php:40 #4

Open
uweng opened this issue Feb 12, 2024 · 2 comments

Comments

@uweng
Copy link

uweng commented Feb 12, 2024

Using "redisearch-php" with this code :

<?php
require_once 'vendor/autoload.php';
use Ehann\RedisRaw\PhpRedisAdapter;
use Ehann\RediSearch\Index;

$redis = new PhpRedisAdapter();
$index = new Index($redis);

//Connecting to Redis server on localhost
 try
   {
     $redis->connect('127.0.0.1', 6379);
     echo "Successfull connect to Redis-Server!\n";
   } catch (Exception $e)
   {
     echo "Error connect to Redis-Server!\n";
   }
//Create Index if not allready exist
 try
   {
     $index->addTextField('sessionId')
          ->addTextField('timestamp')
          ->create();
     echo "Index 'logging' created!\n";
    } catch (Exception $e)
    {
      echo "Error create Index 'logging' !\n";
    }'

results in:
$ php ./bug.php

Successfull connect to Redis-Server!
PHP Fatal error:  Uncaught Error: Typed property Ehann\RedisRaw\AbstractRedisRawClient::$logger must not be accessed before initialization in /logging/vendor/ethanhann/redis-raw/src/AbstractRedisRawClient.php:40
Stack trace:
#0 /logging/vendor/ethanhann/redis-raw/src/PhpRedisAdapter.php(39): Ehann\RedisRaw\AbstractRedisRawClient->prepareRawCommandArguments('FT.CREATE', Array)
#1 /logging/vendor/ethanhann/redisearch-php/src/RediSearchRedisClient.php(109): Ehann\RedisRaw\PhpRedisAdapter->rawCommand('FT.CREATE', Array)
#2 /logging/vendor/ethanhann/redisearch-php/src/AbstractRediSearchClientAdapter.php(24): Ehann\RediSearch\RediSearchRedisClient->rawCommand('FT.CREATE', Array)
#3 /logging/vendor/ethanhann/redisearch-php/src/Index.php(75): Ehann\RediSearch\AbstractRediSearchClientAdapter->rawCommand('FT.CREATE', Array)
#4 /logging/bug.php(23): Ehann\RediSearch\Index->create()
#5 {main}
  thrown in /logging/vendor/ethanhann/redis-raw/src/AbstractRedisRawClient.php on line 40
@uweng
Copy link
Author

uweng commented Feb 12, 2024

The fix like this in File AbstractRedisRawClient.php:

-- protected LoggerInterface $logger;
++private $logger;
++
++ public function __construct(LoggerInterface $logger = null)
++  {
++        $this->logger = $logger;
++   }
works fine. 

@cirolosapio-accenture
Copy link

+1

if I require ethanhann/redis-raw composer installs the version 2.1.0
but in this repository the latest version is 2.0.0
and it hasn't this bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants