ophian / styx

Serendipity Styx Edition - Styx is what Serendipity should be!
https://ophian.github.io
7 stars 0 forks source link

Undefined array key "is_iframe" #31

Closed hbarel closed 2 years ago

hbarel commented 2 years ago

When saving a post, either newly created or edited, upon clicking "save", I get:

Warning: Undefined array key "is_iframe" in /var/www/html/include/plugin_api.inc.php: 93.

Any idea anyone?

ophian commented 2 years ago

Hi Hagai Are you sure you are using the Serendipity Styx Edition? You blog says you are still on S9y origin. Styx has gone far beyond that! And I would recommend using it since it helps you solving issues you once had. ;-) In either case that should be easy to solve by adding an isset($_GET['serendipity']['is_iframe']) &&

if (serendipity_db_bool($serendipity['use_autosave']) && isset($_GET['serendipity']['is_iframe']) && $_GET['serendipity']['is_iframe'] == 'true' && $_GET['serendipity']['iframe_mode'] == 'save') {

If that helps, I`ll add this to the Styx code. Thanks.

Edit: But it as well be a matter of mixing old with new installations... so either Styx and latest Styx freetag plugin (and/or 2k11 ??) or not. Since I do not get this, are you using the autosave feature? Styx has turned this off by default, since that feature issues problems in my eyes.

hbarel commented 2 years ago

Hi Ophian,

Thank you for the explanation and for helping me try to debug this.

Indeed, I am trying to migrate into Styx... You cannot see this because I run this on a staging environment, not the production one.

I downloaded Styx from scratch, used another table prefix on the database, so essentially no remenances of s9y. I installed the 2k11 template for the frontend, and ran an import of the s9y set through the import process (under "maintenance"). The import process threw many warnings, but did the job!

However, editing any post still raises this error.

I also noticed that installing the markdown plugin causes the error:

Warning: Undefined variable $mdv in /var/www/html/plugins/serendipity_event_markdown/serendipity_event_markdown.php: 157.

with no page being displayed, and the Spamblock (Bayes) plugin breaks the Comment page (so nothing appears). The Apache log reads:

PHP Fatal error: Uncaught Error: Call to undefined function b8\\degenerator\\mb_strtolower() in /var/www/html/plugins/serendipity_event_spamblock_bayes/b8/degenerator/standard.php:126

Before going through this experiment, I tried just installing Styx from scratch but used the existing s9y database (and table prefix). It worked well when it comes to having all my posts without needing to import, but had the same problems I mentioned, which caused me to try this installation from scratch.

hbarel commented 2 years ago

Last note: an installation with a new table prefix, without installing 2k11 or any other theme or plugin yields the following error upon save of a post:

Warning: Undefined array key "wysiwyg" in /var/www/html/include/functions_entries_admin.inc.php: 145.

(This warning does not prevent saving, but it appears as soon as the UI for editing a post appears, also before saving.)

Not sure if anyone else spotted that, and if not, what's so special about me...

ophian commented 2 years ago

I also noticed that installing the markdown plugin causes the error:

Warning: Undefined variable $mdv in /var/www/html/plugins/serendipity_event_markdown/serendipity_event_markdown.php: 157.

Oh yes, sorry! That was me. I had removed the old markdown lib in July and forgot some conditionals. Plugin markdown v.1.35 is available online. Thanks for the hint.

ophian commented 2 years ago

the Spamblock (Bayes) plugin breaks the Comment page (so nothing appears). The Apache log reads:

PHP Fatal error: Uncaught Error: Call to undefined function b8\\degenerator\\mb_strtolower() in /var/www/html/plugins/serendipity_event_spamblock_bayes/b8/degenerator/standard.php:126

This is strange. The lib is calling a PHP mb_strtolower() (standard) method. At least up with PHP 8 it should be a standard. Please check, if your PHP version has the mb_* methods enabled by including the mbstring extension module. You will need this everywhere! The strange thing is the error announcing it in the b8\degenerator\ namespace... B8 might as well be a little outdated. Just for the record. After many years of experience I can recall that using spamblock bayes is overkill. All you need is spamblock bee and spamblock (default) in this order.

ophian commented 2 years ago

Last note: an installation with a new table prefix, without installing 2k11 or any other theme or plugin yields the following error upon save of a post:

Warning: Undefined array key "wysiwyg" in /var/www/html/include/functions_entries_admin.inc.php: 145.

(This warning does not prevent saving, but it appears as soon as the UI for editing a post appears, also before saving.)

Not sure if anyone else spotted that, and if not, what's so special about me...

Good find! 😀 This is completely useless and outdated on Styx. See 24a2070ec70c7fa04b234e5e9a1dd0bcb289a623 on what to remove.

ophian commented 2 years ago

I downloaded Styx from scratch, used another table prefix on the database, so essentially no remenances of s9y. I installed the 2k11 template for the frontend, and ran an import of the s9y set through the import process (under "maintenance"). The import process threw many warnings, but did the job!

You did not catch and save these warnings, did you? Did you read the Serendipity importer "More" button info(rmation)? As it says: This is NOT an importer meant for upgrading Serendipity. This importer assumes that both Serendipity installations use the same version.

However, editing any post still raises this error.

Did you add the isset as advised? See e70abe35ff5910c0aa9f353f6ee69da80d83706f

ophian commented 2 years ago

Not sure if anyone else spotted that, and if not, what's so special about me...

Security engineer? 😁 I myself am running Styx in ultra debugging mode and have never seen this. So Thanks! One of the main differences between S9y origin and Styx is that I try not to hide these warnings so we can fix them alltogether. This was a lot of work but brought better understanding, better code and lots of improving fixes!

hbarel commented 2 years ago

I also noticed that installing the markdown plugin causes the error: Warning: Undefined variable $mdv in /var/www/html/plugins/serendipity_event_markdown/serendipity_event_markdown.php: 157.

Oh yes, sorry! That was me. I had removed the old markdown lib in July and forgot some conditionals. Plugin markdown v.1.35 is available online. Thanks for the hint.

Thanks! Resolved, indeed.

hbarel commented 2 years ago

the Spamblock (Bayes) plugin breaks the Comment page (so nothing appears). The Apache log reads: PHP Fatal error: Uncaught Error: Call to undefined function b8\\degenerator\\mb_strtolower() in /var/www/html/plugins/serendipity_event_spamblock_bayes/b8/degenerator/standard.php:126

This is strange. The lib is calling a PHP mb_strtolower() (standard) method. At least up with PHP 8 it should be a standard. Please check, if your PHP version has the mb_* methods enabled by including the mbstring extension module. You will need this everywhere! The strange thing is the error announcing it in the b8\degenerator\ namespace... B8 might as well be a little outdated.

My bad... The staging server was missing mbstring... Sorry.

Now Spamblock (Bayes) does not prevent comments from being displayed, but it's own interface still complains:

Warning: Trying to access array offset on value of type bool in /var/www/html/plugins/serendipity_event_spamblock_bayes/serendipity_event_spamblock_bayes.php: 439.

Warning: Undefined array key "serendipityBaseUrl" in /var/www/html/templates_c/...

Warning: Attempt to read property "value" on null in /var/www/html/templates_c...

Maybe this is not related.

Just for the record. After many years of experience I can recall that using spamblock bayes is overkill. All you need is spamblock bee and spamblock (default) in this order.

Actually, I tend to agree. The other two plugins do good enough job to make Bayes not even have enough samples for proper training. I actually have a separate script that runs with cron once in a while, goes over the logs of the two plugins, finds the offenders and blocks them with iptables... I saw there is a similar feature with .htaccess but haven't tested it yet...

ophian commented 2 years ago

Now Spamblock (Bayes) does not prevent comments from being displayed, but it's own interface still complains:

Warning: Trying to access array offset on value of type bool in /var/www/html/plugins/serendipity_event_spamblock_bayes/serendipity_event_spamblock_bayes.php: 439.

Do you actually have a (dbPrefix)_spamblock_bayes_recycler table? Update for the recycler check is online. You get a fresh xml plugin sync when saving the Spartacus plugin configuration once.

ophian commented 2 years ago

I actually have a separate script that runs with cron once in a while, goes over the logs of the two plugins, finds the offenders and blocks them with iptables... I saw there is a similar feature with .htaccess but haven't tested it yet...

ip/netfilter is the better option if really in need for this.

hbarel commented 2 years ago

I downloaded Styx from scratch, used another table prefix on the database, so essentially no remenances of s9y. I installed the 2k11 template for the frontend, and ran an import of the s9y set through the import process (under "maintenance"). The import process threw many warnings, but did the job!

You did not catch and save these warnings, did you?

No, but I will repeat the process and take note next time. I'm not sure I will use the import in Production, however, since it does not bring in static pages and tag associations, which are quite a few... (I know this is specified in the documentation; no complaints!)

Did you read the Serendipity importer "More" button info(rmation)? As it says: This is NOT an importer meant for upgrading Serendipity. This importer assumes that both Serendipity installations use the same version.

I was not sure how to match the s9y and styx versions... The import was from s9y 2.4beta1.

However, editing any post still raises this error.

Did you add the isset as advised? See e70abe3

I now did, and it indeed removed the error, thanks!

hbarel commented 2 years ago

One of the main differences between S9y origin and Styx is that I try not to hide these warnings so we can fix them alltogether. This was a lot of work but brought better understanding, better code and lots of improving fixes!

I think this is a good engineering practice. Sometimes I see the PHP warnings in Apache's log file and wonder how the tool even works at all... :-)

ophian commented 2 years ago

Well, warnings and notices are just what they are. They say: Do anything about them, but notice they may break your system one future day. ;-)

ophian commented 2 years ago

If you still get these two templace_c warnings after the bayes upgrade, we could find a way to avoid them too.

For the migration. You could either save your old db with phpmyadmin. edit the sql file to remove or disable the table creations and then push the whole or partitially (for entries and its relations, staticpages and so on...) to your new database, or use the old one (if it is not so much fragmented or so.., and is already utf8mb4 ready, which might be the case when 2.4-beta has migrated this to mysql :: InnoDB properly. I can't say this in every case, but that should do generally, I assume.

hbarel commented 2 years ago

Thanks a lot Ophian,

If you still get these two templace_c warnings after the bayes upgrade, we could find a way to avoid them too.

Thanks, I wouldn't worry about it if it's just me.

For the migration. You could either save your old db with phpmyadmin. edit the sql file to remove or disable the table creations and then push the whole or partitially (for entries and its relations, staticpages and so on...) to your new database, or use the old one (if it is not so much fragmented or so.., and is already utf8mb4 ready, which might be the case when 2.4-beta has migrated this to mysql :: InnoDB properly. I can't say this in every case, but that should do generally, I assume.

Thanks. What seems to work well for me is just using the same database. So far there were no additional side-effects. I will test it thoroughly during the next few days...

ophian commented 2 years ago

Great! Have fun with Styx. I'll close this issue so far and await your test results. We can continue in here regardless.

ophian commented 2 years ago

Now Spamblock (Bayes) does not prevent comments from being displayed, but it's own interface still complains: Warning: Trying to access array offset on value of type bool in /var/www/html/plugins/serendipity_event_spamblock_bayes/serendipity_event_spamblock_bayes.php: 439.

Do you actually have a (dbPrefix)_spamblock_bayes_recycler table?

Could you check this please. I think I found a bigger issue.

ophian commented 2 years ago

I pushed out bayes 2.8.0 because of this... which also fixes the templates_c Smarty variable errors :-)

hbarel commented 2 years ago

Thanks!

I upgraded the plugin (actually, I removed and re-installed it), and indeed there are no warnings on the Bayes UI. That said, when one tries to open the "comments" page, or use the contact form (of the contact form plugin), execution breaks with the following error on the log file:

PHP Fatal error: Uncaught mysqli_sql_exception: Table 'serendb.my_blog_b8_wordlist' doesn't exist in ...

ophian commented 2 years ago

Well in this case uninstall left your tables. Uninstall again and drop the table b8_wordlist and (prefix)_spamblock_bayes_recycler, before you install again. That should do (hopefully).

ophian commented 2 years ago

I tried to create, configure and fill the b8_wordlist table on installation/access and afterwards rename it to have the dbPrefix too. Then set a plugin config db_built variable. Something went wrong on this way. But I tested it with existing bayes installations and the upgrade worked. But you are right. I rechecked and the comments page dies into white. I'll have to rework that tomorrow.

hbarel commented 2 years ago

At any time of your convenience please note that even with Bayes plugin disabled, the use of the Contract Form returns (in the log) the following error:

PHP Fatal error: Uncaught mysqli_sql_exception: Table 'serendb.my_blog_delayed_trackbacks' doesn't exist

ophian commented 2 years ago

But you are right. I rechecked and the comments page dies into white. I'll have to rework that tomorrow.

Fixed in bayes 2.8.1. Thanks and sorry for the extra round.

ophian commented 2 years ago

At any time of your convenience please note that even with Bayes plugin disabled, the use of the Contract Form returns (in the log) the following error:

PHP Fatal error: Uncaught mysqli_sql_exception: Table 'serendb.my_blog_delayed_trackbacks' doesn't exist

What do you mean by Contract Form? The Contact Form or the entry forms? The delayed_trackback table is part of the event_trackback plugin. On install (with clean configs) it installs the table and checks upgradeCheck on several trackback tasks to have the db_upgrade (built) variable 3. So I assume you already have that in your config table in something like name is serendipity_event_trackback:...hash4t4tz4tz4t4t4t.../db_upgrade. Re-Set it to 2 and run ... hmmm ... (I assume, save an entry which is not draft, when you have the plugins delayed trackbacks variable set to true (yes)).

I checked all my installations with this plugn and found no issue with not having that table, so it must be something specific to your install, if I haven't overseen a break. But I can easily raise the db_upgrade variable for an upgrade to catch all others which might not have it. Not sure what to do better here...

ophian commented 2 years ago

Actually I decided to update the plugin to raise the variable. So you don't need to to any other than upgrade (hopefully).

ophian commented 2 years ago

And another fix in 1.34, solving the existing db check for upgrade. Without me setting up MYSQLI_SQL_EXCEPTIONS and PHP 8+ we would not have all these benefits. It wonders how they ever worked... ;-)

hbarel commented 2 years ago

But you are right. I rechecked and the comments page dies into white. I'll have to rework that tomorrow.

Fixed in bayes 2.8.1. Thanks and sorry for the extra round.

Fixed indeed! Thank you. (I personally will probably take your advise of not using Bayes, but I'm sure there are sites with heavier loads which will find it essential.)

hbarel commented 2 years ago

Actually I decided to update the plugin to raise the variable. So you don't need to to any other than upgrade (hopefully).

Thanks! Indeed, I was referring to the Contact Form; pardon the typo... At this point, when one uses the form, it emits the warning from Spamblock Bee:

Warning: Undefined array key "title" in /var/www/html/plugins/serendipity_event_spamblock_bee/serendipity_event_spamblock_bee.php: 499.

(Truthfully, I was not even aware that contact form submissions go through spamblock-bee at all...)

ophian commented 2 years ago

They go through spamblock and therefore through bee since that is an extend of spamblock.

I noted above this check

// AntiSpam check, the general spamblock supports, too: Only if spamblock is not installed. [ NOT recommended ! ]

So... did you eventually remove spamblock? You should NOT do this. It is the main and essentiell core plugin against spam. All other spamblock plugins need its features. After having cleared if you have it or not and probably have restored it - do you still get this title warning?

hbarel commented 2 years ago

Oops... I did not even notice I removed it; It was during one of the experiments. Apologies.

Once re-installing and re-configuring it, however, I noted that filtering by comment e-mail addresses causes an error (when viewing the comments):

Warning: preg_match(): Unknown modifier ...

For just about any regexp e-mail you put there, such as: test\@test\.com.

ophian commented 2 years ago

BTW, What the heck did you do to get all these warning etc... I am happy you did, but did you force error handling anyhow? Or is it just PHP 8.1?

Oh great. I'll try to figure that out... I also updated the bee.

hbarel commented 2 years ago

Just a (relatively) clean machine with PHP 8.1.9....

Are you debugging it all by yourself? What happened to all the good old s9y people?

ophian commented 2 years ago

yepp! (They left into LIFE!)

hbarel commented 2 years ago

Wow... So is that end of s9y as we know it? 2.4beta1 to be stuck forever? :-)

ophian commented 2 years ago

I don't know. I innerly left end of 2015 (see https://ophian.github.io/ for reasons) and started Styx after migration in 2016.

hbarel commented 2 years ago

Well, I'm happy you did! I guess the users should hope that you do not also get tired of this... :-) I used b2evo for many years, and moved on when that project was discontinued; wasn't an easy task at all...

ophian commented 2 years ago

😊

ophian commented 2 years ago

Now back to serious issues. Thanks to you I catched this odd preg_match behaviour. Never use preg_quote for preg_match! See e408f7d67c8b502b62a1bd28c020c7bef82febe2 on how to fix!

hbarel commented 2 years ago

Thanks!