mantisbt-plugins / Snippets

Define snippets of text that can be easily pasted into text fields
MIT License
8 stars 12 forks source link

Can't retrieve snippets data from REST API if URL rewriting is not working #31

Closed hong3e closed 6 years ago

hong3e commented 6 years ago

Snippets plugin doesn't work in my site. I can see the Snippet menu on the Manage page, but I cannot see the snippet option on the 'View issues' page. My issue seems like the https://github.com/mantisbt-plugins/Snippets/issues/23

I installed as below:

Is there anything that I need to do?

Console error log

jquery-2.2.4.min.js:4 GET http://...api/rest/plugins/Snippets/data/29655 404 (Not Found) send @ jquery-2.2.4.min.js:4 ajax @ jquery-2.2.4.min.js:4 n.(anonymous function) @ jquery-2.2.4.min.js:4 getJSON @ jquery-2.2.4.min.js:4 SnippetsInit @ plugin_file.php?file…pets/snippets.js:88 (anonymous) @ plugin_file.php?file…ets/snippets.js:125 i @ jquery-2.2.4.min.js:2 fireWith @ jquery-2.2.4.min.js:2 ready @ jquery-2.2.4.min.js:2 J @ jquery-2.2.4.min.js:2

plugin_file.php?file…pets/snippets.js:91 Error occured while retrieving Snippets (anonymous) @ plugin_file.php?file…pets/snippets.js:91 i @ jquery-2.2.4.min.js:2 fireWith @ jquery-2.2.4.min.js:2 z @ jquery-2.2.4.min.js:4 (anonymous) @ jquery-2.2.4.min.js:4 XMLHttpRequest.send (async)
send @ jquery-2.2.4.min.js:4 ajax @ jquery-2.2.4.min.js:4 n.(anonymous function) @ jquery-2.2.4.min.js:4 getJSON @ jquery-2.2.4.min.js:4 SnippetsInit @ plugin_file.php?file…pets/snippets.js:88 (anonymous) @ plugin_file.php?file…ets/snippets.js:125 i @ jquery-2.2.4.min.js:2 fireWith @ jquery-2.2.4.min.js:2 ready @ jquery-2.2.4.min.js:2 J @ jquery-2.2.4.min.js:2

snippet2

snippet

dregad commented 6 years ago

For the record and by the looks of things, you're not actually using version 2.1.0 of the plugin, but the code from the master branch (at 13577913bcee8b8e873a6db317e427a8453fcad5), which relies on the new MantisBT REST API instead of making XML http requests.

jquery-2.2.4.min.js:4 GET http://...api/rest/plugins/Snippets/data/29655 404 (Not Found)

Since you're getting a 404 error on the API endpoint, it means that for some reason it is not working properly. Can you access other APIs, e.g. http://.../api/rest/lang ?

cs97jjm3 commented 6 years ago

Hi i have same problem, i have made sure i am using latest version, I am using 2.10.0

atrol commented 6 years ago

jquery-2.2.4.min.js:4 GET http://...api/rest/plugins/Snippets/data/29655 404 (Not Found)

This happens as URL rewriting configured in api/rest/.htaccess is not working.

The quick workaround (potential security and performance impact) is to change Apache config from AllowOverride None to AllowOverride All and to enable URL rewriting in Apache, e.g. on Ubuntu 16.04

sudo a2enmod rewrite
sudo apache2ctl restart
dregad commented 6 years ago

I'll change the code so that it uses on the full URL (i.e. via index.php) so that the plugin works even if URL rewriting is disabled or not properly configured on the web server.

cs97jjm3 commented 6 years ago

thanks for the prompt help. i must be going mad, i have updated plugin, still nothing in posts etc, just as hong3e picture.. i have disabled all plugins and still nothing.....i have also change apache config... still nothing..... confused .... but really appreciate your prompt help

atrol commented 6 years ago

just as hong3e picture

Does it mean you see something like this?

jquery-2.2.4.min.js:4 GET http://...api/rest/plugins/Snippets/data/29655 404 (Not Found)

If there is still an issue getting the Snippets data, you should see something like this after updating to latest version

jquery-2.2.4.min.js:4 GET http://...api/rest/index.php/plugins/Snippets/data/29655 404 (Not Found)
cs97jjm3 commented 6 years ago

i see nothing like that sorry i mean like capture

atrol commented 6 years ago

i see nothing like that

Does it mean that your browser console error log is empty?

Did you check your web server / PHP logs for errors and warnings?

Did you double check that line 16 of file snippets.js is

return "api/rest/index.php/plugins/Snippets/" + endpoint;

Did you restart your web server after the update?

Did you clear your browser cache?

cs97jjm3 commented 6 years ago

sorry for delay:

I did restart server -no joy that line was there.... also cleared browser cache....

did os update and rebooted server and it was working: once again thanks

vboctor commented 6 years ago

@cs97jjm3 you may be hitting the following bug. Try the fix in the PR: https://mantisbt.org/bugs/view.php?id=23954

cs97jjm3 commented 6 years ago

Hiya Thanks i have updated to 2.11 all working as expected