2015-06-06, 12:29 PM
(2015-06-04, 09:09 PM)Euan T Wrote: [ -> ](2015-06-04, 12:27 PM)Adamas Wrote: [ -> ]Strange. If it's an error 500, it should be logged by the server explaining what the actual error is. Without the error message, it's very difficult to establish the cause.(2015-06-04, 11:29 AM)Euan T Wrote: [ -> ](2015-06-04, 10:09 AM)Adamas Wrote: [ -> ]Euan, when I install MyAlerts, I get a white page when I try to activate it. Do you have any clue what might be going on here?Hi,
Can you check your server error log and post any errors contained in there?
None of my error logs indicate there's any problem, which is odd. I opened up the Network tab in Chrome's Dev Tools, it's an error 500. All I can tell ATM. *scratches head*
Edit: Narrowed down. It's something within the _activate() function, but I don't know what. I put code at the start and end, then activated: the code at the start ran but the end didn't. My activate function is below.
global $db, $lang, $PL, $plugins, $cache; if (!$lang->myalerts) { $lang->load('myalerts'); } if (!file_exists(PLUGINLIBRARY)) { flash_message($lang->myalerts_pluginlibrary_missing, 'error'); admin_redirect('index.php?module=config-plugins'); } $PL or require_once PLUGINLIBRARY; if ($PL->version < 9) { flash_message('This plugin requires PluginLibrary 9 or newer', 'error'); admin_redirect('index.php?module=config-plugins'); } $plugin_info = myalerts_info(); $euantorPlugins = $cache->read('euantor_plugins'); if (!empty($euantorPlugins) && isset($euantorPlugins['myalerts'])) { $oldVersion = $euantorPlugins['myalerts']; if ($oldVersion['version'] == '1.05') { myalerts_upgrade_105_200(); } } $euantorPlugins['myalerts'] = array( 'title' => 'MyAlerts', 'version' => $plugin_info['version'], ); $cache->update('euantor_plugins', $euantorPlugins); $PL->settings( 'myalerts', $lang->setting_group_myalerts, $lang->setting_group_myalerts_desc, array( 'perpage' => array( 'title' => $lang->setting_myalerts_perpage, 'description' => $lang->setting_myalerts_perpage_desc, 'value' => '10', 'optionscode' => 'text', ), 'dropdown_limit' => array( 'title' => $lang->setting_myalerts_dropdown_limit, 'description' => $lang->setting_myalerts_dropdown_limit_desc, 'value' => '5', 'optionscode' => 'text', ), 'autorefresh' => array( 'title' => $lang->setting_myalerts_autorefresh, 'description' => $lang->setting_myalerts_autorefresh_desc, 'value' => '0', 'optionscode' => 'text', ), 'avatar_size' => array( 'title' => $lang->setting_myalerts_avatar_size, 'description' => $lang->setting_myalerts_avatar_size_desc, 'optionscode' => 'text', 'value' => '64|64', ), ) ); $dir = new DirectoryIterator(MYALERTS_PLUGIN_PATH . '/templates'); $templates = array(); foreach ($dir as $file) { if (!$file->isDot() && !$file->isDir() && $file->getExtension() == 'html') { $templateName = $file->getPathname(); $templateName = basename($templateName, '.html'); $templates[$templateName] = file_get_contents($file->getPathName()); } } $PL->templates( 'myalerts', 'MyAlerts', $templates ); $stylesheet = file_get_contents(MYALERTS_PLUGIN_PATH . '/stylesheets/alerts.css'); $PL->stylesheet('alerts.css', $stylesheet); // Attach usercp.css to alerts.php $query = $db->simple_select('themestylesheets', 'sid,attachedto,tid', "name = 'usercp.css'"); while ($userCpStylesheet = $db->fetch_array($query)) { $sid = (int) $userCpStylesheet['sid']; $db->update_query('themestylesheets', array( 'attachedto' => $db->escape_string($userCpStylesheet['attachedto'] . '|alerts.php'), ), "sid = {$sid}" ); update_theme_stylesheet_list((int) $userCpStylesheet['tid']); } require_once MYBB_ROOT . '/inc/adminfunctions_templates.php'; find_replace_templatesets('headerinclude', '/$/', '{$myalerts_js}'); find_replace_templatesets( 'header_welcomeblock_member', "#" . preg_quote('{$modcplink}') . "#i", '{$myalerts_headericon}{$modcplink}' ); find_replace_templatesets( 'footer', '/$/', '{$myalerts_modal}' ); $taskExists = $db->simple_select('tasks', 'tid', 'file = \'myalerts\'', array('limit' => '1')); if ($db->num_rows($taskExists) == 0) { require_once MYBB_ROOT . '/inc/functions_task.php'; $myTask = array( 'title' => $lang->myalerts_task_title, 'file' => 'myalerts', 'description' => $lang->myalerts_task_description, 'minute' => 0, 'hour' => 1, 'day' => '*', 'weekday' => 1, 'month' => '*', 'nextrun' => TIME_NOW + 3600, 'lastrun' => 0, 'enabled' => 1, 'logging' => 1, 'locked' => 0, ); $task_id = $db->insert_query('tasks', $myTask); $theTask = $db->fetch_array($db->simple_select('tasks', '*', 'tid = ' . (int) $task_id, 1)); $nextrun = fetch_next_run($theTask); $db->update_query('tasks', 'nextrun = ' . $nextrun, 'tid = ' . (int) $task_id); $plugins->run_hooks('admin_tools_tasks_add_commit'); $cache->update_tasks(); } else { require_once MYBB_ROOT . '/inc/functions_task.php'; $theTask = $db->fetch_array($db->simple_select('tasks', '*', 'file = \'myalerts\'', 1)); $db->update_query('tasks', array('enabled' => 1, 'nextrun' => fetch_next_run($theTask)), 'file = \'myalerts\''); $cache->update_tasks(); } $plugins->run_hooks('myalerts_activate');
Edit again: It's in the GitHub repo too. Ran that code, no dice. I'm about to go to sleep, so if it's of any use, my PHP version is 5.3.23, Apache 2.2.27.
Hello again Euan, did some more narrowing down of code, it appears to be something to do with this piece of code:
$dir = new DirectoryIterator(MYALERTS_PLUGIN_PATH . '/templates');
$templates = array();
foreach ($dir as $file) {
if (!$file->isDot() && !$file->isDir() && $file->getExtension() == 'html') {
$templateName = $file->getPathname();
$templateName = basename($templateName, '.html');
$templates[$templateName] = file_get_contents($file->getPathName());
}
}
Specifically the foreach. Before this, code runs. Nothing runs after it. It appears the $file object is empty, as echoing $templateName does nothing, but echoing random strings works. Will do some more testing and get back.
Edit: Curiouser and curiouser. The if statement is failing. PHP is 5.3.28 so the methods required do, in fact, exist...