OC 10.0.1 - unable to install Gallery app because it contains unallowed code
Expected behavior
It should be possible to install/update the Gallery app from the new Marketplace.
Current behavior
It isn't possible to install/update the Gallery app from the new Marketplace because the installer identifies unallowed code.
Steps to reproduce
- Open the Marketplace and select the Gallery app
- Select "Install"
- The message "Gallery v16.0.2 cannot be installed because it contains unallowed code.

The following lines were written to the log right after I've pressed the Install button:
{"reqId":"9GqYivNTxYOlxqFwbzi4","level":3,"time":"2017-05-26 15:34:15+02:00","remoteAddr":"10.0.2.2","user":"admin","app":"PHP","method":"POST","url":"\/owncloud\/index.php\/apps\/market\/apps\/gallery\/install","message":"Undefined variable: undefinedVariable at \/var\/www\/htdocs\/owncloud\/lib\/composer\/nikic\/php-parser\/lib\/PhpParser\/Lexer.php#70"}
{"reqId":"TdeBq8QJjRDVuc9MeYIt","level":3,"time":"2017-05-26 15:34:16+02:00","remoteAddr":"10.0.2.2","user":"admin","app":"PHP","method":"GET","url":"\/owncloud\/ocs\/v2.php\/apps\/notifications\/api\/v1\/notifications?format=json","message":"You are using a fallback implementation of the intl extension. Installing the native one is highly recommended instead. at \/var\/www\/htdocs\/owncloud\/lib\/composer\/patchwork\/utf8\/src\/Patchwork\/Utf8\/Bootup\/intl.php#18"}
Environment
Server Configuration
OS: Linux 3.16.42 Web server: Apache2 2.4.25 Database: MariaDB 5.5.54 PHP version: 5.6.29 ownCloud version: 10.0.1
Client Configuration
Browser: Mozilla Firefox 53.0.3 Operating system: Windows 7
Hmm strange, I just managed to upgrade gallery on my own server today.
WFM too
I just want to add that at the same time I had no problems to install/update e.g. the contacts and calendar apps. So it wouldn't expect a general problem.
I've downloaded the Gallery app tar.gz file, extracted its content to the ./owncloud/apps2 folder, activated it and ran ./occ upgrade. I was able to install it without any problems.
Still persistent with OC 10.0.10 and gallery 16.1.0 from market. Can't install because app "contains unallowed code".
Any debugging help before I try the mentioned workaround by @j-ed ?
@davitol mind reverifying ? last I checked the gallery app could be installed without issues.
https://github.com/owncloud/gallery/issues/724#issuecomment-304270472
@PVince81 Worked for me in past. Tested with oC 10.0.7 and WFM. Tested with 10.0.10 and Gallery 16.1.0 and works for me too
Sentry exception but the gallery app was enabled fine and works
ErrorException: require_once(/var/www/owncloud/apps/gallery/appinfo/application.php): failed to open stream: No such file or directory
File "/var/www/owncloud/lib/autoloader.php", line 168, in handleError
require_once $fullPath;
File "/var/www/owncloud/lib/autoloader.php", line 168, in require_once
require_once $fullPath;
File "/var/www/owncloud/lib/autoloader.php", line 168, in load
require_once $fullPath;
File "/var/www/owncloud/lib/autoloader.php", line 0, in spl_autoload_call
OC\Autoloader->load
File "gallery/appinfo/app.php", line 19, in require_once
$app = new Application();
...
(5 additional frame(s) were not displayed)
How to debug?
I unpacked the gallery app into ../apps manually and used the check-code to get more precise output:
./occ app:check-code gallery
Analysing apps/gallery/middleware/envcheckmiddleware.php
1 errors
line 155: OC_User - Static method of private class must not be called
App is not compliant
Is this the source of the problem?
// Allows a logged in user to access public links
line 155: \OC_User::setIncognitoMode(true);
But why does it trigger an error in my owncloud installation and not in others?
see https://raw.githubusercontent.com/owncloud/core/master/.github/issue_template.md to provide more info about your setup. could be some config.php switch about code checking ?
'appcodechecker' => true, in config.php
I will check with the next minor OC update because with the workaround mentioned above all is up & running for the moment :)
https://doc.owncloud.org/server/10.0/admin_manual/configuration/server/occ_command.html says: app:check-code has multiple checks: it checks if an app uses ownCloud’s public API (OCP) or private API (OC_)
So the gallery app seems to use a "private" method (OC_User) which is not allowed?
Yes. Sometimes app developers absolutely need some information and resort to using private APIs to access it. The right approach is to submit a pull request to core to extend the public API with the required method.