Skip to content
Snippets Groups Projects
Unverified Commit bf96cc35 authored by Peter Rotich's avatar Peter Rotich Committed by GitHub
Browse files

Merge pull request #4688 from greezybacon/issue/i18n-oops

Fix crashes compiling language packs on PHP 7
parents a528e0f2 a4237677
Branches
Tags
No related merge requests found
......@@ -130,8 +130,11 @@ class TasksAjaxAPI extends AjaxController {
$note = array(
'title' => __('Task Created From Thread Entry'),
'note' => __('Task ' . $taskLink .
'<br /> Thread Entry: ' . $entryLink)
'note' => sprintf(__(
// %1$s is the task ID number and %2$s is the thread
// entry date
'Task %1$s<br/> Thread Entry: %2$s'),
$taskLink, $entryLink)
);
$originalTask->postNote($note, $errors, $thisstaff);
......@@ -143,7 +146,7 @@ class TasksAjaxAPI extends AjaxController {
$note = array(
'title' => __('Task Created From Thread Entry'),
'note' => __('This Task was created from Task ' . $taskLink));
'note' => sprintf(__('This Task was created from Task %1$s'), $taskLink));
$task->postNote($note, $errors, $thisstaff);
}
......
......@@ -1499,8 +1499,11 @@ function refer($tid, $target=null) {
$note = array(
'title' => __('Task Created From Thread Entry'),
'body' => __('Task ' . $taskLink .
'<br /> Thread Entry: ' . $entryLink)
'body' => sprintf(__(
// %1$s is the task ID number and %2$s is the thread
// entry date
'Task %1$s<br/> Thread Entry: %2$s'),
$taskLink, $entryLink)
);
$ticket->logNote($note['title'], $note['body'], $thisstaff);
......@@ -1512,7 +1515,8 @@ function refer($tid, $target=null) {
$note = array(
'title' => __('Task Created From Thread Entry'),
'note' => __('This Task was created from Ticket ' . $ticketLink));
'note' => sprintf(__('This Task was created from Ticket %1$s', $ticketLink))
);
$task->postNote($note, $errors, $thisstaff);
}
......
......@@ -3955,8 +3955,10 @@ implements RestrictedAccess, Threadable, Searchable {
$note = array(
'title' => __('Ticket Created From Thread Entry'),
'body' => sprintf(__('This Ticket was created from %s '. $link),
$oldTicket ? 'Ticket' : 'Task')
'body' => sprintf(__(
// %1$s is the word Ticket or Task, %2$s will be a link to it
'This Ticket was created from %1$s %2$s'),
$oldTicket ? __('Ticket') : __('Task'), $link)
);
$ticket->logNote($note['title'], $note['body'], $thisstaff);
......@@ -3973,13 +3975,15 @@ implements RestrictedAccess, Threadable, Searchable {
$ticketNote = array(
'title' => __('Ticket Created From Thread Entry'),
'body' => __('Ticket ' . $ticketLink).
'<br /> Thread Entry: ' . $entryLink);
'body' => sprintf(__('Ticket %1$s<br/> Thread Entry: %2$s'),
$ticketLink, $entryLink)
);
$taskNote = array(
'title' => __('Ticket Created From Thread Entry'),
'note' => __('Ticket ' . $ticketLink).
'<br /> Thread Entry: ' . $entryLink);
'note' => sprintf(__('Ticket %1$s<br/> Thread Entry: %2$s'),
$ticketLink, $entryLink)
);
if ($oldTicket)
$oldTicket->logNote($ticketNote['title'], $ticketNote['body'], $thisstaff);
......
......@@ -637,7 +637,7 @@ class i18n_Compiler extends Module {
);
$root = realpath($options['root'] ?: ROOT_DIR);
$domain = $options['domain'] ? '('.$options['domain'].')/' : '';
$files = Test::getAllScripts(true, $root);
$files = Test::getAllScripts("*.php", $root);
$strings = array();
foreach ($files as $f) {
$F = str_replace($root.'/', $domain, $f);
......
......@@ -31,13 +31,13 @@ class Test {
function teardown() {
}
function ignore3rdparty() {
static function ignore3rdparty() {
return true;
}
function getAllScripts($pattern='*.php', $root=false, $excludes=true) {
static function getAllScripts($pattern='*.php', $root=false, $excludes=true) {
$root = $root ?: get_osticket_root_path();
$excludes = $excludes ?: $this->ignore3rdparty();
$excludes = $excludes ?: static::ignore3rdparty();
$scripts = array();
foreach (glob_recursive("$root/$pattern") as $s) {
$found = false;
......
......@@ -5,7 +5,7 @@ class ExtraWhitespace extends Test {
var $name = "PHP Leading and Trailing Whitespace";
function testFindWhitespace() {
foreach ($this->getAllScripts() as $s) {
foreach (static::getAllScripts() as $s) {
$matches = array();
$content = file_get_contents($s);
if (preg_match_all('/^\s+<\?php|\?>\n\s+$/s',
......
......@@ -6,7 +6,7 @@ class GitConflicts extends Test {
function testFindGitConflicts() {
$regex = '/^[\t ]*?<{3,} ?HEAD[\t ]*?|^[\t ]*?>{3,}[\t ]*?/m';
foreach ($this->getAllScripts('*') as $s) {
foreach (static::getAllScripts('*') as $s) {
$matches = array();
$content = file_get_contents($s);
if (preg_match_all($regex,
......
......@@ -6,7 +6,7 @@ class JsSyntaxTest extends Test {
function testLintErrors() {
$exit = 0;
foreach ($this->getAllScripts('*.js') as $s) {
foreach (static::getAllScripts('*.js') as $s) {
ob_start();
system("jsl -process $s", $exit);
$line = ob_get_contents();
......
......@@ -5,7 +5,7 @@ class ShortOpenTag extends Test {
var $name = "PHP Short Open Checks";
function testFindShortOpens() {
foreach ($this->getAllScripts() as $s) {
foreach (static::getAllScripts() as $s) {
$matches = array();
$content = file_get_contents($s);
if (preg_match_all('/<\?\s*(?!php|xml).*$/m',
......
......@@ -8,7 +8,7 @@ class SignalsTest extends Test {
* Ensures that each signal subscribed to has a sender somewhere else
*/
function testFindSignalPublisher() {
$scripts = $this->getAllScripts();
$scripts = static::getAllScripts();
$matches = $published_signals = array();
foreach ($scripts as $s)
if (preg_match_all("/^ *Signal::send\('([^']+)'/m",
......
......@@ -4,13 +4,13 @@ require_once "class.test.php";
class SyntaxTest extends Test {
var $name = "PHP Syntax Checks";
function ignore3rdparty() {
static function ignore3rdparty() {
return false;
}
function testCompileErrors() {
$exit = 0;
foreach ($this->getAllScripts() as $s) {
foreach (static::getAllScripts() as $s) {
ob_start();
system("php -l $s", $exit);
$line = ob_get_contents();
......
......@@ -4,12 +4,12 @@ require_once "class.test.php";
class UndefinedMethods extends Test {
var $name = "Access to undefined object methods";
function ignore3rdparty() {
static function ignore3rdparty() {
return false;
}
function testUndefinedMethods() {
$scripts = $this->getAllScripts();
$scripts = static::getAllScripts();
$function_defs = array();
foreach ($scripts as $s) {
$matches = array();
......
......@@ -6,7 +6,7 @@ class UnitializedVars extends Test {
var $name = "Access to unitialized variables";
function testUnitializedUsage() {
$scripts = $this->getAllScripts();
$scripts = static::getAllScripts();
$matches = array();
foreach ($scripts as $s) {
$a = new SourceAnalyzer($s);
......
......@@ -6,7 +6,7 @@ class VarDump extends Test {
function testFindShortOpens() {
$re = '/^(([\t ]*?)var_dump\(.*[\)|,|;])((?!nolint).)*$/m';
foreach ($this->getAllScripts() as $s) {
foreach (static::getAllScripts() as $s) {
$matches = array();
$content = file_get_contents($s);
if (preg_match_all($re,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment