"Failed Ajax request or invalid JSON returned" errors on Turkish backend

Hi,
Once again, I would like to thank you ( and other developers) for untiring efforts on OJS.
If you excuse me, I would like to ask a previously asked, but not yet solved question. A short time ago, I upgraded our journal’s site form 2.4.8.2 to 3.0.2 and I don’t want to revert back. Like some other non-English locale users, I get “Failed Ajax request or invalid JSON returned.” errors, especially when I click Metadata, Editorial History, Request Revisions, Resubmit for Review, More Info… These errors make OJS impossible to use in Turkish language.
So, I enabled php error log, and it is full of thousands of php warnings, and php errors to a lesser extent.
I inserted the code above line 833 in lib/pkp/classes/core/PKPString.inc.php and get those lines at the moment when I generate those errors.

20-May-2017 05:01:57 Europe/Istanbul] PHP Warning: assert(): Assertion failed in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 833
[20-May-2017 05:01:59 Europe/Istanbul] ojs2: 404 Not Found
[20-May-2017 05:02:08 Europe/Istanbul] ojs2: 404 Not Found
[20-May-2017 05:02:12 Europe/Istanbul] ojs2: 404 Not Found
[20-May-2017 05:09:34 Europe/Istanbul] PHP Warning: assert(): Assertion failed in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 833
[20-May-2017 05:09:35 Europe/Istanbul] PHP Warning: assert(): Assertion failed in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 833
[20-May-2017 05:09:35 Europe/Istanbul] PHP Warning: assert(): Assertion failed in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 833
[20-May-2017 05:09:37 Europe/Istanbul] PHP Warning: assert(): Assertion failed in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 833
[20-May-2017 05:09:37 Europe/Istanbul] PHP Warning: assert(): Assertion failed in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 833
[20-May-2017 05:09:38 Europe/Istanbul] ojs2: 404 Not Found
[20-May-2017 05:16:20 Europe/Istanbul] PHP Fatal error: Call to a member function getRemoteURL() on null in /home/ugukoc/adlitipbulteni.com/pages/article/ArticleHandler.inc.php on line 230
[20-May-2017 05:28:05 Europe/Istanbul] ojs2: 404 Not Found
[20-May-2017 05:42:22 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[20-May-2017 05:42:22 Europe/Istanbul] PHP Warning: assert(): Assertion failed in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[20-May-2017 05:42:22 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[20-May-2017 05:42:22 Europe/Istanbul] PHP Warning: assert(): Assertion failed in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[20-May-2017 05:42:22 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[20-May-2017 05:42:22 Europe/Istanbul] PHP Warning: assert(): Assertion failed in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[20-May-2017 05:42:28 Europe/Istanbul] ojs2: 404 Not Found
[20-May-2017 05:42:34 Europe/Istanbul] ojs2: 404 Not Found
[20-May-2017 05:42:38 Europe/Istanbul] ojs2: 404 Not Found
[20-May-2017 05:42:47 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[20-May-2017 05:42:47 Europe/Istanbul] PHP Warning: assert(): Assertion failed in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[20-May-2017 05:42:48 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[20-May-2017 05:42:48 Europe/Istanbul] PHP Warning: assert(): Assertion failed in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[20-May-2017 05:42:49 Europe/Istanbul] ojs2: 404 Not Found`

I am not a programmer but let’s say, advanced user. Hope, you can find a solution.
Best Regards,
Ugur Kocak

Hi @drugurkocak,

Can you turn on show_stacktrace in your config.inc.php and report what your error log contains after visiting some of the problematic pages?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher

In order to reproduce those errors, I generated an identical test site with identical database, and identical ojs3 files. I only changed config.inc.php.
http://ojs3.adlitipbulteni.com

I can generate the same errors on test site. Wnen I enabled show_stacktrace = On, and display_errors = On in the config file, no submissions are listed. When I click Issues, that error message is displayed at backend
Warning: assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
So enabling only show_stacktrace = On in the config file, I get those lines at php56.log;

[25-May-2017 04:55:22 America/Los_Angeles] PHP Warning:  Cannot use a scalar value as an array in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/DataObject.inc.php on line 133
[25-May-2017 04:55:22 America/Los_Angeles] PHP Warning:  Cannot use a scalar value as an array in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/DataObject.inc.php on line 133
[25-May-2017 14:55:26 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:26 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 04:55:26 America/Los_Angeles] PHP Warning:  Cannot use a scalar value as an array in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/DataObject.inc.php on line 133
[25-May-2017 04:55:26 America/Los_Angeles] PHP Warning:  Cannot use a scalar value as an array in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/DataObject.inc.php on line 133
[25-May-2017 14:55:27 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:27 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 14:55:27 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:27 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 14:55:27 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:27 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 14:55:27 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:27 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 14:55:27 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:27 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 14:55:37 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:37 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 14:55:37 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:37 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 14:55:37 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:37 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 14:55:37 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:37 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 14:55:37 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:37 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 14:55:40 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:40 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 14:55:42 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:42 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 14:55:43 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:43 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 14:55:46 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:46 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 14:55:47 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:47 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 14:55:47 Europe/Istanbul] ASSERTION FAILED ON informationCenter
[25-May-2017 14:55:47 Europe/Istanbul] PHP Warning:  assert(): Assertion failed in /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPString.inc.php on line 838
[25-May-2017 14:55:47 Europe/Istanbul] ojs2: 404 Not Found
[25-May-2017 04:55:55 America/Los_Angeles] PHP Warning:  Cannot use a scalar value as an array in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/DataObject.inc.php on line 133

[25-May-2017 04:55:56 America/Los_Angeles] PHP Warning:  Cannot use a scalar value as an array in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/DataObject.inc.php on line 133
[25-May-2017 14:55:56 Europe/Istanbul] ojs2: 404 Not Found
[25-May-2017 04:55:57 America/Los_Angeles] PHP Warning:  Cannot use a scalar value as an array in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/DataObject.inc.php on line 133

[25-May-2017 04:55:59 America/Los_Angeles] PHP Warning:  Cannot use a scalar value as an array in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/DataObject.inc.php on line 133
[25-May-2017 14:56:06 Europe/Istanbul] ojs2: 404 Not Found
[25-May-2017 04:56:06 America/Los_Angeles] PHP Warning:  Cannot use a scalar value as an array in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/DataObject.inc.php on line 133
[25-May-2017 04:56:06 America/Los_Angeles] PHP Warning:  Cannot use a scalar value as an array in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/DataObject.inc.php on line 133

[25-May-2017 04:56:09 America/Los_Angeles] PHP Warning:  Cannot use a scalar value as an array in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/DataObject.inc.php on line 133
[25-May-2017 14:56:11 Europe/Istanbul] ojs2: 404 Not Found
[25-May-2017 04:56:24 America/Los_Angeles] PHP Warning:  Cannot use a scalar value as an array in /home/ugukoc/adlitipbulteni.com/lib/pkp/classes/core/DataObject.inc.php on line 133

Note: I removed several duplicate lines to save some space.

At the same moment, I get those errors at Safari inspector console,
http://ojs3.adlitipbulteni.com/index.php/atb/$$$call$$$/modals/submission-metadata/Issue-entry/fetch?submissionId=1047&stageId=3&=1495713341081
Failed to load resource: the server responded with a status of 404 (Not Found)
http://ojs3.adlitipbulteni.com/index.php/atb/$$$call$$$/center/submission-Information-center/view-Information-center?submissionId=1047&
=1495713341082
Failed to load resource: the server responded with a status of 404 (Not Found)
http://ojs3.adlitipbulteni.com/index.php/atb/$$$call$$$/center/file-Information-center/view-Information-center?fileId=4538&revision=1&submissionId=1047&stageId=3&=1495713341083
Failed to load resource: the server responded with a status of 404 (Not Found)
http://ojs3.adlitipbulteni.com/index.php/atb/$$$call$$$/modals/editor-decision/editor-decision/send-reviews-In-review?submissionId=1047&stageId=3&reviewRoundId=380&decision=3&
=1495713341084
Failed to load resource: the server responded with a status of 404 (Not Found)
When I click the links above, I got this errors at the opened web page;
404 Not Found

Stack Trace:

File: /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPRouter.inc.php line 356
Function: Dispatcher->handle404()

File: /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPComponentRouter.inc.php line 262
Function: PKPRouter->_authorizeInitializeAndCallRequest(Null, Object(Request), Array(3))

File: /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/Dispatcher.inc.php line 134
Function: PKPComponentRouter->route(Object(Request))

File: /home/ugukoc/ojs3.adlitipbulteni.com/lib/pkp/classes/core/PKPApplication.inc.php line 227
Function: Dispatcher->dispatch(Object(Request))

File: /home/ugukoc/ojs3.adlitipbulteni.com/index.php line 68
Function: PKPApplication->execute()

Best Regards,
Ugur

Hi @drugurkocak,

Try the solution suggested at this thread: Fatal Error on Turkish on UserRolesRequiredPolicy.inc.php at line 49 - #2 by asmecher

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher
As you suggested, I modified lib/pkp/classes/i18n/PKPLocale.inc.php file, and inserted
if ($locale == 'tr_TR') setlocale(LC_CTYPE, 'en_US');
to the end of initialize function, so the final state of the function is;

	static function initialize($request) {
		self::$request = $request;

		// Use defaults if locale info unspecified.
		$locale = AppLocale::getLocale();

		$sysLocale = $locale . '.' . LOCALE_ENCODING;
		if (!@setlocale(LC_ALL, $sysLocale, $locale)) {
			// For PHP < 4.3.0
			if(setlocale(LC_ALL, $sysLocale) != $sysLocale) {
				setlocale(LC_ALL, $locale);
			}
			if ($locale == 'tr_TR') setlocale(LC_CTYPE, 'en_US');
		}

Hope, I inserted to the correct place.
Since the first install of the journal’s site, I used english locale (en_US) as default, and it is same after upgrade. In the web settings, two languages are installed (English and Turkish), and English is the default language. The locale settings in my config.inc.php file is;

[i18n]

; Default locale
locale = en_US

; Client output/input character set
client_charset = utf-8

; Database connection character set
; Must be set to "Off" if not supported by the database server
; If enabled, must be the same character set as "client_charset"
; (although the actual name may differ slightly depending on the server)
connection_charset = utf8

; Database storage character set
; Must be set to "Off" if not supported by the database server
database_charset = utf8

; Enable character normalization to utf-8 (recommended)
; If disabled, strings will be passed through in their native encoding
; Note that client_charset and database collation must be set
; to "utf-8" for this to work, as characters are stored in utf-8
charset_normalization = Off

I checked several times,
Unfortunately, the errors still persist, and php log contains same errors. I may share more, if it will help.
Best regards,
Ugur Kocak

Hi @drugurkocak,

That looks like the wrong place to insert the line – it should be just before the last closing } in that function.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher
I am grateful to you, and give my heartfelt thanks.
I want to write what I did, because some other users may benefit.
Again I am not sure if it is at correct place, I changed relevant page and the errors have gone.
The final state of initialize function in lib/pkp/classes/i18n/PKPLocale.inc.php is;

	static function initialize($request) {
		self::$request = $request;

		// Use defaults if locale info unspecified.
		$locale = AppLocale::getLocale();

		$sysLocale = $locale . '.' . LOCALE_ENCODING;
		if (!@setlocale(LC_ALL, $sysLocale, $locale)) {
			// For PHP < 4.3.0
			if(setlocale(LC_ALL, $sysLocale) != $sysLocale) {
				setlocale(LC_ALL, $locale);
			}
		}

		AppLocale::registerLocaleFile($locale, "lib/pkp/locale/$locale/common.xml");

		// Set site time zone
		// Starting from PHP 5.3.0 PHP will throw an E_WARNING if the default
		// time zone is not set and date/time functions are used
		// http://pl.php.net/manual/en/function.date-default-timezone-set.php
		$timeZone = self::getTimeZone();
		date_default_timezone_set($timeZone);

		if (Config::getVar('general', 'installed')) {
			// Set the time zone for DB
			// Get the offset from UTC
			$now = new DateTime();
			$mins = $now->getOffset() / 60;
			$sgn = ($mins < 0 ? -1 : 1);
			$mins = abs($mins);
			$hrs = floor($mins / 60);
			$mins -= $hrs * 60;
			$offset = sprintf('%+d:%02d', $hrs*$sgn, $mins);

			$conn = DBConnection::getInstance();
			$dbconn =& $conn->getDBConn();
			switch($conn->getDriver()) {
				case 'mysql':
				case 'mysqli':
					$dbconn->execute('SET time_zone = \''.$offset.'\'');
					break;
				case 'postgres':
					$dbconn->execute('SET TIME ZONE INTERVAL \''.$offset.'\' HOUR TO MINUTE');
					break;
				default: assert(false);
			}
		}
				if ($locale == 'tr_TR') setlocale(LC_CTYPE, 'en_US');
	}

That change solved some other problems too. I had read these problems in other topics of the forum.
In Turkish backend, that issues were solved

  • The past and future issues are displayed now,
  • More information (in list of submissions), review details, submission metadata, editorial history, editorial decision links and other work now.
  • Thus, I can use Turkish email templates too.

Best Regards,
Ugur Kocak

Hi @drugurkocak,

Glad to hear it’s resolved! I’m hoping this issue goes away with newer releases of PHP – the linked bug entry seems to disappear and recur multiple times over the last decade – but for now your work-around should improve things.

Regards,
Alec Smecher
Public Knowledge Project Team