Commit Graph

67 Commits

Author SHA1 Message Date
Dag 7dbe106582
docs(nginx, phpfpm): improve install and config instructions (#3866) 2023-12-28 23:26:14 +01:00
Dag f01729c86f
fix(arstechnica): plus a few unrelated tweaks (#3829) 2023-12-13 21:40:13 +01:00
Dag cf9558648e
refactor: YoutubeBridge (#3755) 2023-10-15 00:08:18 +02:00
Dag 0de5180ded
feat: improve sqlite cache robustness (#3715) 2023-09-28 22:21:56 +02:00
Dag 857e908929
chore: prepare 2023-09-24 release (#3703) 2023-09-24 20:53:07 +02:00
Dag 7329b83cc0
refactor: logger (#3678) 2023-09-21 22:05:55 +02:00
Dag 3178deb5a8
fix: mastodon, cache tweaks, docs (#3661)
* cache tweaks

* docs

* fix(mastodon): type bug
2023-09-10 23:35:40 +02:00
Dag 4b9f6f7e53
fix: rewrite and improve caching (#3594) 2023-09-10 21:50:15 +02:00
Dag 0a118310cb
fix(sqlitecache): store blob as blob (#3555)
serialize() can return output with null bytes and other
non-text data. The prior behavior truncated data
which later results in unserialize() errors.

This happens when e.g. caching an object with a private field
or when caching e.g. a JPEG file (starts with 0xFFD8FFE1)

Fixes errors such as e.g.:

unserialize(): Error at offset 20 of 24 bytes at caches/SQLiteCache.php line 51
2023-07-20 19:11:13 +02:00
Dag f91723d9e5
fix(memcached): do not flush entire cache, oops (#3551) 2023-07-19 05:18:26 +02:00
Dag 6254b8593e
refactor(cache): extract and encapsulate cache expiration logic (#3547)
* refactor(cache): extract and encapsulate cache expiration logic

* fix: logic bug in getSimpleHTMLDOMCached

* fix: silly me, index should of course be on the key column

* silly me again, PRIMARY keys get index by default lol

* comment out the delete portion in loadData

* remove a few log statements

* tweak twitter cache timeout
2023-07-19 05:05:49 +02:00
Dag 773eea196f
fix(sqlitecache): bug in prior refactor (#3540)
fixes:

rssbridge.WARNING Trying to access array offset on value of type bool at caches/SQLiteCache.php line 72
2023-07-16 05:29:56 +02:00
Dag e8420b9f39
fix(sqlitecache): log failed unserialization (#3539) 2023-07-15 22:44:26 +02:00
Dag ef8181478d
perf(SqliteCache): add index to updated (#3515)
* refactor(SqliteCache)

* perf(SqliteCache): add index to updated
2023-07-15 22:12:16 +02:00
Dag 91976f7d56
fix(file cache): acquire lock before writing (#3509) 2023-07-08 17:06:49 +02:00
Dag 46f0e97c73
refactor: remove useless actual args to clearstatcache (#3503) 2023-07-06 19:39:40 +02:00
Dag 5e22459eb6
fix: remove unnecessary calls to purgeCache (#3502) 2023-07-06 18:52:19 +02:00
Dag 965d7d44c5
feat(sqlite cache): add config options (#3499)
* refactor: sqlite cache

* refactor

* feat: add config options to sqlite cache

* refactor
2023-07-06 15:59:38 +02:00
Dag caac7f572c
refacor: improve cache interface (#3492)
* fix: proper typehint on setScope

* refactor: type hint setKey()

* typehint
2023-07-06 15:10:30 +02:00
Dag a9fd3b9e61
fix(CacheInterface): logic bug in getTime (#3491)
* fix(CacheInterface): logic bug in getTime

* test
2023-07-05 17:37:21 +02:00
Dag 372880b5ef
fix: file cache tweaks (#3470)
* fix: improve file cache

* fix(filecache): log when unserialize fails
2023-06-30 22:31:19 +02:00
Dag 9e9a697b8b
feat: add config option "path" for file cache (#3297) 2023-03-20 19:10:01 +01:00
Dag 058e792b8f
feat: add filecache config to enable/disable real purge (#3263)
* refactor: cachefactory

* feat: add filecache config to enable/disable real purge

* test: fix test
2023-03-06 21:50:40 +01:00
Dag c27a300e02
test: add failing mastodon test (#3255)
* fix: refactor cache factory

* test: add failing test

* add null cache
2023-02-15 21:22:37 +01:00
Dag 1b45a53402
fix: make filecache be case-sensitive on key (#3113) 2022-10-29 10:27:26 +02:00
Dag 52af2ae34c
fix: php errors (notices) (#3115) 2022-10-26 00:47:45 +02:00
Dag 5165ea265d
fix: case-insensitive config from env, fix #2935 (#2973)
* refactor

* fix: case-sensitive config from env, fix #2935

* lowercase all config section and keys

* test: add test for case-insensitivity
2022-08-23 21:19:53 +02:00
Dag 2bbce8ebef
refactor: general code base refactor (#2950)
* refactor

* fix: bug in previous refactor

* chore: exclude phpcompat sniff due to bug in phpcompat

* fix: do not leak absolute paths

* refactor/fix: batch extensions checking, fix DOS issue
2022-08-06 22:46:28 +02:00
Dag ecb486794b
refactor: use static values for cache scope
This fixes a future problem when code is placed under a namespace because `get_class($bridge)` will then return e.g. `RssBridge\Bridge\TwitterBridge` instead of the the current value `TwitterBridge`.

Also a bit refactoring of `Configuration.php`.
2022-08-02 15:03:54 +02:00
Dag abfc6b4633
feat: introduce template engine (#2899) 2022-07-08 14:17:25 +02:00
Dag 4f75591060
Reformat codebase v4 (#2872)
Reformat code base to PSR12

Co-authored-by: rssbridge <noreply@github.com>
2022-07-01 15:10:30 +02:00
Jakub Valenta 8e2b65556f
[Config] Don't check PATH_CACHE for memcached (#1489) 2022-03-24 21:29:16 +01:00
Eugene Molotov e4c4ae8245
[MemcachedCache] loadData now returns null instead of false (#1592)
FileCache and SQLiteCache returns null on cache miss. This is important if using strict comparing (for example when using "===")
2020-06-08 11:27:19 +02:00
logmanoriginal ccf375e917 config: Use global constant for config files
The configuration files are currently hard-coded in the configuration
classes and error messages. However, the implementation should not
rely on specific details like the file name. Instead, the files should
be part of the global definition.

This commit introduces two global constants for the configuration files

- FILE_CONFIG => 'config.ini.php'
- FILE_CONFIG_DEFAULT => 'config.default.ini.php'
2019-06-07 19:48:29 +02:00
Eugene Molotov 75359bc11b [core] Implemented MemcachedCache (#1000)
* [core] Implemented MemcachedCache
2019-05-03 11:56:07 +02:00
fulmeek 21d3bf3b60 caches: Refactor the API (#1060)
- For consistency, functions should always return null on non-existing data.

- WordPressPluginUpdateBridge appears to have used its own cache instance in the past. Obviously not used anymore.

- Since $key can be anything, the cache implementation must ensure to assign the related data reliably; most commonly by serializing and hashing the key in an appropriate way.

- Even though the default path for storage is perfectly fine, some people may want to use a different location. This is an example how a cache implementation is responsible for its requirements.
2019-04-29 20:12:43 +02:00
logmanoriginal f450b2e118 [SQLiteCache] Check sqlite3 extension in __construct
Checks if the sqlite3 extension is loaded and throws an error
if it's missing.
2019-03-02 19:33:44 +01:00
fulmeek dc1b1b13cc [SQLiteCache] Implement cache based on SQLite 3 (#1035) 2019-02-24 12:04:27 +01:00
Eugene Molotov ffb8b82c73 [FileCache] reseting cached file stat result to have correct getTime() result (#792)
* [FileCache] reseting cached file stat result to have correct getTime() result
2018-08-25 20:00:51 +01:00
LogMANOriginal 193ca87afa [phpcs] enforce single quotes (#732)
* [phpcs] Add rule to enforce single quoted strings
2018-06-29 22:55:33 +01:00
teromene 3ca59392c2 Fix for crashes when accessing FileCache in case it has been purged/not created yet. 2018-05-05 18:05:48 +01:00
logmanoriginal a4b9611e66 [phpcs] Add missing rules
- Do not add spaces after opening or before closing parenthesis

  // Wrong
  if( !is_null($var) ) {
    ...
  }

  // Right
  if(!is_null($var)) {
    ...
  }

- Add space after closing parenthesis

  // Wrong
  if(true){
    ...
  }

  // Right
  if(true) {
    ...
  }

- Add body into new line
- Close body in new line

  // Wrong
  if(true) { ... }

  // Right
  if(true) {
    ...
  }

Notice: Spaces after keywords are not detected:

  // Wrong (not detected)
  // -> space after 'if' and missing space after 'else'
  if (true) {
    ...
  } else{
    ...
  }

  // Right
  if(true) {
    ...
  } else {
    ...
  }
2017-07-29 19:55:12 +02:00
logmanoriginal 5de03d6b9f [FileCache] Use serialize instead of json_encode
json_encode causes high memory footprint on large input data,
where serialize is less problematic.

Example: When using AcrimedBridge items contain pictures in
raw format (entire picture) which leads to a file size of about
2MB using serialize. json_encode will allocate about 98MB of
memory for encoding, causing memory exhausion errors (PHP
allows for 128MB of memory by default)
2017-02-18 12:54:26 +01:00
logmanoriginal 1d26c7f1c3 [FileCache] Do not delete .gitkeep
This commit reduces the chance of accidentally removing the cache
folder from repository.
2017-02-18 10:23:50 +01:00
logmanoriginal 14c689e7a3 [core] Fix typos 2016-11-09 19:10:40 +01:00
Gilles Maurer 4dfbc16a5b Fix Cache write verification
PHP operator '===' is the only strict way to mix up the value '0' and
the value 'FALSE'.

The function saveData of the FileCache tests if the write of the cache
files was done with success and raise an Exception if not. The test was
done without the '===' operator, and if the data is 0 bytes long the
error message says there is a permission error, which is false.

A data 0 bytes long is another issue, either in the json_encode function
either in the Bridge, but not a permission issue.
2016-11-09 02:11:22 +01:00
logmanoriginal 82ed2c5ffb [FileCache] Change output format to JSON
JSON format does not serialize object instances, which we don't
want anyways, and improves readability. The hashing algorithm
changed to md5 to prevent collisions with existing cache files
2016-10-16 11:15:11 +02:00
logmanoriginal 5c309e93dc [cache] Specify cache duration for 'purgeCache' 2016-10-08 16:18:10 +02:00
logmanoriginal 2d56b717cf [FileCache] Add property to define cache folder 2016-10-08 16:03:08 +02:00
logmanoriginal 5639b158e7 [FileCache] Change parameters to lower-case
This prevents creating multiple cache files for the same request.
2016-10-08 15:34:19 +02:00