Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
While running PHP compatibility sniffs on feeds I encountered:
FILE: /sites/all/modules/feeds/mappers/file.inc
---------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------------
193 | WARNING | Targeting a 'switch' control structure with a 'continue' statement is strongly discouraged and will throw a warning
| | as of PHP 7.3.
---------------------------------------------------------------------------------------------------------------------------------------
After reading https://wiki.php.net/rfc/continue_on_switch_deprecation I realized that this might point to a subtle bug if the author was attempting to achieve the behavior of continue 2
.
Thought I'd raise this here for consideration by someone more familiar with this code.
Comment | File | Size | Author |
---|---|---|---|
#15 | feeds-PHPCompatibility-3013743_fixed.PNG | 36.95 KB | Karishma Rawat |
#12 | feeds-php73-3013743-12-d7.patch | 401 bytes | VladimirAus |
Comments
Comment #2
bwood CreditAttribution: bwood as a volunteer commentedComment #3
ansergeyg CreditAttribution: ansergeyg commentedAs far as I understood from the example here:
https://wiki.php.net/rfc/continue_on_switch_deprecation
continue 2 is targeting not the closest looping structure but the second closest.
in our case we have this structure:
By default the documentation says:
https://www.php.net/manual/en/control-structures.continue.php
In our case the continue statement has no parameters set. It means it behaves as a break statement.
But it also means we have two break statements in one case block.
So I just removed the continue statement because according to the experiments with try/catch block in the loop provided here:
https://stackoverflow.com/questions/4673483/php-try-catch-block-inside-loop
Catch block suppresses the interruption thrown by an exception and the code
continues to execute and gets to the last break statement.
So there is only
$delta++;
After the switch code. There is a possibility that delta can be counted differently, but I suppose removing the continue will not affect the delta.
Comment #4
mradcliffeI set the issue to Needs review since there is a patch posted for review, and added a test run for 7.x-2.x-dev on PHP 7.2.
I haven't looked at the patch, but will try to test it out manually on a site soon.
Comment #5
blackbull77 CreditAttribution: blackbull77 commentedHas there been any news on if the patch is ok to use?
Comment #6
wylbur CreditAttribution: wylbur commentedWe tested this today on a D7 site with the following config:
drupal 7.69
Feeds 7.x-2.0-beta4
PHP 7.3
When running cron via drush, feeds module is fired, and produced errors in the terminal
Applying the patch #3 resolved the errors.
Also note that we received no errors in the watchdog logs about this error.
Tagging this issue as PHP 7.3, and set to RBTC, but if others find this issue please test!
Comment #7
mradcliffeIt looks like the test failures in the patch are the same test failures in HEAD for this module.
Comment #8
MegaChriz CreditAttribution: MegaChriz as a volunteer commented@mradcliffe
Yes, apparently something changed recently in the Link module that causes tests to fail. I haven't looked into it yet, cause I've other Feeds issues I'd like to finalize first.
Comment #9
wylbur CreditAttribution: wylbur commentedComment #10
MegaChriz CreditAttribution: MegaChriz as a volunteer commented@mradcliffe
Branch tests are passing again: #3113851: Fix failing test FeedsMapperLinkTestCase::testLinkFieldValidation()..
Comment #11
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedClosed #3115098: PHP 7.3 related: Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2" as a duplicate. Therefore changing title to make this issue hopefully better findable.
Comment #12
VladimirAusJust rerolling the patch to match latest codebase.
Comment #13
VladimirAusSorry. Ended up producing the same patch :/
Comment #14
Karishma Rawat CreditAttribution: Karishma Rawat at TATA Consultancy Services for Pfizer, Inc. commentedComment #15
Karishma Rawat CreditAttribution: Karishma Rawat at TATA Consultancy Services for Pfizer, Inc. commentedPatch #3 works for me and resolved my PHP Compatibility warning.Please find the screenshot for the same.
Comment #16
Karishma Rawat CreditAttribution: Karishma Rawat at TATA Consultancy Services for Pfizer, Inc. commentedComment #17
joelpittetRTBC++
Comment #18
MegaChriz CreditAttribution: MegaChriz as a volunteer commented@joelpittet
Yes, I really should try to find time to get the D7 version of Feeds compatible with recent PHP versions.
Comment #19
joelpittet@MegaChriz if you're interested I don't mind doing light maintenance on D7 if you'd like to keep your focus on D8? Feel free to add me to the project (let me know if you'd like a formal request in a ticket).
Comment #20
MegaChriz CreditAttribution: MegaChriz as a volunteer commented@joelpittet
I've given you commit access :). Thanks for your support.
Comment #22
joelpittetGreat thanks @MegaChriz! I've committed this and credited