Closed aaslun closed 10 years ago
It seems that this only happens to child articles in a list. Could it possibly have something to do with the json_encode in the duplicateImage function in AdminAjaxManager.php?
Update: every time you save the list the number of backslashes duplicates exponentially. After a certain number of saves it reaches a break point which causes the list to corrupt and can no longer be accessed. The only solution is to remove the list and start over with a new one.
Is the image object ['html'] serialized somewhere or parsed at some point? It seems that there is some kind of character escaping going berserk?
I have received a similar report from a user via Twitter. Might be due to the same problem. He describes it as "After a while I can't save anymore and I have to create a new list."
Hmmm. This recalled a mail in 2012 we had the same problem with earlier version of Arlima. It added escapes to already escaped espaces..:)
We investigated this for days but turning from magicquotes-problem to encoding we finally solved it with a function that stripped the double escapes every time we saved the article.
Looking at the same spot now there is a foreach doing this in saveArticle in file ListFactory.php:
foreach($article as $key => $val) {
if( !is_array($val) ) {
$article[$key] = str_replace('\\', '', $val);
}
}
Perhaps this will give you a clue to debug, this might need to be done in updated article?. I will try to reproduce this also. What browsers are you using?
Thanks, we will definitely check that. We're using Chrome. We managed to capture the error output this time:
ERROR:------------Fatal error: Uncaught exception 'Exception' with message 'Data too long for column 'ala_image' at row 1' in C:\Projects\norran-30\public\wp-content\plugins\arlima\classes\ListFactory.php:503Stack trace:#0 C:\Projects\norran-30\public\wp-content\plugins\arlima\classes\ListFactory.php(316): Arlima_ListFactory->executeSQLQuery('query', 'INSERT INTO wp_...')#1 C:\Projects\norran-30\public\wp-content\plugins\arlima\classes\ListFactory.php(259): Arlima_ListFactory->saveArticle(288, Array, 1, -1, 1)#2 C:\Projects\norran-30\public\wp-content\plugins\arlima\classes\AdminAjaxManager.php(492): Arlima_ListFactory->saveNewListVersion(Object(Arlima_List), Array, 142, false)#3 C:\Projects\norran-30\public\wp-content\plugins\arlima\classes\AdminAjaxManager.php(471): Arlima_AdminAjaxManager->saveAndOutputList(4, Array, false)#4 [internal function]: Arlima_AdminAjaxManager->saveList('')#5 C:\Projects\norran-30\public\wp-includes\plugin.php(429): call_user_func_array(Array, Array)#6 C:\Projects\norran-30\public\wp-admin\admin-ajax.p in C:\Projects\norran-30\public\wp-content\plugins\arlima\classes\ListFactory.php on line 503WordPress database error: [Data too long for column 'ala_image' at row 1]
INSERT INTO wp_arlima_articlelist_article (ala_created, ala_published, ala_alv_id, ala_post, ala_title, ala_content, ala_sort, ala_size, ala_options, ala_image, ala_parent) VALUES (1394455632, 1360020434, 288, 15326, 'Texas Chainsaw 3D', '<p>Norrans recensent blir inte ens r‰dd av den h‰r s kallade skr‰ckfilmen.</p>', 1, 24, 'a:2:{s:11:\"hideRelated\";s:5:\"false\";s:8:\"template\";s:14:\"header-rotator\";}', 'a:6:{s:4:\"html\";s:82072:\"<img width=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\...uot; />\";s:3:\"url\";s:64:\"http://wp-norran.dev/wp-content/uploads/2013/12/rl-motorsg-2.jpg\";s:10:\"attachment\";s:5:\"15328\";s:4:\"size\";s:4:\"full\";s:9:\"alignment\";s:9:\"alignleft\";s:9:\"connected\";s:4:\"true\";}', -1)
I have managed to reproduce this now. To get backslashes to duplicate you must drag and drop an article in the list, save or preview the list. Then, in arlima admin, reload the page in the browser. Preview the list again and the backslashes have multiplied. It seems that this page and list reload is required in admin to trigger this.
Here is a "solution", inserting this line in arlima_template_object:
$obj['image']['html'] = str_ireplace('\\', '', $obj['image']['html']);
However, this does not really solve the problem, only removes the slashes in the object. But adding this line in the action that saves the list could be a quick-and-dirty way of cleaning this. Any suggestions in what arlima-filter this cleaning could be applied?
The best solution would of course be to locate the function that produces the backslashes in the first place and prevent it.
This should be done at an earlier stage, when the data is stored in the database. I think that's it's already fixed actually, one moment.....
I dabbled around with Arlima during the weekend and had no problems with the backslashes. Maybe I was doing it wrong (right).
Edit: saw your commit that fixes the issue. Awesome!
It depends on your php-settings http://www.php.net/manual/en/security.magicquotes.disabling.php
Ah, of course.
I found another thing that occurred in connection with our update to Arlima 3.0. I have debugged now for a while but I can not see that this is something that we do in any filter.
When you dump the image object in arlima_template_object it now contains a lot of backslashes in the img tag: