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

API and browse returns error message when there are private linked items #1507

Closed
OyvindLGjesdal opened this issue Feb 8, 2020 · 3 comments

Comments

@OyvindLGjesdal
Copy link

OyvindLGjesdal commented Feb 8, 2020

The problem seems to be:

Public item A has an object property to private item B . Private items B and C has object properties to public item A. When I'm logged in as admin, browse works. When I use credentials in API, the API works. When I change item A from public to private, API and browse works without credentials.

I am unsure if this is an issue, or related to us testing Omeka-S with lots of modules installed.

Error message returned is:

Fatal error: Uncaught Error: Call to a member function valueRepresentation() on null in /var/www/html/omeka-s/application/src/DataType/Resource/AbstractResource.php:81 Stack trace: #0 /var/www/html/omeka-s/application/src/Api/Representation/ValueRepresentation.php(67): Omeka\DataType\Resource\AbstractResource->getJsonLd(Object(Omeka\Api\Representation\ValueRepresentation)) #1 [internal function]: Omeka\Api\Representation\ValueRepresentation->jsonSerialize() #2 /var/www/html/omeka-s/modules/Next/src/Stdlib/JsonUnescaped.php(101): json_encode(Array, 2368) #3 /var/www/html/omeka-s/modules/Next/src/Stdlib/JsonUnescaped.php(68): Next\Stdlib\JsonUnescaped::encodeViaPhpBuiltIn(Array, false) #4 /var/www/html/omeka-s/modules/Next/src/Stdlib/JsonUnescaped.php(39): Next\Stdlib\JsonUnescaped::encodeValue(Array, false, Array, false) #5 /var/www/html/omeka-s/modules/Next/src/View/Renderer/ApiJsonRenderer.php(78): Next\Stdlib\JsonUnescaped::encode(Array, false, Array) #6 /var/www/html/omeka-s/vendor/zendframework/zend-view/src/View.php( in /var/www/html/omeka-s/application/src/DataType/Resource/AbstractResource.php on line 81`

See at https://birgitta.test.uib.no/api/items

Modules

API Info 3.0.8
CSV Import 2.1.1
Custom Ontology version 3.0.5
Custom Vocab version 1.2.0
Easy Install version 3.2.5
Easy Install version 3.2.4 (unable to remove)
Generic module version 3.0.12
IIIF server version 3.5.15
Mapping version 1.2.0
Mirador viewer version 3.1.6
Network Map version 1.0
Next version 3.1.2.26
RDF Datatype version 3.0.4
Value suggest version 1.4.1

System info

Omeka-S version 2.1.0
php version 7.3.13
mariadb version 5.5.5-10.4.12-MariaDB

Edit: I wanted to first post at the community forum (forum.omeka.org), but I am unable to receive a confirmation/email registering.

We cannot detect if your account was created, please ensure you have cookies enabled.

Best regards,
Øyvind

@zerocrates
Copy link
Member

Hmm, I don't think I've seen that error before from the forums.

Is that full setup required for you to see this bug, or just the "A to B" part? Also, this sentence:

When I change item A from private to public, API and browse works without credentials.

Is it supposed to be the other way around (i.e., things work as anonymous users when A is private, and they don't work when it's public)? Otherwise I have trouble squaring it with your initial description.

My immediate attempt to reproduce the problem by just doing an "A to B" setup (a public item pointing to a private item) didn't have any results. My immediate suspicion is that this is related to a module. I do note that the "Next" module is included in your trace, and maybe it is related? You could try temporarily disabling it to see if it resolves the issue.

@OyvindLGjesdal
Copy link
Author

OyvindLGjesdal commented Feb 10, 2020

Is it supposed to be the other way around (i.e., things work as anonymous users when A is private, and they don't work when it's public)? Otherwise I have trouble squaring it with your initial description.

I edited my issue to clarify. When A, B,C are all private. the API returns other public items.

I tried deactivating everything, but still receive the same message.
I managed to simplify the Issue with only public A -> private B.

I hope I found a reproducible example:

Experimenting with the issue I think it's connected to resource templates.

I added a new object property (dct:contributor) to my resource template with data Type Resource:Item and if I add a private item to it, I get the error.

If I change to default data type,delete the item, and readd it (select Omeka Resource -> Item -> Same resource), no error.

@zerocrates
Copy link
Member

Okay, that's definitely relevant. There's code to handle this case of linking to private resources, but it's written to target specifically the type "resource," which is only the type of the regular "pick a kind" resource values, not the specific ones that you can set in the resource templates.

Thanks to that extra bit of information, I can now reproduce the issue.

zerocrates added a commit that referenced this issue Mar 27, 2020
The code preventing this kind of error was keyed specifically to the
name "resource" for the data type of the value, but we've since
introduced other more specific resource types for values that can point
only to items, sets, etc.

Rather than base this check on the name of the type, this instead
checks if the type class extends from the abstract class for resource
data types. This introduces a new method isHidden to the value
representation to simplify this check.

(fix #1507)

(cherry picked from commit 61abd65)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants