bool HHVM_FUNCTION(error_log, const String& message, int message_type /* = 0 */, const Variant& destination /* = null */, const Variant& extra_headers /* = null */) { // error_log() should not invoke the user error handler, // so we use Logger::Error() instead of raise_warning() or raise_error() switch (message_type) { case 0: { std::string line(message.data(), // Truncate to 512k message.size() > (1<<19) ? (1<<19) : message.size()); Logger::Error(line); return true; } case 3: { // open for append only auto outfile = HHVM_FN(fopen)(destination.toString(), "a"); if (outfile.isNull()) { Logger::Error("can't open error_log file!\n"); return false; } HHVM_FN(fwrite)(outfile.toResource(), message); HHVM_FN(fclose)(outfile.toResource()); return true; } case 2: // not used per PHP default: Logger::Error("error_log does not support message_type %d!", message_type); break; } return false; }
Resource get_context_resource(Object obj) { auto res = obj->o_realProp(s_context, ObjectData::RealPropUnchecked, s_zmqcontext.get()); if (!res || !res->isResource()) { return null_resource; } return res->toResource(); }
static NumberFormatter *Get(Object obj) { if (obj.isNull()) { raise_error("NULL object passed"); return nullptr; } auto res = obj->o_get(s_resdata, false, s_NumberFormatter.get()); if (!res.isResource()) { return nullptr; } auto ret = res.toResource().getTyped<NumberFormatter>(false, false); if (!ret) { return nullptr; } if (!ret->formatter()) { ret->setError(U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed NumberFormatter"); return nullptr; } return ret; }
Variant sockopen_impl(const HostURL &hosturl, VRefParam errnum, VRefParam errstr, double timeout, bool persistent) { errnum = 0; errstr = empty_string(); std::string key; if (persistent) { key = hosturl.getHostURL() + ":" + folly::to<std::string>(hosturl.getPort()); Socket *sock = dynamic_cast<Socket*>(g_persistentResources->get("socket", key.c_str())); if (sock) { if (sock->getError() == 0 && sock->checkLiveness()) { return Resource(sock); } // socket had an error earlier, we need to close it, remove it from // persistent storage, and create a new one (in that order) sock->close(); g_persistentResources->remove("socket", key.c_str()); } } if (timeout < 0) { timeout = ThreadInfo::s_threadInfo.getNoCheck()-> m_reqInjectionData.getSocketDefaultTimeout(); } auto socket = new_socket_connect(hosturl, timeout, errnum, errstr); if (!socket.isResource()) { return false; } Resource ret = socket.toResource(); if (persistent) { assert(!key.empty()); g_persistentResources->set("socket", key.c_str(), ret.getTyped<Socket>()); } return ret; }