From e1d570285388990bf280ece3b2041dcc2f409e67 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 11 Mar 2014 17:05:34 +0100 Subject: [PATCH 1/4] [ticket/12262] Also find vars array when it's defined in the trigger_event() PHPBB3-12262 --- phpBB/develop/export_events_for_wiki.php | 33 ++++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/phpBB/develop/export_events_for_wiki.php b/phpBB/develop/export_events_for_wiki.php index b276b4c5fa..ac4c4f9317 100644 --- a/phpBB/develop/export_events_for_wiki.php +++ b/phpBB/develop/export_events_for_wiki.php @@ -117,19 +117,30 @@ function check_for_events($phpbb_root_path, $file) $event_name = substr($event_name, $found_trigger_event + strlen("phpbb_dispatcher->trigger_event('")); $event_name = substr($event_name, 0, strpos($event_name, "'")); - // Find $vars array lines - $find_varsarray_line = 1; - while (strpos($lines[$event_line - $find_varsarray_line], "vars = array('") === false) + $current_line = trim($lines[$event_line]); + $arguments = array(); + if (($found_inline_array = strpos($current_line, "', compact(array('")) !== false) { - $find_varsarray_line++; - - if ($find_varsarray_line > min(50, $event_line)) - { - throw new LogicException('Can not find "$vars = array()"-line for event "' . $event_name . '" in file "' . $file . '"'); - } + $varsarray = substr($current_line, $found_inline_array + strlen("', compact(array('"), -6); + $arguments = explode("', '", $varsarray); + } + + if (empty($arguments)) + { + // Find $vars array lines + $find_varsarray_line = 1; + while (strpos($lines[$event_line - $find_varsarray_line], "vars = array('") === false) + { + $find_varsarray_line++; + + if ($find_varsarray_line > min(50, $event_line)) + { + throw new LogicException('Can not find "$vars = array()"-line for event "' . $event_name . '" in file "' . $file . '"'); + } + } + $varsarray = substr(trim($lines[$event_line - $find_varsarray_line]), strlen("\$vars = array('"), -3); + $arguments = explode("', '", $varsarray); } - $varsarray = substr(trim($lines[$event_line - $find_varsarray_line]), strlen("\$vars = array('"), -3); - $arguments = explode("', '", $varsarray); // Validate $vars array with @var $find_vars_line = 3; From 8aa22550b9e3e21ae6a744cc23a2d22a251afb3d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 11 Mar 2014 17:07:15 +0100 Subject: [PATCH 2/4] [ticket/12262] Fix location list for acp events with "Locations:" PHPBB3-12262 --- phpBB/develop/export_events_for_wiki.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/phpBB/develop/export_events_for_wiki.php b/phpBB/develop/export_events_for_wiki.php index ac4c4f9317..f843c67113 100644 --- a/phpBB/develop/export_events_for_wiki.php +++ b/phpBB/develop/export_events_for_wiki.php @@ -54,7 +54,7 @@ function export_from_eventsmd($phpbb_root_path, $filter) { $file_details = substr($file_details, strlen("* Locations:\n + ")); $files = explode("\n + ", $file_details); - $prosilver = $subsilver2 = array(); + $prosilver = $subsilver2 = $adm = array(); foreach ($files as $file) { if (strpos($file, 'styles/prosilver/template/') === 0) @@ -65,8 +65,19 @@ function export_from_eventsmd($phpbb_root_path, $filter) { $subsilver2[] = substr($file, strlen('styles/subsilver2/template/')); } + if (strpos($file, 'adm/style/') === 0) + { + $adm[] = substr($file, strlen('adm/style/')); + } + } + if ($filter == 'acp') + { + echo implode(', ', $adm); + } + else + { + echo implode(', ', $prosilver) . ' || ' . implode(', ', $subsilver2); } - echo implode(', ', $prosilver) . ' || ' . implode(', ', $subsilver2); } else if ($filter == 'acp') { From 2071abda1fac18a3b53b27ac31d2714c167c993f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 13 Mar 2014 11:43:24 +0100 Subject: [PATCH 3/4] [ticket/12262] Do not use getExtension() The method is php 5.3.6+ only. PHPBB3-12262 --- phpBB/develop/export_events_for_wiki.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/develop/export_events_for_wiki.php b/phpBB/develop/export_events_for_wiki.php index f843c67113..e8a94c1608 100644 --- a/phpBB/develop/export_events_for_wiki.php +++ b/phpBB/develop/export_events_for_wiki.php @@ -289,7 +289,7 @@ function get_file_list($dir, $path = '') $files[] = $file_info->getFilename() . '/' . $file; } } - else if ($file_info->getExtension() == 'php') + else if (substr($file_info->getFilename(), -4) == '.php') { $files[] = $file_info->getFilename(); } From 87292f534ec64364a8f64d53153004c743980a48 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 13 Mar 2014 11:59:51 +0100 Subject: [PATCH 4/4] [ticket/12262] Do not use inline assignments PHPBB3-12262 --- phpBB/develop/export_events_for_wiki.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/phpBB/develop/export_events_for_wiki.php b/phpBB/develop/export_events_for_wiki.php index e8a94c1608..3021b64e05 100644 --- a/phpBB/develop/export_events_for_wiki.php +++ b/phpBB/develop/export_events_for_wiki.php @@ -121,7 +121,8 @@ function check_for_events($phpbb_root_path, $file) for ($i = 0, $num_lines = sizeof($lines); $i < $num_lines; $i++) { $event_line = 0; - if ($found_trigger_event = strpos($lines[$i], "phpbb_dispatcher->trigger_event('")) + $found_trigger_event = strpos($lines[$i], "phpbb_dispatcher->trigger_event('"); + if ($found_trigger_event !== false) { $event_line = $i; $event_name = $lines[$event_line]; @@ -130,7 +131,8 @@ function check_for_events($phpbb_root_path, $file) $current_line = trim($lines[$event_line]); $arguments = array(); - if (($found_inline_array = strpos($current_line, "', compact(array('")) !== false) + $found_inline_array = strpos($current_line, "', compact(array('"); + if ($found_inline_array !== false) { $varsarray = substr($current_line, $found_inline_array + strlen("', compact(array('"), -6); $arguments = explode("', '", $varsarray); @@ -175,11 +177,12 @@ function check_for_events($phpbb_root_path, $file) throw new LogicException('$vars array does not match the list of @var tags for event "' . $event_name . '" in file "' . $file . '"'); } } - else if ($found_trigger_event = strpos($lines[$i], "phpbb_dispatcher->dispatch('")) + $found_dispatch = strpos($lines[$i], "phpbb_dispatcher->dispatch('"); + if ($found_dispatch !== false) { $event_line = $i; $event_name = $lines[$event_line]; - $event_name = substr($event_name, $found_trigger_event + strlen("phpbb_dispatcher->dispatch('")); + $event_name = substr($event_name, $found_dispatch + strlen("phpbb_dispatcher->dispatch('")); $event_name = substr($event_name, 0, strpos($event_name, "'")); $arguments = array(); }