feediron / ttrss_plugin-feediron

Evolution of ttrss_plugin-af_feedmod
https://discourse.tt-rss.org/t/plugin-update-feediron-v1-2-0/2018
MIT License
206 stars 34 forks source link

"spl_autoload_register" causes warnings in ttrss system log #148

Closed iWantToKeepAnon closed 4 years ago

iWantToKeepAnon commented 4 years ago

Prerequisites

Expected Behavior

Non error/warning integration into tt-rss, playing friendly with other plugins.

Current Behavior

Feediron is placing a warning into tt-rss system log every time {myPlugin} (named redacted) uses "class_exists" due to (AFAICT) "spl_autoload_register".

Steps to Reproduce

I have a personal plugin that I have not yet released, it exectues: if (class_exists($className)) {…}

and feediron enters a warning into the tt-rss system log:

include(): Failed opening 'filters/{myClass}/init.php' for inclusion (include_path='/.../ttrss/...')
1. plugins.local/feediron/init.php(14): ttrss_error_handler(2, include(): Failed opening 'filters/{myClass}/init.php' for inclusion (include_path='...'), plugins.local/feediron/init.php, 14, Array)
2. plugins.local/feediron/init.php(14): include()
3. plugins.local/{myPlugin}/init.php(26): class_exists({myClass})
4. plugins.local/{myPlugin}/init.php(49): {myFunction)(…)
5. classes/rssutils.php(345): hook_fetch_feed(...)
6. classes/feeds.php(840): update_rss_feed(...)

You can see that execution jumps from {myPlugin} to feediron init.php(14). Can the "spl_autoload_register" function be limited to code in feediron's scope?

Failure Information (for bugs)

Not sure this is a full blown bug, but definitely a feature. I am kind of surprised that the ttrss codebase doesn't trigger these warnings when it uses class_exists. I skipped autoloading code by changing my call to class_exists($className, false) and that fixes the warnings, but that shouldn't be necessary. Right?

I am not a php expert, am I missing something obvious?

Context

dugite-code commented 4 years ago

Unfortunately I've not been able to use namespaces in FeedIron, I believe that would be the ideal way to address the issue. It's not a major issue per-say, it's just the auto-loader going through the registered sequence. It wouldn't show normally in TTRSS as it's only loaded during the article filter process, hence why it appears to interfere with your plugin.

I've added some fixes in defaults-dev that should address this issue

iWantToKeepAnon commented 4 years ago

Perfect, thanks for a quick turn around! : ))