algorys / gitlabproject

Dokuwiki plugin to display a Gitlab project
3 stars 4 forks source link

PHP error after clean install #5

Closed hAh0L13 closed 5 years ago

hAh0L13 commented 5 years ago

Hello. I have similar problem to old issue "PHP Error...". After clean install throuhgt Extension Manager and configuring in Settings page, I had try to use plugin with correct syntax - but got blank page w/o dokuwiki side links (edit, move, up and other). Apache error.log have this:

[Thu Oct 04 16:07:07.171219 2018] [php7:error] [pid 24885] [client IP_client] PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /var/www/dokuwiki/lib/plugins/gitlabproject/gitlab/gitlab.php:13\nStack trace:\n#0 /var/www/dokuwiki/lib/plugins/gitlabproject/syntax.php(104): DokuwikiGitlab->__construct(Array)\n#1 /var/www/dokuwiki/lib/plugins/gitlabproject/syntax.php(91): syntax_plugin_gitlabproject->renderGitlab(Object(Doku_Renderer_xhtml), Array)\n#2 /var/www/dokuwiki/inc/parser/renderer.php(111): syntax_plugin_gitlabproject->render('xhtml', Object(Doku_Renderer_xhtml), Array)\n#3 /var/www/dokuwiki/inc/parserutils.php(654): Doku_Renderer->plugin('gitlabproject', Array, 5, '<gitlab project...')\n#4 /var/www/dokuwiki/inc/parserutils.php(130): p_render('xhtml', Array, NULL)\n#5 /var/www/dokuwiki/inc/parserutils.php(83): p_cached_output('/var/www/dokuwi...', 'xhtml', 'python_scripts:...')\n#6 /var/www/dokuwiki/inc/html.php(293): p_wiki_xhtml('python_scripts:...', 0, true, '')\n#7 /var/www/dokuwiki/inc/Action/Show.php(33): html_show()\n#8 /var/www/dokuwiki/inc/template.php(98): dokuwiki\Action\ in /var/www/dokuwiki/lib/plugins/gitlabproject/gitlab/gitlab.php on line 13, referer: http://IP_dokuwiki/doku.php?id=python_scripts:urg_get_ftp

DokuWiki Release 2018-04-22a "Greebo" PHP Version => 7.2.10-0ubuntu0.18.04.1

Another mistake - changing settings throught web page does not affect server.json file and conf/default.php, i'm edit this files manually

_Originally posted by @hAh0L13 in https://github.com/algorys/gitlabproject/issue_comments#issuecomment-426946908_

hAh0L13 commented 5 years ago

OK, it's my mistake. apt install php7.2-curl fix this. Now i have another problem:

`Warning: Illegal string offset 'web_url' in /var/www/dokuwiki/lib/plugins/gitlabproject/syntax.php on line 141

Warning: Illegal string offset 'username' in /var/www/dokuwiki/lib/plugins/gitlabproject/syntax.php on line 141

Warning: Illegal string offset 'access_level' in /var/www/dokuwiki/lib/plugins/gitlabproject/syntax.php on line 142

Warning: Use of undefined constant Guest - assumed 'Guest' (this will throw an Error in a future version of PHP) in /var/www/dokuwiki/lib/plugins/gitlabproject/gitlab/gitlab.php on line 88

Warning: Use of undefined constant Reporter - assumed 'Reporter' (this will throw an Error in a future version of PHP) in /var/www/dokuwiki/lib/plugins/gitlabproject/gitlab/gitlab.php on line 89

Warning: Use of undefined constant Developer - assumed 'Developer' (this will throw an Error in a future version of PHP) in /var/www/dokuwiki/lib/plugins/gitlabproject/gitlab/gitlab.php on line 90

Warning: Use of undefined constant Master - assumed 'Master' (this will throw an Error in a future version of PHP) in /var/www/dokuwiki/lib/plugins/gitlabproject/gitlab/gitlab.php on line 91

Warning: Use of undefined constant Owner - assumed 'Owner' (this will throw an Error in a future version of PHP) in /var/www/dokuwiki/lib/plugins/gitlabproject/gitlab/gitlab.php on line 92 `

And all what i see on page is:

`Gitlab Project

Members: A ()`

hAh0L13 commented 5 years ago

Ok, problem solved. It's about api version change: v3 -> v4. Just small editing gitlab.php and everything works

algorys commented 5 years ago

Hi @hAh0L13,

Which API? That of Gitlab?

Could you tell me the changes you made on the file gitlab.php please ?

hAh0L13 commented 5 years ago

Yep, gitlab api. Now it use v4. Gitlab + dokuwiki using on our work, i didn't make copy of changes for home use. if the memory does not fail me, then the changes are: line 17: return $this->dw_data['server'] . '/api/v4/'; line 41: $url_request = $this->getAPIUrl().'projects/'.urlencode($this->dw_data['project']).'?private_token='.$this->dw_data['token']; line 50: $user_url_request = $this->getAPIUrl().'projects/'.urlencode((string)$this->dw_data['project']).'/members/all?private_token='.$this->dw_data['token']; line 55: $group_url_request = $this->getAPIUrl().'groups/'.urlencode($namespace).'/members/all?private_token='.$this->dw_data['token']; lines 88-92: all names in '', like Guest -> 'Guest'

algorys commented 5 years ago

@hAh0L13 thanks for #6 .

Strange thing here is I've 2 Gitlab server with API v4 and it works for me without any changes.

screenshot from 2018-10-17 11-11-58

So not sure it was an API problem. And it looks like you only had warnings ? Maybe due to PHP version.

algorys commented 5 years ago

After some tests, it seems that requests for members does not work same as php5 and php7... strange behavior. On a new server with Php7 installed, your PR #6 works as expected. But with 5.6 requests fails.

Can you please try to make this kind of request on your Gitlab server (replacing words in upper case with your values):

http://GITLAB_SERVER/api/v4/groups/GROUP/members?private_token=ADMIN_TOKEN

Or

http://GITLAB_SERVER/api/v4/projects/GROUP%2FPROJECT/members?private_token=ADMIN_TOKEN

Before I added /all right after members like that:

http://GITLAB_SERVER/api/v4/groups/GROUP/members/all?private_token=ADMIN_TOKEN

... and curl requests fails

You can also try last commit 509b09a