The following warnings occurred:
Warning [2] Undefined array key "threadviews_countguests" - Line: 745 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php 745 errorHandler->error_callback
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 1121 build_postbit
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 1121 build_postbit
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 861 postParser->parse_message
/showthread.php 1121 build_postbit
Warning [2] Undefined property: MyLanguage::$thread_modes - Line: 46 - File: showthread.php(1650) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php(1650) : eval()'d code 46 errorHandler->error_callback
/showthread.php 1650 eval




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Some javascript problems in admin area
#1
I recently discover a problem with 3.1B version. In admin area, on file admin/template/header.php, this piece of code generated an uncaught exception :
Code:
var obj = jQuery.parseJSON('<?php echo get_api_details(); ?>');
if(obj.status != 1) {
    $('a.support').parent('li').append('<span class="warning">!</span>');
    $('a.support').attr('href', 'health-check.php');
}

We use getsimple for a project hosted on sourceforge. On this host service, all outbound communications are forbidden (http://sourceforge.net/apps/trac/sourcef...nnectivity) and the PHP function "get_api_details()" returns an empty string.

As mentionned in jquery docs http://api.jquery.com/jQuery.parseJSON/, the parseJSON method returns null if an empty strings is passed in parameter, so reading obj.status directly after calling parseJSON can end with an error. This error causes many Javascript codes to not be executed in the rest of page (especially with the i18n_navigation plugin).

To prevent these king of problem, it is possible to control that obj is different from null before reading its status property. Moreover, as mentionned in jQuery doc, parseJSON method can throws exceptions if malformed JSON is gave as parameter. So I would like to suggest this code to replace the one mentioned above :
Code:
try {
    var obj = jQuery.parseJSON('<?php echo get_api_details(); ?>');
    if(obj != null && obj.status != null && obj.status != 1) {
        $('a.support').parent('li').append('<span class="warning">!</span>');
        $('a.support').attr('href', 'health-check.php');
    }
} catch(error){
    //Something to do ?
}
Reply
#2
Absolutely

Created issue
http://code.google.com/p/get-simple-cms/...ail?id=320
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply




Users browsing this thread: 2 Guest(s)