-
Notifications
You must be signed in to change notification settings - Fork 22
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
PHP8.0 compatibility patch #32
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped some notes, In overall good work!
7692726
to
69bed7b
Compare
Finally got around to reworking that history. Let's see how Travis feels about it :) |
Everything checks out except for that one thing in Zend_Log_Writer_AbstractTest with PHP5.4 which also only occurs if you run the full suite. All three tests pass if you run that thing manually. |
@falkenhawk Do you want me to put a guard in for that specific case so we can have pretty green arrows? |
packages/zend-loader/library/Zend/Loader/ClassMapAutoloader.php
Outdated
Show resolved
Hide resolved
$iterator = $this->stack->getIterator(); | ||
$this->assertEquals('Zend_Controller_Action_Helper_Redirector', get_class(current($iterator))); | ||
next($iterator); | ||
$this->assertEquals('Zend_Controller_Action_Helper_ViewRenderer', get_class(current($iterator))); | ||
$iterator = $this->stack->getIterator()->getIterator(); | ||
$this->assertEquals('Zend_Controller_Action_Helper_Redirector', get_class($iterator->current())); | ||
$iterator->next(); | ||
$this->assertEquals('Zend_Controller_Action_Helper_ViewRenderer', get_class($iterator->current())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does php8 throw on calling current()
/ next()
on an iterator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It retuns false and thus get_class throws a TypeError
if (stristr($e->getMessage(), 'undefined constant')) { | ||
$this->markTestSkipped(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which case this the db factory throws this undefined constant
error? What kind of constants were missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DB2 constants
$options['filters'] = array( | ||
array('Digits', array('bar' => 'baz')), | ||
array('Alnum', array('allowWhiteSpace' => true)), | ||
array('Alpha', array('foo')), | ||
); | ||
$this->element->setOptions($options); | ||
$filter = $this->element->getFilter('Digits'); | ||
$this->assertTrue($filter instanceof Zend_Filter_Digits); | ||
$filter = $this->element->getFilter('Alnum'); | ||
$this->assertTrue($filter instanceof Zend_Filter_Alnum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the behavior of this tests has changed. Could you comment on why, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behaviour hasn't really changed because the intent of the test is to use an array of arrays in setOptions
. What has changed is that PHP8 supports calling functions with named parameters and will throw a Fatal if you try to access a parameter by name that does not exist. Digits::__construct
has no param named bar ergo we get a Fatal.
I could add a version switch but that wouldn't make the test any more meaningful.
} catch (Exception $e) { | ||
$this->assertTrue($e instanceof Zend_Log_Exception); | ||
$this->assertRegExp('/not a stream/i', $e->getMessage()); | ||
} catch (TypeError $e) { | ||
$this->assertRegExp('/must be of t/i', $e->getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about the adjustments here. Were these TypeError
, ValueError
triggered as regular errors in PHP <8 or were they simply non-errors before and now PHP 8 is more strict? If that's the case, is it okay that PHP8 will throw such errors instead of the php <8 shrug-and-proceed behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually where I added Error catches the behaviour in <8 was to emit a warning or fail silently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I guess it is fine in case of this component - when something is wrong with internals of this stream thing, it should throw
@Megatherium I will try to run php5.4 test suite locally to see if I can figure out why it fails |
#35 created a separate issue, so it can be worked independently of this PR. |
As this branch does not contain the major fixes for PHP8 ( cf. zf1s#32) the tests will abort with a fatal. Thus Travis has beeb allowed to fail for PHP8.
As this branch does not contain the major fixes for PHP8 ( cf. zf1s#32) the tests will abort with a fatal. Thus Travis has beeb allowed to fail for PHP8.
So, next step: Rebase this to master, add 8.0 to Github actions, disallow failure for 8.0 on Travis. Correct? |
14a9170
to
da24d0a
Compare
I don't really get why that test bails all of the sudden in 5.4. As far as I can tell I haven't touched any file involved in that test. Also that test is supposed to cause an error which PHPUnit should handle... I'm confused. |
mainly backported from zf1s/zf1#32 PR by @Megatherium
Because the return values of iconv_substr changed in PHP8 calling Zend_Date::set could lead to TypeError
@falkenhawk @Megatherium seems this is stalled again. Is there any interest, I could cherry-pick commits related from here to separate PRs? So the changeset could be merged individually, not depending on the "big approval". I need confirmation, so I won't end up doing unwanted work. |
@glensc thanks for stepping up. I believe there is lots of interest, but I guess we all might be constrained by the regular job responsibilities or other stuff. As much as I would like to have it done, I can't merge it yet when there are tests failing. I would also love to jump in and help but I am afraid I can't do at the moment. Is that failing test due to the issue with iconv the only thing left to be sorted out here? If you have an idea how to fix it then perhaps could you either rebase or merge from master and push a fix? 🙏 Please coordinate with @Megatherium if possible so that work is not doubled, perhaps Alex has some work not pushed yet. |
The thing is I believe the test setup and not the code to be wrong. I know this is basically like claiming a compiler bug but iconv is an external resource and I didn't have my little grubby hands anywhere near the failing code. tl;dr: I currently don't know how to give all green check marks. |
@falkenhawk @Megatherium I proposed to extract all changes that are ok to a separate PR. I would not be interested in fixing actual bugs right now. I would like to receive the clear Go Ahead signal. Or would you @Megatherium want to do that yourself? |
@glensc please do 🙏 |
@glensc Please do. Maybe by chopping this stuff up it'll help me to narrow down the source of the remaining problems. |
Created 14 PR's as can see from the web: The last one seems to have issues, probably depends on the change that went to some other pr: or it could be just a flaky test. |
Closing in favor of multitude of PRs from @glensc . Thank you both! |
Some of the more common things that needed be fixed were:
A lot of times where PHP used to emit a warning (or even nothing) we
now get Type- and ValueErrors which either need to be prevented by
intializing or casting variables or catching the error.
file_exists will error out if you feed it NULL bytes. This needed to
be circumvented
optional parameters need to come after required params, thus some
default values had to be removed from method signatures and workarounds
put in place
some reflection methods like isArray have become deprecated and are
only called conditionally going forward
libxml_disable_entity_loader has been deprecated and is only called
conditionally