Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

SS3.0.3 / CMS: reload content


Go to End


2 Posts   872 Views

Avatar
dacar

Community Member, 173 Posts

8 February 2013 at 9:27pm

Hi,

i am just testing SS3.0.3 and found an issue. If i switch between two menu items in the sitetree, tahn the content will not reload. you have to reload the whole window to show the new content. During the installation process i had to delete mb_regex_encoding('UTF-8'); in Core.php because of some error messages. Is that related to the problem? How to aktivate mb_regex_encoding in php.ini? My PHP version is 5.3.0

Hope that someone can help. Greetings, Carsten.

ERROR [Warning]: json_encode() [<a href='function.json-encode'>function.json-encode</a>]: Invalid UTF-8 sequence in argument
IN GET /silver_test/admin/pages/edit/show/2
Line 103 in /framework/core/Convert.php

Source
======
  94:  	}
  95:  
  96:  	/**
  97:  	 * Encode a value as a JSON encoded string.
  98:  	 *
  99:  	 * @param mixed $val Value to be encoded
  100: 	 * @return string JSON encoded string
  101: 	 */
  102: 	public static function raw2json($val) {
* 103: 		return json_encode($val);
  104: 	}
  105: 
  106: 	/**
  107: 	 * Encode an array as a JSON encoded string.
  108: 	 * THis is an alias to {@link raw2json()}
  109: 	 *

Trace
=====
json_encode(Array)
Convert.php:103

Convert::raw2json(Array)
PjaxResponseNegotiator.php:87

PjaxResponseNegotiator->respond(SS_HTTPRequest)
LeftAndMain.php:464

LeftAndMain->show(SS_HTTPRequest)
Controller.php:205

Controller->handleAction(SS_HTTPRequest)
RequestHandler.php:184

RequestHandler->handleRequest(SS_HTTPRequest,DataModel)
Controller.php:153

Controller->handleRequest(SS_HTTPRequest,DataModel)
LeftAndMain.php:357

LeftAndMain->handleRequest(SS_HTTPRequest,DataModel)
AdminRootController.php:89

AdminRootController->handleRequest(SS_HTTPRequest,DataModel)
Director.php:307

Director::handleRequest(SS_HTTPRequest,Session,DataModel)
Director.php:119

Director::direct(/admin/pages/edit/show/2,DataModel)
main.php:126

{"Content":null}

Avatar
dacar

Community Member, 173 Posts

8 February 2013 at 9:52pm

Hi, i think i have found the solution: I have Changed "framework/core/convert.php" from

	public static function raw2json($val) {
		return json_encode($val);
	}

to

	public static function raw2json($val) {
		array_walk_recursive($val, function (&$item, $key) { 
			if (is_string($item)) $item = mb_encode_numericentity($item, array (0x80, 0xffff, 0, 0xffff), 'UTF-8'); 
		});
		return mb_decode_numericentity(json_encode($val), array (0x80, 0xffff, 0, 0xffff), 'UTF-8');
		
		//return json_encode($val);
	}

Now it seems to work. I think with this solution u can use SS3 without mb_regex_encoding('UTF-8');

Greetings, Carsten.