aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rw-r--r--build/build.xml145
-rwxr-xr-xbuild/build_announcement.php50
-rwxr-xr-xbuild/build_changelog.php12
-rw-r--r--build/build_helper.php69
-rw-r--r--build/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php222
-rw-r--r--build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php234
-rw-r--r--build/code_sniffer/ruleset-minimum.xml15
-rw-r--r--build/code_sniffer/ruleset-php-extensions.xml8
-rw-r--r--build/code_sniffer/ruleset-php-legacy-core.xml11
-rw-r--r--build/code_sniffer/ruleset-php-legacy.xml89
-rw-r--r--build/code_sniffer/ruleset-php-strict-core.xml9
-rw-r--r--build/code_sniffer/ruleset-php-strict.xml48
-rwxr-xr-xbuild/package.php142
13 files changed, 993 insertions, 61 deletions
diff --git a/build/build.xml b/build/build.xml
index 3c0f4dc592..a8d34d3db1 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -2,9 +2,9 @@
<project name="phpBB" description="The phpBB forum software" default="all" basedir="../">
<!-- a few settings for the build -->
- <property name="newversion" value="3.0.13-PL1" />
- <property name="prevversion" value="3.0.13" />
- <property name="olderversions" value="3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.0.7-PL1, 3.0.8, 3.0.9, 3.0.10, 3.0.11, 3.0.12" />
+ <property name="newversion" value="3.1.3-RC1" />
+ <property name="prevversion" value="3.1.2" />
+ <property name="olderversions" value="3.0.12, 3.0.13, 3.0.13-PL1, 3.1.0-a1, 3.1.0-a2, 3.1.0-a3, 3.1.0-b1, 3.1.0-b2, 3.1.0-b3, 3.1.0-b4, 3.1.0-RC1, 3.1.0-RC2, 3.1.0-RC3, 3.1.0-RC4, 3.1.0-RC5, 3.1.0-RC6, 3.1.0, 3.1.1, 3.1.2-RC1" />
<!-- no configuration should be needed beyond this point -->
<property name="oldversions" value="${olderversions}, ${prevversion}" />
@@ -73,6 +73,50 @@
passthru="true" />
</target>
+ <target name="sniff">
+ <exec command="phpBB/vendor/bin/phpcs
+ -s
+ --extensions=php
+ --standard=build/code_sniffer/ruleset-php-strict-core.xml
+ --ignore=${project.basedir}/phpBB/phpbb/db/migration/data/v30x/*
+ phpBB/phpbb"
+ dir="." returnProperty="retval-php-strict" passthru="true" />
+ <exec command="phpBB/vendor/bin/phpcs
+ -s
+ --extensions=php
+ --standard=build/code_sniffer/ruleset-php-legacy-core.xml
+ --ignore=${project.basedir}/phpBB/cache/*
+ --ignore=${project.basedir}/phpBB/develop/*
+ --ignore=${project.basedir}/phpBB/ext/*
+ --ignore=${project.basedir}/phpBB/includes/diff/*.php
+ --ignore=${project.basedir}/phpBB/includes/sphinxapi.php
+ --ignore=${project.basedir}/phpBB/includes/utf/data/*
+ --ignore=${project.basedir}/phpBB/install/data/*
+ --ignore=${project.basedir}/phpBB/install/database_update.php
+ --ignore=${project.basedir}/phpBB/phpbb/*
+ --ignore=${project.basedir}/phpBB/vendor/*
+ phpBB"
+ dir="." returnProperty="retval-php-legacy" passthru="true" />
+ <exec command="phpBB/vendor/bin/phpcs
+ -s
+ --extensions=php
+ --standard=build/code_sniffer/ruleset-php-extensions.xml
+ --ignore=${project.basedir}/phpBB/ext/*/tests/*
+ --ignore=${project.basedir}/phpBB/ext/*/vendor/*
+ phpBB/ext"
+ dir="." returnProperty="retval-php-ext" passthru="true" />
+ <if>
+ <or>
+ <not><equals arg1="${retval-php-strict}" arg2="0" /></not>
+ <not><equals arg1="${retval-php-legacy}" arg2="0" /></not>
+ <not><equals arg1="${retval-php-ext}" arg2="0" /></not>
+ </or>
+ <then>
+ <fail message="PHP Code Sniffer failed." />
+ </then>
+ </if>
+ </target>
+
<!-- Builds docs for current branch into build/api/output/master -->
<target name="docs">
<exec dir="."
@@ -107,6 +151,7 @@
<exec dir="build/old_versions" command="LC_ALL=C diff -crNEBwd release-${version} release-${newversion} >
../new_version/patches/phpBB-${version}_to_${newversion}.patch" escape="false" />
+ <exec dir="build/old_versions" command="LC_ALL=C diff -qr release-${version} release-${newversion} | grep 'Only in release-${version}' > ../new_version/patches/phpBB-${version}_to_${newversion}.deleted" escape="false" />
</target>
<target name="prepare-new-version">
@@ -221,7 +266,7 @@
command="git archive ${revision} composer.phar | tar -xf - -C ${dir}"
checkreturn="true" />
<exec dir="${dir}"
- command="php composer.phar install --no-dev"
+ command="php composer.phar install --no-dev --optimize-autoloader"
checkreturn="true"
passthru="true" />
<delete file="${dir}/composer.phar" />
@@ -235,10 +280,17 @@
</else>
</if>
+ <!-- Create schema.json -->
+ <exec dir="${dir}" command="php develop/create_schema_files.php" />
+
<delete file="${dir}/config.php" />
<delete dir="${dir}/develop" />
<delete dir="${dir}/install/data" />
+ <phingcall target="clean-vendor-dir">
+ <property name="dir" value="${dir}" />
+ </phingcall>
+
<echo msg="Setting permissions for checkout of ${revision} in ${dir}" />
<!-- set permissions of all files to 644, directories to 755 -->
<exec dir="${dir}" command="find . -type f|xargs chmod 644" escape="false" />
@@ -250,6 +302,91 @@
<chmod mode="0777" file="${dir}/images/avatars/upload" />
</target>
+ <target name="clean-vendor-dir">
+ <!-- Delete unrelated files from vendor/, see PHPBB3-12390 -->
+ <delete dir="${dir}/vendor/lusitanian/oauth/examples" />
+ <delete dir="${dir}/vendor/lusitanian/oauth/tests" />
+ <delete file="${dir}/vendor/lusitanian/oauth/.gitignore" />
+ <delete file="${dir}/vendor/lusitanian/oauth/.travis.yml" />
+ <delete file="${dir}/vendor/lusitanian/oauth/phpunit.xml.dist" />
+ <delete file="${dir}/vendor/lusitanian/oauth/README.md" />
+
+ <delete dir="${dir}/vendor/psr/log/Psr/Log/Test" />
+ <delete file="${dir}/vendor/psr/log/.gitignore" />
+ <delete file="${dir}/vendor/psr/log/README.md" />
+
+ <delete dir="${dir}/vendor/symfony/config/Symfony/Component/Config/Tests" />
+ <delete file="${dir}/vendor/symfony/config/Symfony/Component/Config/.gitignore" />
+ <delete file="${dir}/vendor/symfony/config/Symfony/Component/Config/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/config/Symfony/Component/Config/README.md" />
+ <delete file="${dir}/vendor/symfony/config/Symfony/Component/Config/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/console/Symfony/Component/Console/Tests" />
+ <delete file="${dir}/vendor/symfony/console/Symfony/Component/Console/.gitignore" />
+ <delete file="${dir}/vendor/symfony/console/Symfony/Component/Console/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/console/Symfony/Component/Console/README.md" />
+ <delete file="${dir}/vendor/symfony/console/Symfony/Component/Console/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/debug/Symfony/Component/Debug/Tests" />
+ <delete file="${dir}/vendor/symfony/debug/Symfony/Component/Debug/.gitignore" />
+ <delete file="${dir}/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/debug/Symfony/Component/Debug/README.md" />
+ <delete file="${dir}/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests" />
+ <delete file="${dir}/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/.gitignore" />
+ <delete file="${dir}/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/README.md" />
+ <delete file="${dir}/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests" />
+ <delete file="${dir}/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore" />
+ <delete file="${dir}/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md" />
+ <delete file="${dir}/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/filesystem/Symfony/Component/Filesystem/Tests" />
+ <delete file="${dir}/vendor/symfony/filesystem/Symfony/Component/Filesystem/.gitignore" />
+ <delete file="${dir}/vendor/symfony/filesystem/Symfony/Component/Filesystem/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/filesystem/Symfony/Component/Filesystem/README.md" />
+ <delete file="${dir}/vendor/symfony/filesystem/Symfony/Component/Filesystem/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests" />
+ <delete file="${dir}/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/.gitignore" />
+ <delete file="${dir}/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md" />
+ <delete file="${dir}/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests" />
+ <delete file="${dir}/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitignore" />
+ <delete file="${dir}/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md" />
+ <delete file="${dir}/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/routing/Symfony/Component/Routing/Tests" />
+ <delete file="${dir}/vendor/symfony/routing/Symfony/Component/Routing/.gitignore" />
+ <delete file="${dir}/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/routing/Symfony/Component/Routing/README.md" />
+ <delete file="${dir}/vendor/symfony/routing/Symfony/Component/Routing/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/yaml/Symfony/Component/Yaml/Tests" />
+ <delete file="${dir}/vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore" />
+ <delete file="${dir}/vendor/symfony/yaml/Symfony/Component/Yaml/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/yaml/Symfony/Component/Yaml/README.md" />
+ <delete file="${dir}/vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/twig/twig/doc" />
+ <delete dir="${dir}/vendor/twig/twig/ext" />
+ <delete dir="${dir}/vendor/twig/twig/test" />
+ <delete file="${dir}/vendor/twig/twig/.editorconfig" />
+ <delete file="${dir}/vendor/twig/twig/.gitignore" />
+ <delete file="${dir}/vendor/twig/twig/.travis.yml" />
+ <delete file="${dir}/vendor/twig/twig/AUTHORS" />
+ <delete file="${dir}/vendor/twig/twig/CHANGELOG" />
+ <delete file="${dir}/vendor/twig/twig/phpunit.xml.dist" />
+ <delete file="${dir}/vendor/twig/twig/README.markdown" />
+ </target>
+
<target name="clean-diff-dir">
<delete dir="${dir}/cache" />
<delete dir="${dir}/docs" />
diff --git a/build/build_announcement.php b/build/build_announcement.php
index 3ee96fc67d..0718bbc82a 100755
--- a/build/build_announcement.php
+++ b/build/build_announcement.php
@@ -2,9 +2,13 @@
<?php
/**
*
-* @package build
-* @copyright (c) 2013 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -22,16 +26,20 @@ $checksum_algorithm = $_SERVER['argv'][4];
$series_version = substr($version, 0, 3);
$base_url = "https://download.phpbb.com/pub/release/$series_version";
-if (strpos($version, 'RC') === false)
+if (version_compare($version, "$series_version.0", '<'))
+{
+ // Everything before 3.x.0, i.e. unstable (e.g. alpha, beta, rc)
+ $url = "$base_url/unstable/$version";
+}
+else if (strpos($version, 'RC') !== false)
{
- // Final release
- $install_url = "$base_url/$version";
- $update_url = "$base_url/update/to_$version";
+ // Release candidate of stable release
+ $url = "$base_url/qa/$version";
}
else
{
- $install_url = "$base_url/release_candidates/$version";
- $update_url = "$base_url/release_candidates/update/other_to_$version";
+ // Stable release (e.g. 3.x.0, 3.x.1, 3.x.2, 3.x.3-PL1)
+ $url = "$base_url/$version";
}
if ($mode === 'bbcode')
@@ -58,41 +66,19 @@ function phpbb_string_ends_with($haystack, $needle)
return substr($haystack, -strlen($needle)) === $needle;
}
-function phpbb_is_update_file($filename)
-{
- return strpos($filename, '_to_') !== false;
-}
-
function phpbb_get_checksum($checksum_file)
{
return array_shift(explode(' ', file_get_contents($checksum_file)));
}
-$install_files = $update_files = array();
foreach (phpbb_rnatsort(array_diff(scandir($root), array('.', '..'))) as $filename)
{
if (phpbb_string_ends_with($filename, $checksum_algorithm))
{
continue;
}
- else if (phpbb_is_update_file($filename))
- {
- $update_files[] = $filename;
- }
else
{
- $install_files[] = $filename;
+ printf($template, $url, $filename, phpbb_get_checksum("$root/$filename.$checksum_algorithm"));
}
}
-
-foreach ($install_files as $filename)
-{
- printf($template, $install_url, $filename, phpbb_get_checksum("$root/$filename.$checksum_algorithm"));
-}
-
-echo "\n";
-
-foreach ($update_files as $filename)
-{
- printf($template, $update_url, $filename, phpbb_get_checksum("$root/$filename.$checksum_algorithm"));
-}
diff --git a/build/build_changelog.php b/build/build_changelog.php
index 1e80959adf..2d38480f9f 100755
--- a/build/build_changelog.php
+++ b/build/build_changelog.php
@@ -2,9 +2,13 @@
<?php
/**
*
-* @package build
-* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -16,7 +20,7 @@ if ($_SERVER['argc'] != 2)
$fixVersion = $_SERVER['argv'][1];
-$query = 'project = PHPBB3
+$query = 'project IN (PHPBB3, SECURITY)
AND resolution = Fixed
AND fixVersion = "' . $fixVersion . '"
AND status IN ("Unverified Fix", Closed)';
diff --git a/build/build_helper.php b/build/build_helper.php
index d6169b913b..35e8cd744b 100644
--- a/build/build_helper.php
+++ b/build/build_helper.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package build
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -312,4 +316,63 @@ class build_package
return $result;
}
+
+ /**
+ * Collect the list of the deleted files from a list of deleted files and folders.
+ *
+ * @param string $deleted_filename The full path to a file containing the list of deleted files and directories
+ * @param string $package_name The name of the package
+ * @return array
+ */
+ public function collect_deleted_files($deleted_filename, $package_name)
+ {
+ $result = array();
+ $file_contents = file($deleted_filename);
+
+ foreach ($file_contents as $filename)
+ {
+ $filename = trim($filename);
+
+ if (!$filename)
+ {
+ continue;
+ }
+
+ $filename = str_replace('Only in ' . $package_name, '', $filename);
+ $filename = ltrim($filename, '/');
+
+ if (substr($filename, 0, 1) == ':')
+ {
+ $replace = '';
+ }
+ else
+ {
+ $replace = '/';
+ }
+
+ $filename = str_replace(': ', $replace, $filename);
+
+ if (is_dir("{$this->locations['old_versions']}{$package_name}/{$filename}"))
+ {
+ $iterator = new \RecursiveIteratorIterator(
+ new \RecursiveDirectoryIterator(
+ "{$this->locations['old_versions']}{$package_name}/{$filename}",
+ \FilesystemIterator::UNIX_PATHS | \FilesystemIterator::SKIP_DOTS
+ ),
+ \RecursiveIteratorIterator::LEAVES_ONLY
+ );
+
+ foreach ($iterator as $file_info)
+ {
+ $result[] = "{$filename}/{$iterator->getSubPathname()}";
+ }
+ }
+ else
+ {
+ $result[] = $filename;
+ }
+ }
+
+ return $result;
+ }
}
diff --git a/build/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php b/build/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php
new file mode 100644
index 0000000000..8337cf02ee
--- /dev/null
+++ b/build/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php
@@ -0,0 +1,222 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+/**
+* Checks that each PHP source file contains a valid header as defined by the
+* phpBB Coding Guidelines.
+*
+* @package code_sniffer
+* @author Manuel Pichler <mapi@phpundercontrol.org>
+*/
+class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
+{
+ /**
+ * Returns an array of tokens this test wants to listen for.
+ *
+ * @return array
+ */
+ public function register()
+ {
+ return array(T_OPEN_TAG);
+ }
+
+ /**
+ * Processes this test, when one of its tokens is encountered.
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+ * @param int $stackPtr The position of the current token
+ * in the stack passed in $tokens.
+ *
+ * @return null
+ */
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ {
+ // We are only interested in the first file comment.
+ if ($stackPtr !== 0)
+ {
+ if ($phpcsFile->findPrevious(T_OPEN_TAG, $stackPtr - 1) !== false)
+ {
+ return;
+ }
+ }
+
+ // Fetch next non whitespace token
+ $tokens = $phpcsFile->getTokens();
+ $start = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, null, true);
+
+ // Skip empty files
+ if ($tokens[$start]['code'] === T_CLOSE_TAG)
+ {
+ return;
+ }
+ // Mark as error if this is not a doc comment
+ else if ($start === false || $tokens[$start]['code'] !== T_DOC_COMMENT)
+ {
+ $phpcsFile->addError('Missing required file doc comment.', $stackPtr);
+ return;
+ }
+
+ // Find comment end token
+ $end = $phpcsFile->findNext(T_DOC_COMMENT, $start + 1, null, true) - 1;
+
+ // If there is no end, skip processing here
+ if ($end === false)
+ {
+ return;
+ }
+
+ // List of found comment tags
+ $tags = array();
+
+ // check comment lines without the first(/**) an last(*/) line
+ for ($i = $start + 1, $c = $end - 1; $i <= $c; ++$i)
+ {
+ $line = $tokens[$i]['content'];
+
+ // Check that each line starts with a '*'
+ if (substr($line, 0, 1) !== '*' && substr($line, 0, 2) !== ' *')
+ {
+ $message = 'The file doc comment should not be indented.';
+ $phpcsFile->addWarning($message, $i);
+ }
+ else if (preg_match('/^[ ]?\*\s+@([\w]+)\s+(.*)$/', $line, $match) !== 0)
+ {
+ if (!isset($tags[$match[1]]))
+ {
+ $tags[$match[1]] = array();
+ }
+
+ $tags[$match[1]][] = array($match[2], $i);
+ }
+ }
+
+ // Check that the first and last line is empty
+ if (trim($tokens[$start + 1]['content']) !== '*')
+ {
+ $message = 'The first file comment line should be empty.';
+ $phpcsFile->addWarning($message, ($start + 1));
+ }
+ if (trim($tokens[$end - 1]['content']) !== '*')
+ {
+ $message = 'The last file comment line should be empty.';
+ $phpcsFile->addWarning($message, $end - 1);
+ }
+
+ //$this->processPackage($phpcsFile, $start, $tags);
+ //$this->processVersion($phpcsFile, $start, $tags);
+ $this->processCopyright($phpcsFile, $start, $tags);
+ $this->processLicense($phpcsFile, $start, $tags);
+ }
+
+ /**
+ * Checks that the tags array contains a valid package tag
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param integer The stack pointer for the first comment token.
+ * @param array(string=>array) $tags The found file doc comment tags.
+ *
+ * @return null
+ */
+ protected function processPackage(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ {
+ if (!isset($tags['package']))
+ {
+ $message = 'Missing require @package tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+ else if (preg_match('/^([\w]+)$/', $tags['package'][0]) === 0)
+ {
+ $message = 'Invalid content found for @package tag.';
+ $phpcsFile->addWarning($message, $tags['package'][1]);
+ }
+ }
+
+ /**
+ * Checks that the tags array contains a valid version tag
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param integer The stack pointer for the first comment token.
+ * @param array(string=>array) $tags The found file doc comment tags.
+ *
+ * @return null
+ */
+ protected function processVersion(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ {
+ if (!isset($tags['version']))
+ {
+ $message = 'Missing require @version tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+ else if (preg_match('/^\$Id:[^\$]+\$$/', $tags['version'][0]) === 0)
+ {
+ $message = 'Invalid content found for @version tag, use "$Id: $".';
+ $phpcsFile->addError($message, $tags['version'][1]);
+ }
+ }
+
+ /**
+ * Checks that the tags array contains a valid copyright tag
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param integer The stack pointer for the first comment token.
+ * @param array(string=>array) $tags The found file doc comment tags.
+ *
+ * @return null
+ */
+ protected function processCopyright(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ {
+ $copyright = '(c) phpBB Limited <https://www.phpbb.com>';
+
+ if (!isset($tags['copyright']))
+ {
+ $message = 'Missing require @copyright tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+ else if ($tags['copyright'][0][0] !== $copyright)
+ {
+ $message = 'Invalid content found for the first @copyright tag, use "' . $copyright . '".';
+ $phpcsFile->addError($message, $tags['copyright'][0][1]);
+ }
+ }
+
+ /**
+ * Checks that the tags array contains a valid license tag
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param integer The stack pointer for the first comment token.
+ * @param array(string=>array) $tags The found file doc comment tags.
+ *
+ * @return null
+ */
+ protected function processLicense(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ {
+ $license = 'GNU General Public License, version 2 (GPL-2.0)';
+
+ if (!isset($tags['license']))
+ {
+ $message = 'Missing require @license tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+ else if (sizeof($tags['license']) !== 1)
+ {
+ $message = 'It must be only one @license tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+ else if (trim($tags['license'][0][0]) !== $license)
+ {
+ $message = 'Invalid content found for @license tag, use '
+ . '"' . $license . '".';
+ $phpcsFile->addError($message, $tags['license'][0][1]);
+ }
+ }
+}
diff --git a/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php b/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php
new file mode 100644
index 0000000000..18cb8ba82e
--- /dev/null
+++ b/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php
@@ -0,0 +1,234 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+/**
+* Checks that each use statement is used.
+*/
+class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function register()
+ {
+ return array(T_USE);
+ }
+
+ protected function check($phpcsFile, $found_name, $full_name, $short_name, $line)
+ {
+
+ if ($found_name === $full_name)
+ {
+ $error = 'Either use statement or full name must be used.';
+ $phpcsFile->addError($error, $line, 'FullName');
+ }
+
+ if ($found_name === $short_name)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ {
+ if ($this->should_ignore_use($phpcsFile, $stackPtr) === true)
+ {
+ return;
+ }
+
+ $tokens = $phpcsFile->getTokens();
+
+ $class_name_start = $phpcsFile->findNext(array(T_NS_SEPARATOR, T_STRING), ($stackPtr + 1));
+
+ $find = array(
+ T_NS_SEPARATOR,
+ T_STRING,
+ T_WHITESPACE,
+ );
+
+ $class_name_end = $phpcsFile->findNext($find, ($stackPtr + 1), null, true);
+
+ $aliasing_as_position = $phpcsFile->findNext(T_AS, $class_name_end, null, false, null, true);
+ if ($aliasing_as_position !== false)
+ {
+ $alias_position = $phpcsFile->findNext(T_STRING, $aliasing_as_position, null, false, null, true);
+ $class_name_short = $tokens[$alias_position]['content'];
+ $class_name_full = $phpcsFile->getTokensAsString($class_name_start, ($class_name_end - $class_name_start - 1));
+ }
+ else
+ {
+ $class_name_full = $phpcsFile->getTokensAsString($class_name_start, ($class_name_end - $class_name_start));
+ $class_name_short = $tokens[$class_name_end - 1]['content'];
+ }
+
+ $ok = false;
+
+ // Checks in simple statements (new, instanceof and extends)
+ foreach (array(T_INSTANCEOF, T_NEW, T_EXTENDS) as $keyword)
+ {
+ $old_simple_statement = $stackPtr;
+ while (($simple_statement = $phpcsFile->findNext($keyword, ($old_simple_statement + 1))) !== false)
+ {
+ $old_simple_statement = $simple_statement;
+
+ $simple_class_name_start = $phpcsFile->findNext(array(T_NS_SEPARATOR, T_STRING), ($simple_statement + 1));
+ $simple_class_name_end = $phpcsFile->findNext($find, ($simple_statement + 1), null, true);
+
+ $simple_class_name = trim($phpcsFile->getTokensAsString($simple_class_name_start, ($simple_class_name_end - $simple_class_name_start)));
+
+ $ok = $this->check($phpcsFile, $simple_class_name, $class_name_full, $class_name_short, $simple_statement) ? true : $ok;
+ }
+ }
+
+ // Checks paamayim nekudotayim
+ $old_paamayim_nekudotayim = $stackPtr;
+ while (($paamayim_nekudotayim = $phpcsFile->findNext(T_PAAMAYIM_NEKUDOTAYIM, ($old_paamayim_nekudotayim + 1))) !== false)
+ {
+ $old_paamayim_nekudotayim = $paamayim_nekudotayim;
+
+ $paamayim_nekudotayim_class_name_start = $phpcsFile->findPrevious($find, $paamayim_nekudotayim - 1, null, true);
+ $paamayim_nekudotayim_class_name_end = $paamayim_nekudotayim - 1;
+
+ $paamayim_nekudotayim_class_name = trim($phpcsFile->getTokensAsString($paamayim_nekudotayim_class_name_start + 1, ($paamayim_nekudotayim_class_name_end - $paamayim_nekudotayim_class_name_start)));
+
+ $ok = $this->check($phpcsFile, $paamayim_nekudotayim_class_name, $class_name_full, $class_name_short, $paamayim_nekudotayim) ? true : $ok;
+ }
+
+ // Checks in implements
+ $old_implements = $stackPtr;
+ while (($implements = $phpcsFile->findNext(T_IMPLEMENTS, ($old_implements + 1))) !== false)
+ {
+ $old_implements = $implements;
+
+ $old_implemented_class = $implements;
+ while (($implemented_class = $phpcsFile->findNext(T_STRING, ($old_implemented_class + 1), null, false, null, true)) !== false)
+ {
+ $old_implemented_class = $implemented_class;
+
+ $implements_class_name_start = $phpcsFile->findNext(array(T_NS_SEPARATOR, T_STRING), ($implemented_class - 1));
+ $implements_class_name_end = $phpcsFile->findNext($find, ($implemented_class - 1), null, true);
+
+ $implements_class_name = trim($phpcsFile->getTokensAsString($implements_class_name_start, ($implements_class_name_end - $implements_class_name_start)));
+
+ $ok = $this->check($phpcsFile, $implements_class_name, $class_name_full, $class_name_short, $implements) ? true : $ok;
+ }
+ }
+
+ // Checks in type hinting
+ $old_function_declaration = $stackPtr;
+ while (($function_declaration = $phpcsFile->findNext(T_FUNCTION, ($old_function_declaration + 1))) !== false)
+ {
+ $old_function_declaration = $function_declaration;
+
+ // Check docblocks
+ $find = array(
+ T_COMMENT,
+ T_DOC_COMMENT,
+ T_CLASS,
+ T_FUNCTION,
+ T_OPEN_TAG,
+ );
+
+ $comment_end = $phpcsFile->findPrevious($find, ($function_declaration - 1));
+ if ($comment_end !== false)
+ {
+ if (!$tokens[$comment_end]['code'] !== T_DOC_COMMENT)
+ {
+ $comment_start = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($comment_end - 1), null, true) + 1);
+ $comment = $phpcsFile->getTokensAsString($comment_start, ($comment_end - $comment_start + 1));
+
+ try
+ {
+ $comment_parser = new PHP_CodeSniffer_CommentParser_FunctionCommentParser($comment, $phpcsFile);
+ $comment_parser->parse();
+
+ // Check @param
+ foreach ($comment_parser->getParams() as $param) {
+ $type = $param->getType();
+ $types = explode('|', str_replace('[]', '', $type));
+ foreach ($types as $type)
+ {
+ $ok = $this->check($phpcsFile, $type, $class_name_full, $class_name_short, $param->getLine() + $comment_start) ? true : $ok;
+ }
+ }
+
+ // Check @return
+ $return = $comment_parser->getReturn();
+ if ($return !== null)
+ {
+ $type = $return->getValue();
+ $types = explode('|', str_replace('[]', '', $type));
+ foreach ($types as $type)
+ {
+ $ok = $this->check($phpcsFile, $type, $class_name_full, $class_name_short, $return->getLine() + $comment_start) ? true : $ok;
+ }
+ }
+ }
+ catch (PHP_CodeSniffer_CommentParser_ParserException $e)
+ {
+ $line = ($e->getLineWithinComment() + $comment_start);
+ $phpcsFile->addError($e->getMessage(), $line, 'FailedParse');
+ }
+ }
+ }
+
+ // Check type hint
+ $params = $phpcsFile->getMethodParameters($function_declaration);
+ foreach ($params as $param)
+ {
+ $ok = $this->check($phpcsFile, $param['type_hint'], $class_name_full, $class_name_short, $function_declaration) ? true : $ok;
+ }
+ }
+
+ if (!$ok)
+ {
+ $error = 'There must not be unused USE statements.';
+ $phpcsFile->addError($error, $stackPtr, 'Unused');
+ }
+ }
+
+ /**
+ * Check if this use statement is part of the namespace block.
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+ * @param int $stackPtr The position of the current token in
+ * the stack passed in $tokens.
+ *
+ * @return bool
+ */
+ private function should_ignore_use(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ {
+ $tokens = $phpcsFile->getTokens();
+
+ // Ignore USE keywords inside closures.
+ $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
+ if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS)
+ {
+ return true;
+ }
+
+ // Ignore USE keywords for traits.
+ if ($phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_TRAIT)) === true)
+ {
+ return true;
+ }
+
+ return false;
+
+ }
+}
diff --git a/build/code_sniffer/ruleset-minimum.xml b/build/code_sniffer/ruleset-minimum.xml
new file mode 100644
index 0000000000..33d0177390
--- /dev/null
+++ b/build/code_sniffer/ruleset-minimum.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<ruleset name="phpBB Minimum Standard">
+
+ <description>phpBB minimum coding standard</description>
+
+ <!-- All code files MUST use only UTF-8 without BOM. -->
+ <rule ref="Generic.Files.ByteOrderMark" />
+
+ <!-- All code files MUST use the Unix LF (linefeed) line ending. -->
+ <rule ref="Generic.Files.LineEndings" />
+
+ <!-- Tabs MUST be used for indentation -->
+ <rule ref="Generic.WhiteSpace.DisallowSpaceIndent" />
+
+</ruleset>
diff --git a/build/code_sniffer/ruleset-php-extensions.xml b/build/code_sniffer/ruleset-php-extensions.xml
new file mode 100644
index 0000000000..2d388103c3
--- /dev/null
+++ b/build/code_sniffer/ruleset-php-extensions.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<ruleset name="phpBB PHP Strict Standard Extensions">
+
+ <description>phpBB coding standard for PHP files of phpBB extensions</description>
+
+ <rule ref="./ruleset-php-strict.xml" />
+
+</ruleset>
diff --git a/build/code_sniffer/ruleset-php-legacy-core.xml b/build/code_sniffer/ruleset-php-legacy-core.xml
new file mode 100644
index 0000000000..55f2461a04
--- /dev/null
+++ b/build/code_sniffer/ruleset-php-legacy-core.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<ruleset name="phpBB PHP Legacy Standard Core">
+
+ <description>phpBB legacy coding standard for PHP files of phpBB core</description>
+
+ <rule ref="./ruleset-php-legacy.xml" />
+
+ <!-- Each file MUST start with a valid header as defined by the Coding Guidelines -->
+ <rule ref="./phpbb/Sniffs/Commenting/FileCommentSniff.php" />
+
+</ruleset>
diff --git a/build/code_sniffer/ruleset-php-legacy.xml b/build/code_sniffer/ruleset-php-legacy.xml
new file mode 100644
index 0000000000..b0110e8b12
--- /dev/null
+++ b/build/code_sniffer/ruleset-php-legacy.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0"?>
+<ruleset name="phpBB PHP Legacy Standard">
+
+ <description>phpBB legacy coding standard for PHP files</description>
+
+ <rule ref="./ruleset-minimum.xml" />
+
+ <!-- "for (; bar; )" should be "while (bar)" instead -->
+ <rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" />
+
+ <!-- A method MUST not only call its parent -->
+ <rule ref="Generic.CodeAnalysis.UselessOverridingMethod" />
+
+ <!-- The body of each structure MUST be enclosed by braces. -->
+ <rule ref="Generic.ControlStructures.InlineControlStructure" />
+
+ <!-- There MUST not be more than one statement per line. -->
+ <rule ref="Generic.Formatting.DisallowMultipleStatements" />
+
+ <!-- Call-time pass-by-reference MUST not be used. -->
+ <rule ref="Generic.Functions.CallTimePassByReference.NotAllowed" />
+
+ <!-- Filenames MUST be lowercase. -->
+ <rule ref="Generic.Files.LowercasedFilename" />
+
+ <!-- The function brace MUST be on the line following the function declaration
+ and MUST be indented to the same column as the start of the function declaration. -->
+ <rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman" />
+
+ <!-- There MUST be exactly one space after a cast. -->
+ <rule ref="Generic.Formatting.SpaceAfterCast" />
+
+ <!-- Class constants MUST be declared in all upper case with underscore separators. -->
+ <rule ref="Generic.NamingConventions.UpperCaseConstantName" />
+
+ <!-- Only <?php, no short tags. -->
+ <rule ref="Generic.PHP.DisallowShortOpenTag.EchoFound" />
+
+ <!-- Method arguments with default values MUST go at the end of the argument list. -->
+ <rule ref="PEAR.Functions.ValidDefaultValue" />
+
+ <!-- Each file MUST end with exactly one newline character -->
+ <rule ref="PSR2.Files.EndFileNewline" />
+
+ <!-- When referencing arrays there MUST NOT be any whitespace around the opening bracket
+ or before the closing bracket. -->
+ <rule ref="Squiz.Arrays.ArrayBracketSpacing" />
+
+ <!-- The "else if" statement MUST be written with a space between the words else and if. -->
+ <rule ref="Squiz.ControlStructures.ElseIfDeclaration" />
+
+ <!-- There MUST be a space between each element of a foreach loop. -->
+ <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration" />
+
+ <!-- In a for loop declaration, there MUST be no space inside the brackets
+ and there MUST be 0 spaces before and 1 space after semicolons. -->
+ <rule ref="Squiz.ControlStructures.ForLoopDeclaration" />
+
+ <!-- In the argument list, there MUST NOT be a space before each comma,
+ and there MUST be one space after each comma. -->
+ <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
+ <properties>
+ <property name="equalsSpacing" value="1"/>
+ </properties>
+ </rule>
+ <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint" />
+
+ <!-- All built-in PHP functions MUST be called lowercased. -->
+ <rule ref="Squiz.Functions.LowercaseFunctionKeywords" />
+
+ <!-- The eval() function MUST NOT be used. -->
+ <rule ref="Squiz.PHP.Eval" />
+
+ <!-- There MUST NOT be trailing whitespace at the end of lines. -->
+ <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
+
+ <!-- There MUST NOT be whitespace before the first content of a file -->
+ <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile" />
+
+ <!-- There MUST NOT be whitespace after the last content of a file -->
+ <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile" />
+
+ <!-- Functions MUST NOT contain multiple empty lines in a row -->
+ <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines" />
+
+ <!-- The ?> closing tag MUST be omitted from files containing only PHP. -->
+ <rule ref="Zend.Files.ClosingTag" />
+
+</ruleset>
diff --git a/build/code_sniffer/ruleset-php-strict-core.xml b/build/code_sniffer/ruleset-php-strict-core.xml
new file mode 100644
index 0000000000..5ca4d0cf1e
--- /dev/null
+++ b/build/code_sniffer/ruleset-php-strict-core.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<ruleset name="phpBB PHP Strict Standard Core">
+
+ <description>phpBB coding standard for PHP files of phpBB core</description>
+
+ <rule ref="./ruleset-php-legacy-core.xml" />
+ <rule ref="./ruleset-php-strict.xml" />
+
+</ruleset>
diff --git a/build/code_sniffer/ruleset-php-strict.xml b/build/code_sniffer/ruleset-php-strict.xml
new file mode 100644
index 0000000000..9e2f0664d8
--- /dev/null
+++ b/build/code_sniffer/ruleset-php-strict.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<ruleset name="phpBB PHP Strict Standard">
+
+ <description>phpBB coding standard for PHP files</description>
+
+ <rule ref="./ruleset-php-legacy.xml" />
+
+ <!-- There SHOULD NOT be more than 80 characters per line
+ There MUST NOT be more than 120 characters per line -->
+ <!--
+ <rule ref="Generic.Files.LineLength">
+ <properties>
+ <property name="lineLimit" value="80"/>
+ <property name="absoluteLineLimit" value="120"/>
+ </properties>
+ </rule>
+ -->
+
+ <!-- The PHP constants true, false, and null MUST be in lower case. -->
+ <rule ref="Generic.PHP.LowerCaseConstant" />
+
+ <!-- PHP keywords MUST be in lower case. -->
+ <rule ref="Generic.PHP.LowerCaseKeyword" />
+
+ <!-- Constructors MUST be called __construct() instead of after the class. -->
+ <rule ref="Generic.NamingConventions.ConstructorName" />
+
+ <!-- Classes etc. MUST be namespaced -->
+ <rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace" />
+
+ <!-- A file MUST not contain more than one class/interface -->
+ <rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses" />
+
+ <!-- Files containing classes MUST not have any side-effects -->
+ <rule ref="PSR1.Files.SideEffects.FoundWithSymbols" />
+
+ <!-- When present, all use declarations MUST go after the namespace declaration.
+ There MUST be one use keyword per declaration.
+ There MUST be one blank line after the use block. -->
+ <rule ref="PSR2.Namespaces.UseDeclaration" />
+
+ <!-- There MUST be one blank line after the namespace declaration -->
+ <rule ref="PSR2.Namespaces.NamespaceDeclaration" />
+
+ <!-- There MUST NOT be unused use statements. -->
+ <rule ref="./phpbb/Sniffs/Namespaces/UnusedUseSniff.php" />
+
+</ruleset>
diff --git a/build/package.php b/build/package.php
index 22ea4e52af..d168957ca5 100755
--- a/build/package.php
+++ b/build/package.php
@@ -2,9 +2,13 @@
<?php
/**
*
-* @package build
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -45,6 +49,10 @@ if (sizeof($package->old_packages))
$package->get('patch_directory') . '/phpBB-' . $dest_package_filename . $package->get('new_version_number') . '.patch',
$_package_name
);
+ $diff_file_changes[$_package_name]['deleted'] = $package->collect_deleted_files(
+ $package->get('patch_directory') . '/phpBB-' . $dest_package_filename . $package->get('new_version_number') . '.deleted',
+ $_package_name
+ );
}
// Now put those files determined within the correct directories
@@ -121,6 +129,7 @@ if (sizeof($package->old_packages))
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/docs ' . $dest_filename_dir);
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/install ' . $dest_filename_dir);
+ $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/vendor ' . $dest_filename_dir);
$package->run_command('mkdir ' . $dest_filename_dir . '/install/update');
$package->run_command('mkdir ' . $dest_filename_dir . '/install/update/old');
@@ -138,6 +147,12 @@ if (sizeof($package->old_packages))
{
unset($file_contents['all'][$index]);
}
+
+ $source_filename = $package->locations['old_versions'] . $package->get('simple_name') . '/' . $file;
+ if (!file_exists($source_filename))
+ {
+ unset($file_contents['all'][$index]);
+ }
}
// First of all, fill the 'old' directory
@@ -173,16 +188,27 @@ if (sizeof($package->old_packages))
$package->run_command('cp ' . $source_filename . ' ' . $dest_filename);
}
+ /**
+ * We try to keep the update packages as small as possible while creating them.
+ * However, we sometimes need to include additional files that are not included
+ * in the diff in order to be able to correctly include the relatively
+ * referenced files from the same or subsequent directories.
+ */
+ $copy_relative_directories = array(
+ 'config/' => array(
+ 'copied' => false,
+ 'copy' => array(
+ 'config/*.yml' => 'config',
+ ),
+ ),
+ );
+
// Then fill the 'new' directory
foreach ($file_contents['all'] as $file)
{
$source_filename = $package->locations['old_versions'] . $package->get('simple_name') . '/' . $file;
$dest_filename = $dest_filename_dir . '/install/update/new/' . $file;
-
- if (!file_exists($source_filename))
- {
- continue;
- }
+ $filename = $file;
// Create Directories along the way?
$file = explode('/', $file);
@@ -204,6 +230,73 @@ if (sizeof($package->old_packages))
}
$package->run_command('cp ' . $source_filename . ' ' . $dest_filename);
+
+ foreach ($copy_relative_directories as $reference => $data)
+ {
+ // Copy all relative referenced files if needed
+ if (strpos($filename, $reference) === 0 && !$data['copied'])
+ {
+ foreach ($data['copy'] as $source_dir_files => $destination_dir)
+ {
+ // Create directories along the way?
+ $directories = explode('/', $destination_dir);
+
+ chdir($dest_filename_dir . '/install/update/new');
+ foreach ($directories as $dir)
+ {
+ $dir = trim($dir);
+ if ($dir)
+ {
+ if (!file_exists('./' . $dir))
+ {
+ $package->run_command('mkdir ' . $dir);
+ }
+ chdir('./' . $dir);
+ }
+ }
+ $source_dir_files = $package->locations['old_versions'] . $package->get('simple_name') . '/' . $source_dir_files;
+ $destination_dir = $dest_filename_dir . '/install/update/new/' . $destination_dir;
+ $package->run_command('cp ' . $source_dir_files . ' ' . $destination_dir);
+ }
+ $copy_relative_directories[$reference]['copied'] = true;
+ }
+ }
+ }
+
+ /**
+ * We need to always copy the template and asset files that we need in
+ * the update, to ensure that the page is displayed correctly.
+ */
+ $copy_update_files = array(
+ 'adm/images/*' => 'adm/images',
+ 'adm/style/admin.css' => 'adm/style',
+ 'adm/style/admin.js' => 'adm/style',
+ 'adm/style/ajax.js' => 'adm/style',
+ 'adm/style/install_*' => 'adm/style',
+ 'assets/javascript/*' => 'assets/javascript',
+ );
+
+ foreach ($copy_update_files as $source_files => $destination_dir)
+ {
+ // Create directories along the way?
+ $directories = explode('/', $destination_dir);
+
+ chdir($dest_filename_dir . '/install/update/new');
+ foreach ($directories as $dir)
+ {
+ $dir = trim($dir);
+ if ($dir)
+ {
+ if (!file_exists('./' . $dir))
+ {
+ $package->run_command('mkdir ' . $dir);
+ }
+ chdir('./' . $dir);
+ }
+ }
+ $source_dir_files = $package->locations['old_versions'] . $package->get('simple_name') . '/' . $source_files;
+ $destination_dir = $dest_filename_dir . '/install/update/new/' . $destination_dir;
+ $package->run_command('cp ' . $source_dir_files . ' ' . $destination_dir);
}
// Build index.php file for holding the file structure
@@ -221,29 +314,32 @@ $update_info = array(
if (sizeof($file_contents['all']))
{
- $index_contents .= '\'files\' => array(\'' . implode("',\n\t'", $file_contents['all']) . '\'),
-';
+ $index_contents .= "\t'files' => array(\n\t\t'" . implode("',\n\t\t'", $file_contents['all']) . "',\n\t),\n";
}
else
{
- $index_contents .= '\'files\' => array(),
-';
+ $index_contents .= "\t'files' => array(),\n";
}
if (sizeof($file_contents['binary']))
{
- $index_contents .= '\'binary\' => array(\'' . implode("',\n\t'", $file_contents['binary']) . '\'),
-';
+ $index_contents .= "\t'binary' => array(\n\t\t'" . implode("',\n\t\t'", $file_contents['binary']) . "',\n\t),\n";
}
else
{
- $index_contents .= '\'binary\' => array(),
-';
+ $index_contents .= "\t'binary' => array(),\n";
}
- $index_contents .= ');
+ if (sizeof($file_contents['deleted']))
+ {
+ $index_contents .= "\t'deleted' => array(\n\t\t'" . implode("',\n\t\t'", $file_contents['deleted']) . "',\n\t),\n";
+ }
+ else
+ {
+ $index_contents .= "\t'deleted' => array(),\n";
+ }
-?' . '>';
+ $index_contents .= ");\n";
$fp = fopen($dest_filename_dir . '/install/update/index.php', 'wt');
fwrite($fp, $index_contents);
@@ -256,6 +352,7 @@ $update_info = array(
// Copy the install files to their respective locations
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/docs ' . $package->get('patch_directory'));
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/install ' . $package->get('patch_directory'));
+ $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/vendor ' . $package->get('patch_directory'));
// Remove some files
chdir($package->get('patch_directory') . '/install');
@@ -297,6 +394,7 @@ if (sizeof($package->old_packages))
$package->run_command('mkdir ' . $package->get('files_directory') . '/release');
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/docs ' . $package->get('files_directory') . '/release');
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/install ' . $package->get('files_directory') . '/release');
+ $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/vendor ' . $package->get('files_directory') . '/release');
$package->run_command('rm -v ' . $package->get('files_directory') . '/release/install/install_install.php');
$package->run_command('rm -v ' . $package->get('files_directory') . '/release/install/install_update.php');
@@ -372,14 +470,22 @@ chdir($package->get('dest_dir') . '/install');
// $package->run_command('rm -v database_update.php');
$package->run_command('rm -v install_update.php');
+chdir($package->get('dest_dir'));
+$package->run_command('mv -v styles/subsilver2 ../subsilver2');
+$package->run_command('cp -p docs/COPYING ../subsilver2/license.txt');
+
chdir($package->locations['package_dir']);
foreach ($compress_programs as $extension => $compress_command)
{
$package->begin_status('Packaging phpBB for ' . $extension);
$package->run_command('rm -v ./release_files/' . $package->get('release_filename') . ".{$extension}");
+ $package->run_command('rm -v ./release_files/subsilver2_' . $package->get('new_version_number') . ".{$extension}");
// Build Package
$package->run_command("$compress_command ./release_files/" . $package->get('release_filename') . '.' . $extension . ' ' . $package->get('package_name'));
+
+ // Build subSilver2 Package
+ $package->run_command("$compress_command ./release_files/subsilver2_" . $package->get('new_version_number') . '.' . $extension . ' subsilver2');
}
// Microsoft Web PI packaging