Commit 2881c362 authored by David Coutadeur's avatar David Coutadeur
Browse files

write class.cache

parent a38c4c55
......@@ -32,24 +32,36 @@ copy_dir()
write_classcache()
{
# TODO: write class.cache
:
# Example:
#<?php
# $class_mapping= array(
# "NonExistingBranchException" => "/include/class_exceptions.inc",
# "setupStepLanguage" => "/setup/class_setupStepLanguage.inc",
# [...]
# );
#?>
# from every file in FD_HOME_PATH matching:
# if ( ( $file =~ /.*\.inc$/ ) && ( $file !~ /.*smarty.*/ ) ) {
# classes are extracted from these lines (2nd arg)
# /^interface\s*(\w+).*/
# and
# /^(abstract )?class\s*(\w+).*/
# Get all classes (all .inc that does not contain smarty)
CLASSES_FILES=$( find ${FD_HOME_PATH} -name '*.inc' | grep -v smarty )
RES=""
for FILE in ${CLASSES_FILES} ; do
# get lines matching "interface *" or "class *"
MATCH=$( grep -E '^(interface\s*(\w+)|(abstract )?class\s*(\w+)).*' "$FILE" \
| sed -e 's/^interface\s*\(\w\+\).*$/\1/' \
-e 's/^.*class\s*\(\w\+\).*$/\1/' )
# get truncated filename
TFILE=$( printf "%s" "$FILE" | sed -e "s#${FD_HOME_PATH}##" )
for M in ${MATCH}; do
# format result : "key" => "value"
RES="\t\t\"${M}\" => \"${TFILE}\",
$RES"
done
done
# remove empty lines
RES=$( printf "${RES}" | sed -e '/^$/d' )
# sort
RES=$( printf "${RES}" | sort )
printf "<?php\n" > ${FD_VAR_PATH}/${CLASSCACHE_FILENAME}
printf "\t\$class_mapping= array(\n" >> ${FD_VAR_PATH}/${CLASSCACHE_FILENAME}
printf "${RES}\n" >> ${FD_VAR_PATH}/${CLASSCACHE_FILENAME}
printf "\t);\n" >> ${FD_VAR_PATH}/${CLASSCACHE_FILENAME}
printf "?>\n" >> ${FD_VAR_PATH}/${CLASSCACHE_FILENAME}
}
......
  • @dcoutadeur why not rely on fusiondirectory-setup command for this? It is already called at the end of the install task

  • Because:

    • at first I didn't known fusiondirectory-setup was installed
    • this note https://gitlab.fusiondirectory.org/fusiondirectory/fd-plugins/-/issues/6128#note_110658 let me think fusiondirectory-setup is not reliable in some situation
    • actually, the --update-locales is not working, because of invalid language detection + some paths that are not correct
    • it did not seem very difficult to adapt the necessary code, especially because the fusiondirectory-setup is sometimes external commands

    Anyway we can discuss and reconsider this decision.

    Edited by dcoutadeur dcoutadeur
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment