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

[ticket/16696] Fix unsupported operand types in viewforum - PHP8 #6135

Merged
merged 1 commit into from Feb 5, 2021
Merged

[ticket/16696] Fix unsupported operand types in viewforum - PHP8 #6135

merged 1 commit into from Feb 5, 2021

Conversation

3D-I
Copy link
Contributor

@3D-I 3D-I commented Feb 2, 2021

PHPBB3-16696

Checklist:

  • Correct branch: master for new features; 3.3.x for fixes
  • Tests pass
  • Code follows coding guidelines: master and 3.3.x
  • Commit follows commit message format

https://tracker.phpbb.com/browse/PHPBB3-16696

@3D-I 3D-I changed the title [ticket/16696] Unsupported operand types in viewforum.php - PHP8 [ticket/16696] Fix unsupported operand types in viewforum - PHP8 Feb 2, 2021
@@ -1027,7 +1027,7 @@

$template->assign_block_vars('topicrow', $topic_row);

$pagination->generate_template_pagination($topic_row['U_VIEW_TOPIC'], 'topicrow.pagination', 'start', $topic_row['REPLIES'] + 1, $config['posts_per_page'], 1, true, true);
$pagination->generate_template_pagination($topic_row['U_VIEW_TOPIC'], 'topicrow.pagination', 'start', (int) $topic_row['REPLIES'] + 1, $config['posts_per_page'], 1, true, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the underlying problem here exactly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is related to extensions that use the core.viewforum_modify_topicrow event.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen that. My question is why is this necessary? I would have assumed + implicitly casts anyway. Is that not the case?

Copy link
Contributor Author

@3D-I 3D-I Feb 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, is not the case. It breaks in php 7 and PHP 8 is more explicit: unsupported operand types

I will provide a code example where you can see it in action later on.
The real issue is where the PR which caused this BC regression has been merged, anyway this simple fix solves the issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover, there are potentially a lot of extensions which can break via that PR.
https://github.com/search?q=core.viewforum_modify_topicrow&type=code
My first impression it was to revert that PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that extension authors have been using a value that was initially an integer value to change it to strings. As a result of that, casting to int would get rid of the warning but still somewhat has a potential of ending up with weird output. Anyway, weird output is still better than PHP warnings being output.

@marc1706 marc1706 added this to the 3.3.4 milestone Feb 5, 2021
@marc1706 marc1706 merged commit bb8768b into phpbb:3.3.x Feb 5, 2021
@3D-I 3D-I deleted the ticket/16696 branch February 5, 2021 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants