TypoScript conditions with symfony expression language throws error - typo3

I have following typoscript condition:
[request.getNormalizedParams().getHttpHost() == 'www.domain.com' && traverse(request.getQueryParams(), 'tx_news_pi1/news') > 0 && {$const.pid.pageX} in tree.rootLineIds]
which throws this error in the TYPO3 log:
Thu, 24 Sep 2020 06:52:04 +0200 [ERROR] request="2fa420fbc8c67" component="TYPO3.CMS.Frontend.Configuration.TypoScript.ConditionMatching.ConditionMatcher": Unable to get a property on a non-object. - {"expression":"request.getNormalizedParams().getHttpHost() == 'www.domain.com' && traverse(request.getQueryParams(), 'tx_news_pi1/news') > 0 && 11 in tree.rootLineIds","exception":"RuntimeException: Unable to get a property on a non-object. in /var/www/typo3cms/typo3_src-10.4.8/vendor/symfony/expression-language/Node/GetAttrNode.php:83
The problem seems to be the request.getNormalizedParams().getHttpHost() when the cronjob calls typo3/sysext/core/bin/typo3 scheduler:run.
How can I get rid of the error in the log file?

Changing the condition to the following removes the entries from the log file:
[request.getNormalizedParams() && request.getNormalizedParams().getHttpHost() == 'www.domain.com' && traverse(request.getQueryParams(), 'tx_news_pi1/news') > 0 && {$const.pid.pageX} in tree.rootLineIds]
So I just added the request.getNormalizedParams() && at the beginning of the condition.

Related

In neovim, how do I get a file to open at the same line number I closed it at last time?

au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
This code is valid in vim. It is the syntax of vimscript. It can also work in neovim's configuration file init.vim. how can I achieve the same effect in init.lua?
Tested on 0.7.2, if not available, the version may be too low.
vim.api.nvim_create_autocmd("BufReadPost", {
pattern = {"*"},
callback = function()
if vim.fn.line("'\"") > 1 and vim.fn.line("'\"") <= vim.fn.line("$") then
vim.api.nvim_exec("normal! g'\"",false)
end
end
})

How to convert a string to Date in red

If I accept a date from a user using ask and then wish to use it as a Date by using to-date, I get an error.
>> to-date "31-Dec-2019"
*** Script Error: cannot MAKE/TO date! from: "31-Dec-2019"
*** Where: to
*** Stack: to-date
What is the correct way of converting a string to date ?
You have to use load
>> load "31-Dec-2019"
== 31-Dec-2019
a few examples for to-date!
>> to-date 1547196008
== 11-Jan-2019/8:40:08
>> to-date [200 1 1]
== 1-Jan-0200

TYPO3 version 6 to version 8 compatibility issues

While upgrading typo3 version 6 to 8.7.3 getting this database error...
An exception occurred while executing 'SELECT `pid` FROM `sys_template` WHERE (root = 1 AND deleted = 0 AND hidden = 0 AND starttime <= :starttime AND (endtime = 0 OR endtime > :endtime)) AND ((`sys_template`.`deleted` = 0) AND (`sys_template`.`hidden` = 0) AND (`sys_template`.`starttime` <= 1500543000) AND ((`sys_template`.`endtime` = 0) OR (`sys_template`.`endtime` > 1500543000)))': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':starttime AND (endtime = 0 OR endtime > :endtime)) AND ((`sys_template`.`delete' at line 1
Please review the screen shot.
DB Configuration variables have changed from TYPO3 v7 to v8 ^^
It is not
$GLOBALS['TYPO3_CONF_VARS']['DB']['database']
$GLOBALS['TYPO3_CONF_VARS']['DB']['host']
$GLOBALS['TYPO3_CONF_VARS']['DB']['username']
$GLOBALS['TYPO3_CONF_VARS']['DB']['password']
anymore, but
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['host']
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['dbname']
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['user']
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['password']
This is especially the case, when configuring additional Environments via AdditionalConfiguration.php

How to define AM_CONDITIONAL and AC_DEFINE based on PKG_CHECK_MODULES result?

I am trying to write a configure.ac file to do these tasks:
The configure script should accept a --with-libuv parameter.
A variable with_libuv should be set to either yes, no or check (with check being the default value when nothing was passed on the command line).
When with_libuv == "yes" a mandatory PKG_CHECK_MODULES check for libuv >= 1.9.0 should be done and HAVE_LIBUV = 1 should be set on success (On error configure should abort).
When with_libuv == "no" nothing should be checked,
When with_libuv == "false" an optional PKG_CHECK_MODULES check (for the same library as in 3.) should be done and HAVE_LIBUV should be set to either 0 or 1 accordingly.
If with_libuv != "no" && HAVE_LIBUV == 1 AC_DEFINE should set -DUSE_LIBUV and AM_CONDITIONAL should set USE_LIBUV as a conditional for automake.
If not with_libuv != "no" && HAVE_LIBUV == 1 the preprocessor directive should not be set and the AM_CONDITIONAL should be set to 0.
I have figured out how to do steps 1-5, but I am struggeling with 6 and 7.
Here is my current attempt:
AC_INIT(
[mumble-pluginbot-plusplus],
[0.5],
[https://github.com/promi/mumble-pluginbot-plusplus/issues],
[],
[https://github.com/promi/mumble-pluginbot-plusplus])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign])
AM_SILENT_RULES([yes])
AC_PROG_CXX
LT_INIT
# Make sure that pkg-config is installed!
# The PKG_CHECK_MODULES macro prints a horrible error message when
# pkg-config is not installed at autogen time.
#
# It is also required when the first PKG_CHECK_MODULES is inside a conditional
PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES(OPUS, [opus >= 1.1])
PKG_CHECK_MODULES(OPENSSL, [openssl])
PKG_CHECK_MODULES(PROTOBUF, [protobuf])
PKG_CHECK_MODULES(MPDCLIENT, [libmpdclient])
AC_ARG_WITH(
[libuv],
[AS_HELP_STRING([--with-libuv], [support efficient MPD status polling #<:#default=check#:>#])],
[],
[with_libuv=check])
# if --with-libuv -> it must be installed
# elseif --without-libuv -> do nothing
# else -> check whether it is installed
AS_CASE(
["$with_libuv"],
[yes], [PKG_CHECK_MODULES(UV, [libuv >= 1.9.0], [HAVE_LIBUV=1])],
[no], [],
[PKG_CHECK_MODULES(UV, [libuv >= 1.9.0], [HAVE_LIBUV=1], [HAVE_LIBUV=0])])
if test "$with_libuv" != no -a "x$HAVE_LIBUV" -eq x1; then
AM_CONDITIONAL([USE_LIBUV], [1])
AC_DEFINE([USE_LIBUV], [1], [Define when libuv should be used.])
else
AM_CONDITIONAL([USE_LIBUV], [0])
fi
#AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
The problematic part is this:
if test "$with_libuv" != no -a "x$HAVE_LIBUV" -eq x1; then
AM_CONDITIONAL([USE_LIBUV], [1])
AC_DEFINE([USE_LIBUV], [1], [Define when libuv should be used.])
else
AM_CONDITIONAL([USE_LIBUV], [0])
fi
Here is an excerpt from the configure output:
checking pkg-config is at least version 0.9.0... yes
checking for OPUS... yes
checking for OPENSSL... yes
checking for PROTOBUF... yes
checking for MPDCLIENT... yes
checking for UV... yes
./configure: line 16467: test: x1: integer expression expected
./configure: line 16480: 0: command not found
checking that generated files are newer than configure... done
How can I implement steps 6 and 7 in a way that actually works?
You aren't aborting when yes fails (step 3). AM_CONDITIONAL should always be run. Step 6 says -DUSE_LIBUV, but your existing code will add -DUSE_LIBUV=1 to DEFS. Portable shell scripting considers test -a broken, so you shouldn't be using that. Your no case is equivalent to the check (or false) case where the search fails.
AS_CASE(
["$with_libuv"],
[yes], [PKG_CHECK_MODULES(UV, [libuv >= 1.9.0], [HAVE_LIBUV=1],
[AC_MSG_ERROR("libuv >= 1.9.0 is not installed")])],
[no], [HAVE_LIBUV=0],
[PKG_CHECK_MODULES(UV, [libuv >= 1.9.0], [HAVE_LIBUV=1],[HAVE_LIBUV=0])])
AS_IF([test "x$HAVE_LIBUV" = x1], [AC_DEFINE([USE_LIBUV])])
AM_CONDITIONAL([USE_LIBUV], [test "x$HAVE_LIBUV" = x1])
I think you should use = instead of -eq. The -eq is a relation between integers - the x1 isn't integer!
if test "$with_libuv" != no -a "x$HAVE_LIBUV" -eq x1; then
replace to
if test "$with_libuv" != no -a "x$HAVE_LIBUV" = x1; then
This should do the trick:
if test "$with_libuv" != no -a "x$HAVE_LIBUV" == x1; then
AC_DEFINE([USE_LIBUV], [1], [Define when libuv should be used.])
fi
AM_CONDITIONAL([USE_LIBUV], [test "$with_libuv" != no -a "x$HAVE_LIBUV" == x1])
It's a bit ugly, because the test is executed twice, but it seems to work ok.

Print When Expression Jasper reports

Is the following Print When Expression invaild:
29 <= $F{selfawarenesscore} <= 45
I get the following error in JasperReports Server
com.jaspersoft.jasperserver.api.JSExceptionWrapper:
Errors were encountered when compiling report expressions class file:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
calculator_subreport2_EmotionalSelfAwareness40QI41_1370531739954_546871: 233:
unexpected token: <= # line 233, column 83. 1 error
I want to print a text field when $F{selfawarenesscore} is the above mentioned range.
Any help is appreciated.
Try:
$F{selfawarenessscore} >= 29 && $F{selfawarenessscore} <= 45