anvc / scalar

Born-digital, open source, media-rich scholarly publishing that’s as easy as blogging.
Other
231 stars 73 forks source link

Image_Metadata.php causing JS and AJAX errors on file upload #126

Closed dmer closed 4 years ago

dmer commented 4 years ago

We were getting errors trying to upload any files using the "Files and URLs > File Upload" menu.

error msg: "There was an error saving the file: SyntaxError: Unexpected token < in JSON at position 0"

We inserted the following before line 76 which seems to have fixed the issue. if (!empty($pano_arr)) {

thanks, Derek

craigdietrich commented 4 years ago

Hi @dmer Yep, this is a known, very recent bug. The master fixes it with this commit:

https://github.com/anvc/scalar/commit/c5242c24b8804e485d7bc3bedc3d1682b160edad

Master should be safe to update from right now if needed. I'll create a Release probably at the end of this week.

Sorry about that!

dmer commented 4 years ago

Thanks @craigdietrich appreciate the quick reply!

craigdietrich commented 4 years ago

NB there's a new Release up if ya need it!

bulbil commented 4 years ago

I appear to be experiencing a similar issue to the one described here, though it appears on image upload (as described above) as well as on new content block save. I was unclear whether this was an issue or something to do with my local installation.

After seeing this issue, I thought I'd chime in. I don't believe these are relevant but I'm running PHP 7.0, Ubuntu 16.04, Apache 2.4 -- I also have the S3 storage adapter enabled in local_settings.php.

index.edit:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0
    at parse (<anonymous>)
    at Function.jQuery.parseJSON (jquery-migrate-3.1.0.js:205)
    at Object.error (scalarapi.js:1882)
    at c (jquery-3.4.1.min.js:2)
    at Object.fireWith [as rejectWith] (jquery-3.4.1.min.js:2)
    at l (jquery-3.4.1.min.js:2)
    at XMLHttpRequest.<anonymous> (jquery-3.4.1.min.js:2)
index.edit:1 Failed to load resource: the server responded with a status of 404 (Not Found)

I'm just beginning with a local instance of Scalar here, so apologies in advance if the issue has been addressed elsewhere.

craigdietrich commented 4 years ago

Hi @bulbil,

Are you able to get to the PHP error that is being thrown in the ajax response? Ie, it looks like a PHP error is present in what is supposed to be the JSON return and jQuery.parseJSON therefore can't parse it.

If you're in the console, you can click the 'Network' tab, then re-run the file upload. You'll see the request to the backend show up in the Network list (at the bottom). Click that and then click the 'Response' tab and hopefully you'll see the PHP error there.

bulbil commented 4 years ago

Thank you @craigdietrich for responding so quickly! This is so helpful to see the PHP error. I realize now my problem is unrelated to this issue and I was able to figure it out.

FWIW I was under the impression I had to specify the port parameter in database.php (we use AWS RDS for our databases) but the port wasn't necessary plus it was secretly causing Scalar to bark at me.

Thanks again! Nabil

Fatal error: Uncaught Exception: MySQL host or socket is not set in /var/www/scalar/system/application/arc/vendor/joshcam/mysqli-database-class/MysqliDb.php:319 Stack trace: #0 /var/www/scalar/system/application/arc/vendor/joshcam/mysqli-database-class/MysqliDb.php(415): MysqliDb->connect('default') #1 /var/www/scalar/system/application/arc/vendor/joshcam/mysqli-database-class/MysqliDb.php(1978): MysqliDb->mysqli() #2 /var/www/scalar/system/application/arc/vendor/joshcam/mysqli-database-class/MysqliDb.php(559): MysqliDb->_prepareQuery() #3 /var/www/scalar/system/application/arc/vendor/joshcam/mysqli-database-class/MysqliDb.php(594): MysqliDb->rawQuery('SHOW COLUMNS FR...', NULL) #4 /var/www/scalar/system/application/arc/src/ARC2/Store/Adapter/mysqliAdapter.php(106): MysqliDb->rawQueryOne('SHOW COLUMNS FR...') #5 /var/www/scalar/system/application/arc/store/ARC2_Store.php(195): ARC2\Store\Adapter\mysqliAdapter->fetchRow('SHOW COLUMNS FR...') #6 /var/www/scalar/system/application/arc/store/ARC2_Store.php(713): ARC2_Store->h in /var/www/scalar/system/application/arc/vendor/joshcam/mysqli-database-class/MysqliDb.php on line 319