PHPSocialNetwork / phpfastcache

A high-performance backend cache system. It is intended for use in speeding up dynamic web applications by alleviating database load. Well implemented, it can drops the database load to almost nothing, yielding faster page load times for users, better resource utilization. It is simple yet powerful.
https://www.phpfastcache.com
MIT License
2.36k stars 452 forks source link

v8: `Invalid type hint found for "htaccess", expected "string" got "boolean"` for `leveldb` driver. #840

Closed nitz closed 2 years ago

nitz commented 2 years ago

Configuration

Describe the bug

Freshly installed phpfastcache via composer, attempting to use an unmodified (sans require path) leveldb example produces the error:

[Sun Nov 07 15:22:56.106595 2021] [fcgid:warn] [pid 3096559:tid 140172737914624] [client 108.253.163.97:65297] mod_fcgid: stderr: PHP Fatal error:  Uncaught Phpfastcache\\Exceptions\\PhpfastcacheInvalidConfigurationException: Invalid type hint found for "htaccess", expected "string" got "boolean" in /path/to/www/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Config/ConfigurationOption.php:144
[Sun Nov 07 15:22:56.106744 2021] [fcgid:warn] [pid 3096559:tid 140172737914624] [client 108.253.163.97:65297] mod_fcgid: stderr: Stack trace:
[Sun Nov 07 15:22:56.106773 2021] [fcgid:warn] [pid 3096559:tid 140172737914624] [client 108.253.163.97:65297] mod_fcgid: stderr: #0 /path/to/www/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/CacheManager.php(189): Phpfastcache\\Config\\ConfigurationOption->__construct(Array)
[Sun Nov 07 15:22:56.106796 2021] [fcgid:warn] [pid 3096559:tid 140172737914624] [client 108.253.163.97:65297] mod_fcgid: stderr: #1 /path/to/www/index.php(30): Phpfastcache\\CacheManager::getInstance('Leveldb')
[Sun Nov 07 15:22:56.106816 2021] [fcgid:warn] [pid 3096559:tid 140172737914624] [client 108.253.163.97:65297] mod_fcgid: stderr: #2 {main}
[Sun Nov 07 15:22:56.106834 2021] [fcgid:warn] [pid 3096559:tid 140172737914624] [client 108.253.163.97:65297] mod_fcgid: stderr:   thrown in /path/to/www/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Config/ConfigurationOption.php on line 144

To Reproduce Steps to reproduce the behavior:

  1. Create a new directory on a publicly accessible website.
  2. In that directory, composer require phpfastcache/phpfastcache (respond 'n' if asked to use a parent directory composer.json)
  3. Create index.php with the contents of docs/examples/leveldb.php. 3.a. Modify index.php to adjust the include path to point to the vendor folder composer created.
  4. Access that directory through a web browser.
  5. Observe 500 error.
  6. View server error logs, observe error similar to one shown above.

Expected behavior The leveldb example to run.

Screenshots N/A

Additional context I'm not sure if this is something fixed in v9. I'm not on PHP 8 yet, so I can't try the newer version.

github-actions[bot] commented 2 years ago

Hello curious contributor ! Since it seems to be your first contribution, make sure that you've been:

Geolim4 commented 2 years ago

Hello,

Example directory is not really reliable but I'll push a fix soon.

Be aware that this directory has been removed in V9.

Instead look at the tests directory which contain much more reliable examples.

nitz commented 2 years ago

Sure that makes sense! :)

I don't see any test that uses the leveldb driver specifically. But I am still confused as to where the htaccess issue is coming from, too. I don't see that property in the config structure for it to get upset about. The same code seems to work fine if I swap the leveldb driver for files for example.

Geolim4 commented 2 years ago

This issue has been fixed, however I'm not going to make a new version immediately, meanwhile use dev-v8.

nitz commented 2 years ago

Awesome, thank you! I'm blown away with how quickly you responded and got this figured out. Make sure to relax some this weekend! :)

Geolim4 commented 2 years ago

Sure that makes sense! :)

I don't see any test that uses the leveldb driver specifically. But I am still confused as to where the htaccess issue is coming from, too. I don't see that property in the config structure for it to get upset about. The same code seems to work fine if I swap the leveldb driver for files for example.

It's because Phpfastcache "auto-validate" the Configuration object passed to the driver pool instance, if something is wrong it throws an error.

I think this driver is not tested actually (the last one not to be) because I can't build a stable Leveldb extension for current php7 version. It looks abandoned or poorly maintained atm.