From d1876900e53164bbd95118120706e360d0f01dd4 Mon Sep 17 00:00:00 2001 From: gwen Date: Mon, 22 Feb 2016 17:37:24 +0100 Subject: [PATCH] correcting issue #4797 --- hphp/runtime/base/execution-context.h | 2 +- hphp/runtime/base/unit-cache.cpp | 10 +++++----- hphp/runtime/debugger/debugger_hook_handler.cpp | 2 +- hphp/runtime/ext/xdebug/hook.cpp | 2 +- hphp/test/slow/include/included_twice_different.php | 11 +++++++++++ .../slow/include/included_twice_different.php.expect | 1 + 6 files changed, 20 insertions(+), 8 deletions(-) create mode 100755 hphp/test/slow/include/included_twice_different.php create mode 100755 hphp/test/slow/include/included_twice_different.php.expect diff --git a/hphp/runtime/base/execution-context.h b/hphp/runtime/base/execution-context.h index 507c531bdc07f..2a79a07e29945 100644 --- a/hphp/runtime/base/execution-context.h +++ b/hphp/runtime/base/execution-context.h @@ -626,7 +626,7 @@ struct ExecutionContext { // destroying the context, so C++ order of destruction is not an issue. req::hash_map dynPropTable; VarEnv* m_globalVarEnv; - req::hash_map + req::hash_map,string_data_hash,string_data_same> m_evaledFiles; req::vector m_evaledFilesOrder; req::vector m_createdFuncs; diff --git a/hphp/runtime/base/unit-cache.cpp b/hphp/runtime/base/unit-cache.cpp index 9ae2e0b98ccc9..60b4a8496ab9c 100644 --- a/hphp/runtime/base/unit-cache.cpp +++ b/hphp/runtime/base/unit-cache.cpp @@ -483,9 +483,9 @@ Unit* lookupUnit(StringData* path, const char* currentDir, bool* initial_opt) { // Check if this file has already been included. auto it = eContext->m_evaledFiles.find(spath.get()); - if (it != end(eContext->m_evaledFiles)) { - initial = false; - return it->second; + if (it != end(eContext->m_evaledFiles) && it->second.second >= s.st_mtime) { + initial = false; + return it->second.first; } // This file hasn't been included yet, so we need to parse the file @@ -499,10 +499,10 @@ Unit* lookupUnit(StringData* path, const char* currentDir, bool* initial_opt) { // if parsing was successful, update the mappings for spath and // rpath (if it exists). eContext->m_evaledFilesOrder.push_back(cunit.unit->filepath()); - eContext->m_evaledFiles[spath.get()] = cunit.unit; + eContext->m_evaledFiles[spath.get()] = std::make_pair(cunit.unit,time(NULL)); spath.get()->incRefCount(); if (!cunit.unit->filepath()->same(spath.get())) { - eContext->m_evaledFiles[cunit.unit->filepath()] = cunit.unit; + eContext->m_evaledFiles[cunit.unit->filepath()] = std::make_pair(cunit.unit,time(NULL)); } if (g_system_profiler) { g_system_profiler->fileLoadCallBack(path->toCppString()); diff --git a/hphp/runtime/debugger/debugger_hook_handler.cpp b/hphp/runtime/debugger/debugger_hook_handler.cpp index 447767220cfd3..06a51bd240e0a 100644 --- a/hphp/runtime/debugger/debugger_hook_handler.cpp +++ b/hphp/runtime/debugger/debugger_hook_handler.cpp @@ -77,7 +77,7 @@ void proxySetBreakPoints(DebuggerProxy* proxy) { auto fileName = bp->m_file; if (!fileName.empty()) { for (auto& kv : g_context->m_evaledFiles) { - auto const unit = kv.second; + auto const unit = kv.second.first; if (!BreakPointInfo::MatchFile(fileName, unit->filepath()->toCppString())) { continue; diff --git a/hphp/runtime/ext/xdebug/hook.cpp b/hphp/runtime/ext/xdebug/hook.cpp index 5ece9ce1aaff7..bc310ed51d84c 100644 --- a/hphp/runtime/ext/xdebug/hook.cpp +++ b/hphp/runtime/ext/xdebug/hook.cpp @@ -110,7 +110,7 @@ static const Unit* find_unit(String filename) { // Search the given filename in the list of evaled files. We translate each // unit's filename to a canonical format, which is slow, but necessary. for (auto& kv : g_context->m_evaledFiles) { - auto const unit = kv.second; + auto const unit = kv.second.first; String ufilename(const_cast(unit->filepath())); if (filename == File::TranslatePath(ufilename)) { return unit; diff --git a/hphp/test/slow/include/included_twice_different.php b/hphp/test/slow/include/included_twice_different.php new file mode 100755 index 0000000000000..c689ed6df6d36 --- /dev/null +++ b/hphp/test/slow/include/included_twice_different.php @@ -0,0 +1,11 @@ + diff --git a/hphp/test/slow/include/included_twice_different.php.expect b/hphp/test/slow/include/included_twice_different.php.expect new file mode 100755 index 0000000000000..48082f72f087c --- /dev/null +++ b/hphp/test/slow/include/included_twice_different.php.expect @@ -0,0 +1 @@ +12