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

Fixes PHP 8 compatibility issues. #4613

Merged
merged 20 commits into from Apr 29, 2023
Merged

Fixes PHP 8 compatibility issues. #4613

merged 20 commits into from Apr 29, 2023

Conversation

yuliu
Copy link
Member

@yuliu yuliu commented Dec 17, 2022

  1. The issue for tracking: Fix PHP 8 compatibility issues since version 1.8.31 #4593.
  2. The message of each commit explains what it fixes (the PHP 8 compatibility issue).
  3. The PR includes fixes for issues reported in undefined variable $usersbrowsing in eval()'d code (92) in ./showthread.php(1617). #4602.
  4. The PR includes fixes for some issues reported in Mark forum read doesn't work with php 8.0 #4530 (comment) . This one may be closed when the PR is merged, since other issues reported in it can't be reproduced.
  5. The PR doesn't fix all remaining PHP 8 compatibility issues. That means there are still more.
  6. Some more commits will be pushed later, before marking the PR as ready.

…ray key 0 in `inc/class_parser.php` (L1494, L1587).
 - Delayed moderation:
    - Undefined variable `$thread` in `moderation.php` (L423).
    - Trying to access array offset on value of type null in `moderation.php` (L423).

 - Soft delete thread(s):
    - Undefined array key "num_threads" in `inc/class_moderation.php` (L3798).
    - Undefined array key "num_threads" in `inc/class_moderation.php` (L3798).

 - Restore (soft-deleted) thread(s):
    - Undefined array key "num_threads" in `inc/class_moderation.php` (L3639).
    - Undefined array key "num_threads" in `inc/class_moderation.php` (L3639).

 - Move post(s):
    - Undefined variable `$return_url` in eval()'d code (L27) in `moderation.php` (L2669).

 - Moving post(s):
    - Undefined array key 1 in `moderation.php` (L2697).
@yuliu
Copy link
Member Author

yuliu commented Dec 18, 2022

In commit 6b2fa22

  • Move post(s):
    • Undefined variable $return_url in eval()'d code (L27) in moderation.php (L2669).

Note: not sure if the variable $return_url used in template moderation_inline_moveposts is truly needed.

 - Approve thread(s):
    - Undefined array key XXX in `inc/class_moderation.php` (L437).
    - Undefined array key "num_posts" in `inc/class_moderation.php` (L437).
    - Undefined array key "num_threads" in `inc/class_moderation.php` (L504).

 - Similarly, unapprove thread(s).
… UTF-8 Conversion:

 - Undefined array key "table" in `admin/modules/tools/system_health.php` (L441).
 - Undefined variable `$converting_table` in `admin/modules/tools/system_health.php` (L241).
 - Undefined variable `$fulltext_to_create` in `admin/modules/tools/system_health.php` (L360).
…, which results in PHP fatal error of uncaught TypeError: Argument #2 ($array) must be of type array, null given in `array_key_exists()` in `/inc/datahandler.php` (L207).
@yuliu
Copy link
Member Author

yuliu commented Dec 22, 2022

Remarks in commit 64e8476

  • $pm['saveasdraft'] and $pm['options']['XXX'] are added following how a pm is prepared in send_pm():

    mybb/inc/functions.php

    Lines 9079 to 9085 in c3c474a

    $pm['options'] = array(
    "disablesmilies" => 0,
    "savecopy" => 0,
    "readreceipt" => 0
    );
    $pm['saveasdraft'] = 0;
  • $pm['saveasdraft'] = 0 is optional because the default for this option is 0.
  • $pm['options']['signature'] is set to 0, given that the pms are to inform moderators/admins of a report.

…efinements in `send_pm()` in `inc/functions.php` (L9027).
@Eldenroot
Copy link
Contributor

Will be merged into 1.8.33?

…rify_sender()` in `inc/datahandlers/pm.php` (L149-L150), a workaround for mybb#4630 (comment) .
 - Undefined array key "pid" in `inc/datahandlers/warnings.php` (L687) when issuing a warning from user profile page, etc.
 - Undefined variable `$last_expired` in `warnings.php` (L238) when viewing a user's warnings for their specific post.
@dvz dvz added this to the 1.8.34 milestone Jan 3, 2023
…php` (L1213) and a typo in `inc/datahandlers/post.php` (L1228).
@yuliu
Copy link
Member Author

yuliu commented Jan 3, 2023

Remarks for commit 128f8ea

@yuliu
Copy link
Member Author

yuliu commented Jan 3, 2023

Remarks for commit b153eb7

  • The fixed typo here (canonlyviewownthread -> canonlyviewownthreads) doesn't fully resolve the PHP warning issue:

    Warning [2] Undefined array key "canonlyviewownthreads" - Line: 1228 - File: inc\datahandlers\post.php PHP 8.1.13
    
  • The real issue behind this typo fix is about getting forum permissions:

    • forum_permissions() which calls
    • fetch_forum_permissions() that may return a set of group permissions where relevant permissions are missing --- those only exist in forum permissions (stored in mybb_forumpermissions) but not usergroup permissions (in mybb_usergroups), e.g., canonlyviewownthreads, canonlyreplyownthreads, etc.

@yuliu yuliu marked this pull request as ready for review January 10, 2023 07:13
@yuliu
Copy link
Member Author

yuliu commented Jan 10, 2023

Since the code base is already in v1.8.33, while the PR is based on v1.8.32, it'll cost much more time to pinpoint recent reported issues.

More PHP 8 compatibility issues will be addressed in other PRs, and this one is marked as ready for review.

@yuliu
Copy link
Member Author

yuliu commented Feb 8, 2023

More issues relating to the video mycode parsing have been reported in https://community.mybb.com/thread-237617.html . I'll push some commits that'll cover these issues later, to this PR.

@kgraefe
Copy link

kgraefe commented Mar 16, 2023

Not sure if that's the right place, but I found some more in the admin panel of MyBB 1.8.33 that are not yet fixed, as far as I can tell from scanning through the PR:
mybb

This only happens when a view is selected that does not match any user.

Edit: You probably guessed it, but FTR: the error happens on PHP 8.0, 8.1 and 8.2. It does not occur on PHP 7.4.

@yuliu
Copy link
Member Author

yuliu commented Mar 25, 2023

Remarks for commit d0af363

  • The commit should have fixed all issues related to the parser reported in https://community.mybb.com/thread-237617.html .

  • The following line was removed as the variable $title isn't used in the video_metacafe_embed template or anywhere else in the parser class. The removal may affect plugins that rely on the variable.

    $title = htmlspecialchars_uni($path[3]);

  • Currently, the parser can't correctly deal with URLs with any number of continuous / in its path part. [REF]

@dvz dvz merged commit e4f184d into mybb:feature Apr 29, 2023
8 checks passed
@yuliu yuliu deleted the fix-4593-2 branch May 16, 2023 08:47
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

Successfully merging this pull request may close these issues.

None yet

4 participants