Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Fix call to method not in ExpressionInterface #7292

Closed
wants to merge 5 commits into from
Closed

Fix call to method not in ExpressionInterface #7292

wants to merge 5 commits into from

Conversation

marcelto
Copy link
Contributor

@marcelto marcelto commented Mar 4, 2015

The ExpressionInterface does not have the method getExpression

The ExpressionInterface does not have the method getExpression
@weierophinney
Copy link
Member

@marcelto Can you please provide a unit test that would hit this particular condition?

@marcelto
Copy link
Contributor Author

Ok,the test case has been added. I ended up changing Select::processJoins a bit more for the test case though.

$joinName = $joinName->getExpression();
} elseif ($joinName instanceof TableIdentifier) {
$joinName = $joinName->getTableAndSchema();
$joinName = ($joinName[1] ? $platform->quoteIdentifier($joinName[1]) . $platform->getIdentifierSeparator() : '') . $platform->quoteIdentifier($joinName[0]);
} elseif ($joinName instanceof Select) {
$joinName = '(' . $this->processSubSelect($joinName, $platform, $driver, $parameterContainer) . ')';
} elseif (is_string($joinName) || (is_object($joinName) && method_exists($joinName, '__toString'))) {

Choose a reason for hiding this comment

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

Use is_callable() instead of method_exists().

Copy link
Contributor

Choose a reason for hiding this comment

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

Can the magic method __toString be something else than public?

Copy link
Member

Choose a reason for hiding this comment

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

Updated to is_callable(array($joinName, '__toString')) during merge.

@marcelto
Copy link
Contributor Author

So it seems it can be but it shouldn't be anything but public. Using php 5.5 a simple test script shows that __toString will return a string in an echo as a protected or private method, however, a warning will be thrown. Using is_callable seems good to me but I defer to you.

Warning: The magic method __toString() must have public visibility and cannot be static in toStringTest.php on line 16


Warning: The magic method __toString() must have public visibility and cannot be static in toStringTest.php on line 26

I am an A string
I am a B string
I am a C string


A::__toString (public) is callable
B::__toString (protected) is not callable
C::__toString (private) is not callable

weierophinney added a commit that referenced this pull request Mar 17, 2015
Fix call to method not in ExpressionInterface

Conflicts:
	library/Zend/Db/Sql/Select.php
weierophinney added a commit that referenced this pull request Mar 17, 2015
@weierophinney
Copy link
Member

Merged to develop for release with 2.4.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants