extiverse / bazaar

The extension marketplace for your Flarum forum.
https://discuss.flarum.org/d/5151
MIT License
59 stars 14 forks source link

Class Flagrow\Bazaar\Listeners\AddApiControllers does not exist #110

Closed hardware closed 6 years ago

hardware commented 6 years ago

Steps to reproduce

  1. composer require flagrow/bazaar
  2. open flarum administration panel at https://flarum.domain.tld/admin

You can reproduce the error below with my docker image : https://github.com/mondediefr/docker-flarum Dockerfile : https://github.com/mondediefr/docker-flarum/blob/master/Dockerfile

Poke @Braintelligence @hydrog3n @magicalex

Expected behaviour

No error and bazaar panel available on the left menu.

Actual behaviour

2018/04/13 20:25:19 [error] 32#32: *28 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught ReflectionException: Class Flagrow\Bazaar\Listeners\AddApiControllers does not exist in /flarum/app/vendor/illuminate/container/Container.php:741
Stack trace:
#0 /flarum/app/vendor/illuminate/container/Container.php(741): ReflectionClass->__construct('Flagrow\\Bazaar\\...')
#1 /flarum/app/vendor/illuminate/container/Container.php(631): Illuminate\Container\Container->build('Flagrow\\Bazaar\\...', Array)
#2 /flarum/app/vendor/flarum/core/src/Foundation/Application.php(514): Illuminate\Container\Container->make('Flagrow\\Bazaar\\...', Array)
#3 /flarum/app/vendor/illuminate/events/Dispatcher.php(149): Flarum\Foundation\Application->make('Flagrow\\Bazaar\\...')
#4 /flarum/app/vendor/illuminate/events/Dispatcher.php(135): Illuminate\Events\Dispatcher->resolveSubscriber('Flagrow\\Bazaar\\...')
#5 /flarum/app/vendor/flagrow/bazaar/bootstrap.php(9): Illuminate\Events\Dispatcher->subscribe('Flagrow\\Bazaar\\...')
#6 [internal function]: Flarum\Extension\ExtensionServiceProv" while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "127.0.0.1:8888"

example1

example2

example3

The bazaar panel freeze all my forum when I try to access it. Nginx reports a timeout error.

Configuration

Version of Bazaar:

0.2.4

Version of Flarum:

v0.1.0-beta.7.1

Other extensions:

No other extension.

All installed packages

composer show ``` /flarum/app # composer show components/font-awesome 4.7.0 The iconic font designed for use with Twitter Bootstrap. composer/ca-bundle 1.1.1 Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle. composer/composer 1.6.4 Composer helps you declare, manage and install dependencies of PHP projects, ensuring you have the right stack everywhere. composer/semver 1.4.2 Semver library that offers utilities, version constraint parsing and validation. composer/spdx-licenses 1.3.0 SPDX licenses list and validation library. danielstjules/stringy 1.10.0 A string manipulation library with multibyte support dflydev/fig-cookies v1.0.2 Cookies for PSR-7 HTTP Message Interface. doctrine/annotations v1.6.0 Docblock Annotations Parser doctrine/cache v1.7.1 Caching library offering an object-oriented API for many cache backends doctrine/collections v1.5.0 Collections Abstraction library doctrine/common v2.8.1 Common Library for Doctrine projects doctrine/dbal v2.6.3 Database Abstraction Layer doctrine/inflector v1.3.0 Common String Manipulations with regard to casing and singular/plural rules. doctrine/lexer v1.0.1 Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers. filp/whoops 2.1.14 php error handling for cool kids flagrow/bazaar 0.2.4 The Flarum extension marketplace. flarum/core v0.1.0-beta.7.1 Delightfully simple forum software. flarum/flarum-ext-akismet v0.1.0-beta.6 Stop spam using the Akismet anti-spam service. flarum/flarum-ext-approval v0.1.0-beta.7 Make discussions and posts require moderator approval. flarum/flarum-ext-auth-facebook v0.1.0-beta.6 Allow users to log in with Facebook. flarum/flarum-ext-auth-github v0.1.0-beta.6 Allow users to log in with GitHub. flarum/flarum-ext-auth-twitter v0.1.0-beta.6 Allow users to log in with Twitter. flarum/flarum-ext-bbcode v0.1.0-beta.5 Allow posts to be formatted with BBCode. flarum/flarum-ext-emoji v0.1.0-beta.6 Convert text and unicode emoji into Twemoji. flarum/flarum-ext-english v0.1.0-beta.7 English language pack. flarum/flarum-ext-flags v0.1.0-beta.7 Allow users to flag posts for moderator review. flarum/flarum-ext-likes v0.1.0-beta.6 Allow users to like posts. flarum/flarum-ext-lock v0.1.0-beta.7 End a discussion and don't let anyone add further replies. flarum/flarum-ext-markdown v0.1.0-beta.5 Allow posts to be formatted with Markdown. flarum/flarum-ext-mentions v0.1.0-beta.7 Mention and reply to specific posts and users. flarum/flarum-ext-pusher v0.1.0-beta.6 See new discussions and posts in real-time using Pusher. flarum/flarum-ext-sticky v0.1.0-beta.7 Pin discussions to the top of the list. flarum/flarum-ext-subscriptions v0.1.0-beta.6 Allow users to follow discussions and receive notifications for new posts. flarum/flarum-ext-suspend v0.1.0-beta.7 Suspend users so they can't post. flarum/flarum-ext-tags v0.1.0-beta.8 Organize discussions into a hierarchy of tags and categories. franzl/studio 0.11.2 Develop your Composer libraries with style franzl/whoops-middleware 0.4.1 guzzlehttp/guzzle 6.3.0 Guzzle is a PHP HTTP client library guzzlehttp/promises v1.3.1 Guzzle promises library guzzlehttp/psr7 1.4.2 PSR-7 message implementation that also provides common utility methods http-interop/http-middleware 0.2.0 Common interface for HTTP middleware illuminate/bus v5.1.41 The Illuminate Bus package. illuminate/cache v5.1.41 The Illuminate Cache package. illuminate/config v5.1.41 The Illuminate Config package. illuminate/container v5.1.41 The Illuminate Container package. illuminate/contracts v5.1.41 The Illuminate Contracts package. illuminate/database v5.1.41 The Illuminate Database package. illuminate/events v5.1.41 The Illuminate Events package. illuminate/filesystem v5.1.41 The Illuminate Filesystem package. illuminate/hashing v5.1.41 The Illuminate Hashing package. illuminate/mail v5.1.41 The Illuminate Mail package. illuminate/pipeline v5.1.41 The Illuminate Pipeline package. illuminate/support v5.1.41 The Illuminate Support package. illuminate/validation v5.1.41 The Illuminate Validation package. illuminate/view v5.1.41 The Illuminate View package. intervention/image 2.4.1 Image handling and manipulation library with support for Laravel integration ircmaxell/random-lib v1.2.0 A Library For Generating Secure Random Numbers ircmaxell/security-lib v1.1.0 A Base Security Library justinrainbow/json-schema 5.2.7 A library to validate a json schema. league/flysystem 1.0.42 Filesystem abstraction: Many filesystems, one API. league/oauth1-client 1.7.0 OAuth 1.0 Client Library league/oauth2-client 1.4.2 OAuth 2.0 Client Library league/oauth2-facebook 1.4.5 Facebook OAuth 2.0 Client Provider for The PHP League OAuth2-Client league/oauth2-github 0.2.2 Github OAuth 2.0 Client Provider for The PHP League OAuth2-Client matthiasmullie/minify 1.3.59 CSS & JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets inCSS files), and optimizes/shortens a few common programming patterns. matthiasmullie/path-converter 1.1.1 Relative path converter monolog/monolog 1.23.0 Sends your logs to files, sockets, inboxes, databases and various web services nesbot/carbon 1.22.1 A simple API extension for DateTime. nikic/fast-route v0.6.0 Fast request router for PHP oyejorge/less.php v1.7.0.14 PHP port of the Javascript version of LESS http://lesscss.org (Originally maintained by Josh Schmidt) paragonie/random_compat v1.4.2 PHP 5.x polyfill for random_bytes() and random_int() from PHP 7 psr/http-message 1.0.1 Common interface for HTTP messages psr/log 1.0.2 Common interface for logging libraries pusher/pusher-php-server 2.6.4 Library for interacting with the Pusher REST API s9e/text-formatter 0.8.5 Multi-purpose text formatting and markup library. Plugins offer support for BBCodes, Markdown, emoticons, HTML, embedding media (YouTube, etc...), enhanced typography and more. seld/cli-prompt 1.0.3 Allows you to prompt for user input on the command line, and optionally hide the characters they type seld/jsonlint 1.7.1 JSON Linter seld/phar-utils 1.0.1 PHAR file format utilities, for when PHP phars you up swiftmailer/swiftmailer v5.4.9 Swiftmailer, free feature-rich PHP mailer symfony/console v2.8.34 Symfony Console Component symfony/debug v2.7.41 Symfony Debug Component symfony/filesystem v3.4.4 Symfony Filesystem Component symfony/finder v2.7.41 Symfony Finder Component symfony/http-foundation v2.7.41 Symfony HttpFoundation Component symfony/polyfill-mbstring v1.7.0 Symfony polyfill for the Mbstring extension symfony/process v3.4.4 Symfony Process Component symfony/translation v2.7.41 Symfony Translation Component symfony/yaml v2.8.34 Symfony Yaml Component tijsverkoyen/akismet 1.1.1 Akismet is a wrapper-class to communicate with the Akismet API. tobscure/json-api v0.3.0 JSON-API responses in PHP zendframework/zend-diactoros 1.7.0 PSR HTTP Message implementations zendframework/zend-escaper 2.5.2 zendframework/zend-stratigility 1.3.3 Middleware for PHP ```
clarkwinkelmann commented 6 years ago

Could you share the php flarum info to get more details about what's running in that Docker container ? In particular, the PHP version. I'm not into Docker myself so I wouldn't be sure how to debug it.

Does it happen only in that container or did you reproduce it inside the container after experiencing it elsewhere ?

Do other extensions work fine ? In particular other Flagrow extensions should work exactly the same at this point, it would be strange for Bazaar to have an issue there.

Braintelligence commented 6 years ago

To chime in, I'm using that container and don't have any problems with Flagrow Upload or User-Directory (other than the loading overlay for user-directory that won't go away, but that issue is already opened for non-docker installations as well).

hardware commented 6 years ago

@clarkwinkelmann :

php flarum info

Flarum core 0.1.0-beta.7
PHP 7.1.15
Loaded extensions: Core, date, libxml, pcre, filter, hash, readline, Reflection, SPL, session, ctype, curl, dom, fileinfo, gd, json, mbstring, openssl, PDO, standard, tokenizer, xmlwriter, zlib, mysqlnd, Phar, pdo_mysql, Zend OPcache
EXT flarum-approval v0.1.0-beta.7
EXT flarum-bbcode v0.1.0-beta.5
EXT wiwatsrt-best-answer v0.1.0-beta.11
EXT flarum-emoji v0.1.0-beta.6
EXT clarkwinkelmann-emojionearea 0.1.2
EXT flarum-english v0.1.0-beta.7
EXT flagrow-bazaar 0.2.4
EXT flarum-flags v0.1.0-beta.7
EXT milescellar-french v1.1.0
EXT flarum-auth-github v0.1.0-beta.6
EXT sijad-recaptcha 0.0.2
EXT flarum-likes v0.1.0-beta.6
EXT sijad-links 0.1.0-beta.6
EXT flarum-lock v0.1.0-beta.7
EXT flarum-markdown v0.1.0-beta.5
EXT s9e-mediaembed 0.3.2
EXT flarum-mentions v0.1.0-beta.7
EXT davis-securehttps 0.1.0-beta5
EXT terabin-sitemap v1.0.2-beta.2
EXT flarum-sticky v0.1.0-beta.7
EXT flarum-subscriptions v0.1.0-beta.6
EXT flarum-suspend v0.1.0-beta.7
EXT flarum-tags v0.1.0-beta.8
EXT avatar4eg-transliterator 0.4.0
sh: git: not found
EXT mondediefr-mondedie dev-master
Base URL: https://mondedie.fr
Installation path: /flarum/app

Do other extensions work fine ?

Yes, other extensions work fine.

In particular other Flagrow extensions

I have not tested any flagrow extensions.

But that issue is already opened for non-docker installations as well

@Braintelligence : Do you have a link ?

Braintelligence commented 6 years ago

@hardware https://github.com/flagrow/user-directory/issues/8

luceos commented 6 years ago

@hardware can you check your steps to reproduce? Seems like you're trying to open the Bazaar tab after opening the admin? Is that all you did?

hardware commented 6 years ago

The error PHP Fatal error: Uncaught ReflectionException: Class Flagrow\Bazaar\Listeners\AddApiControllers does not exist seems fixed with php 7.1.16 but the bazaar panel always freeze all my forum when I try to access it.

2018/04/17 19:54:56 [error] 18#18: *59 upstream timed out (110: Operation timed out) while reading response header from upstream, client: 172.18.0.3, server: , request: "GET /api/bazaar/extensions?filter%5Bsearch%5D= HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-fpm.sock", host: "flarum.domain.tld", referrer: "https://flarum.domain.tld/admin"

Is that all you did ?

Yes.

With 7.1.15, I got the Fatal error: Uncaught ReflectionException error with this two steps :

  1. composer require flagrow/bazaar
  2. Open flarum administration panel at https://flarum.domain.tld/admin

And the request GET /api/bazaar/extensions?filter%5Bsearch%5D= timed out when I try to access Bazaar panel

With 7.1.16, I do not have the Fatal error: Uncaught ReflectionException error but I get the timeout error.

hardware commented 6 years ago

You can reproduce all of this with my docker image :

docker pull mondedie/docker-flarum:latest
docker pull mondedie/docker-flarum:0.1.0-beta.7.1-stable

docker run -d --name flarum-php-7.1.15 -p 80:8888 mondedie/docker-flarum:0.1.0-beta.7.1-stable
docker run -d --name flarum-php-7.1.16 -p 81:8888 mondedie/docker-flarum:latest

use the following command to install Bazaar :

docker exec -ti flarum-php-7.1.15 extension require flagrow/bazaar
docker exec -ti flarum-php-7.1.16 extension require flagrow/bazaar

Using version ^0.2.4 for flagrow/bazaar
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 9 installs, 0 updates, 0 removals
  - Installing seld/phar-utils (1.0.1): Downloading (100%)
  - Installing seld/jsonlint (1.7.1): Downloading (100%)
  - Installing seld/cli-prompt (1.0.3): Downloading (100%)
  - Installing justinrainbow/json-schema (5.2.7): Downloading (100%)
  - Installing composer/spdx-licenses (1.3.0): Downloading (100%)
  - Installing composer/semver (1.4.2): Downloading (100%)
  - Installing composer/ca-bundle (1.1.1): Downloading (100%)
  - Installing composer/composer (1.6.4): Downloading (100%)
  - Installing flagrow/bazaar (0.2.4): Downloading (100%)
composer/composer suggests installing ext-zip (Enabling the zip extension allows you to unzip archives)
Package http-interop/http-middleware is abandoned, you should avoid using it. Use http-interop/http-server-middleware instead.
Writing lock file
Generating autoload files

flagrow/bazaar added to flarum.
Clearing the cache...

And this command to verify nginx error log :

docker exec -ti flarum-php-7.1.15 tail -f /tmp/ngx_error.log
docker exec -ti flarum-php-7.1.16 tail -f /tmp/ngx_error.log

2018/04/17 19:51:51 [error] 18#18: *33 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught ReflectionException: Class Flagrow\Bazaar\Listeners\AddApiControllers does not exist in /flarum/app/vendor/illuminate/container/Container.php:741
Stack trace:
#0 /flarum/app/vendor/illuminate/container/Container.php(741): ReflectionClass->__construct('Flagrow\\Bazaar\\...')
#1 /flarum/app/vendor/illuminate/container/Container.php(631): Illuminate\Container\Container->build('Flagrow\\Bazaar\\...', Array)
#2 /flarum/app/vendor/flarum/core/src/Foundation/Application.php(514): Illuminate\Container\Container->make('Flagrow\\Bazaar\\...', Array)
#3 /flarum/app/vendor/illuminate/events/Dispatcher.php(149): Flarum\Foundation\Application->make('Flagrow\\Bazaar\\...')
#4 /flarum/app/vendor/illuminate/events/Dispatcher.php(135): Illuminate\Events\Dispatcher->resolveSubscriber('Flagrow\\Bazaar\\...')
#5 /flarum/app/vendor/flagrow/bazaar/bootstrap.php(9): Illuminate\Events\Dispatcher->subscribe('Flagrow\\Bazaar\\...')
#6 [internal function]: Flarum\Extension\ExtensionServiceProv" while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "127.0.0.1:8888"

2018/04/17 19:44:21 [error] 22#22: *49 upstream timed out (110: Operation timed out) while reading response header from upstream, client: 172.18.0.3, server: , request: "GET /api/bazaar/extensions?filter%5Bsearch%5D= HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-fpm.sock", host: "flarum.domain.tld", referrer: "https://flarum.domain.tld/admin"

Or this command to open a shell into the container :

docker exec -ti flarum-php-7.1.15 sh
docker exec -ti flarum-php-7.1.16 sh
> cd /flarum/app
> php flarum info
> ...
clarkwinkelmann commented 6 years ago

I've still not had time to try booting the docker image myself but I noticed something in your log files: the php zip extension is missing. So this probably means Composer is installing the extension differently than the normal dist files, but I don't know how it extracts dist or source zipballs without that extension.

Could you mabye try with the php zip extension activated ?

hardware commented 6 years ago

Could you mabye try with the php zip extension activated ?

With zip extension, i got the same error.

2018/05/03 07:12:36 [error] 20#20: *11 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught ReflectionException: Class Flagrow\Bazaar\Listeners\AddApiControllers does not exist in /flarum/app/vendor/illuminate/container/Container.php:741
Stack trace:
#0 /flarum/app/vendor/illuminate/container/Container.php(741): ReflectionClass->__construct('Flagrow\\Bazaar\\...')
#1 /flarum/app/vendor/illuminate/container/Container.php(631): Illuminate\Container\Container->build('Flagrow\\Bazaar\\...', Array)
#2 /flarum/app/vendor/flarum/core/src/Foundation/Application.php(514): Illuminate\Container\Container->make('Flagrow\\Bazaar\\...', Array)
#3 /flarum/app/vendor/illuminate/events/Dispatcher.php(149): Flarum\Foundation\Application->make('Flagrow\\Bazaar\\...')
#4 /flarum/app/vendor/illuminate/events/Dispatcher.php(135): Illuminate\Events\Dispatcher->resolveSubscriber('Flagrow\\Bazaar\\...')
#5 /flarum/app/vendor/flagrow/bazaar/bootstrap.php(9): Illuminate\Events\Dispatcher->subscribe('Flagrow\\Bazaar\\...')
#6 [internal function]: Flarum\Extension\ExtensionServiceProv" while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "127.0.0.1:8888"

https://github.com/mondediefr/docker-flarum/blob/990087f809350528a1260f610b5876bbb744604c/Dockerfile#L20-L38

clarkwinkelmann commented 6 years ago

@hardware please try removing vendor folder and run composer install again once you enabled the zip extension.

hardware commented 6 years ago

It is not useful with docker because all folders inside the container are deleted when the container is deleted (what I do every time after a new build). Only two folders are preserved across reboot :

/flarum/app/assets
/flarum/app/extensions

In /flarum/app/extensions I keep the composer cache to speedup packages installation.

COMPOSER_CACHE_DIR=/flarum/app/extensions/.cache https://github.com/mondediefr/docker-flarum/blob/master/rootfs/usr/local/bin/extension#L29

luceos commented 6 years ago

@hardware aside from the fact that I absolutely love docker (currently working with kubernetes), I am unsure it's our responsibility to make your docker image work.

After beta 8 we'll start improving the overall codebase of our extensions by adding tests aiming for an acceptable code coverage on different php versions.

Right now, our time is limited and our responsibilities are far spread. As such I'm sorry to tell you I'll be closing this issue and we are not supporting your current set up.

I'd love to hear whether you figured out the cause of your troubles.

hardware commented 6 years ago

I understand your point. When I will have more time, I will try to figure out the cause. But you can still notice that I maintain for 2 years the main docker image for flarum, used by a small part of the community for the moment but it could grow. Help would have been appreciated on this issue because this problem is easily reproducible with any host environment (docker containers are immutable).

And it's not a closed and obscure environment, you have access to the filesystem to reproduce this behavior.

https://github.com/mondediefr/docker-flarum/tree/master/rootfs

hardware commented 6 years ago

@Magicalex @xataz @Hydrog3n @webeindustry Any idea on this issue ?

luceos commented 6 years ago

@hardware we're short on time, looking into this takes time. I'll see what we can do, but it won't be treated as an issue of Bazaar for now.