chemistry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steven Harding (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CMIS-768) CMISService::getLink doesn't check that link exists in link cache, only that link cache exists
Date Tue, 31 May 2016 01:16:12 GMT

    [ https://issues.apache.org/jira/browse/CMIS-768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15307056#comment-15307056
] 

Steven Harding commented on CMIS-768:
-------------------------------------

There's not a lot of error checking like this anywhere in the application, unfortunately.
It should either return an empty string or raise an exception so that the calling code can
handle it. 

I've found this problem is a particular issue when dealing with search results, as per my
bug report CMIS-981. In this case, search results don't actually have any links, but the library
caches them as if they did. This means that when you then do any calls that use the 'getLinks'
function, they fail with the same error message you're experiencing.

The code would be even better if it checked for the link count - for example...

Replace...

if (isset($this->_link_cache[$objectId][$linkName]))

with...

if ((isset($this->_link_cache[$objectId][$linkName])) && (count($this->_link_cache[$objectId][$linkName])
> 0))

This will make the library fetch the links for any object that doesn't have any, such as search
results. If it STILL fails, your changes will catch the issue. 

> CMISService::getLink doesn't check that link exists in link cache, only that link cache
exists
> ----------------------------------------------------------------------------------------------
>
>                 Key: CMIS-768
>                 URL: https://issues.apache.org/jira/browse/CMIS-768
>             Project: Chemistry
>          Issue Type: Bug
>          Components: cmis-phplib
>    Affects Versions: PHPCMIS 0.2
>         Environment: PHP 5.3.10-1ubuntu3.10 with Suhosin-Patch
>            Reporter: Seth Yastrov
>
> I am using phpclient 0.2.0-RC1 installed in a Drupal 7 installation.
> I receive the following PHP error when trying to synchronize CMIS nodes to Drupal:
> "Notice: Undefined index: edit-media in CMISService->getLink() (line 263 of /var/www/jh/cmis/cmis_service.php)."
> It appears that the code for getLink, at line 261 of cmis/cmis_service.php doesn't check
that the key $linkName exists in the $this->_link_cache, before returning it:
> {code}
> 	function getLink($objectId, $linkName) {
> 		if (array_key_exists($objectId, $this->_link_cache)) {
>           return $this->_link_cache[$objectId][$linkName];
>         }
> 		$obj = $this->getObject($objectId);
> 		return $obj->links[$linkName];
> 	}
> {code}
> The function should check if that key exists in the _link_cache and if not, call getObject()
before returning the value.
> So the code should look something like this:
> {code}
> 	function getLink($objectId, $linkName) {
> 		if (array_key_exists($objectId, $this->_link_cache)) {
>       if (isset($this->_link_cache[$objectId][$linkName])) {
>           return $this->_link_cache[$objectId][$linkName];
>         }
>     }
> 		$obj = $this->getObject($objectId);
> 		return $obj->links[$linkName];
> 	}
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message