Remove a few more uses of ClassInfo
Esse commit está contido em:
@@ -605,13 +605,10 @@ static bool valid_statement_class(sp_PDOConnection dbh, CVarRef opt,
|
||||
PDO_HANDLE_DBH_ERR(dbh);
|
||||
return false;
|
||||
}
|
||||
const ClassInfo *cls = ClassInfo::FindClass(clsname);
|
||||
HPHP::VM::Class* cls = HPHP::VM::Unit::loadClass(clsname.get());
|
||||
if (cls) {
|
||||
ClassInfo::MethodInfo *method = cls->getMethodInfo("__construct");
|
||||
if (!method) {
|
||||
method = cls->getMethodInfo(clsname.data());
|
||||
}
|
||||
if (method && (method->attribute & ClassInfo::IsPublic)) {
|
||||
const HPHP::VM::Func* method = cls->getDeclaredCtor();
|
||||
if (method && method->isPublic()) {
|
||||
pdo_raise_impl_error
|
||||
(dbh, NULL, "HY000",
|
||||
"user-supplied statement class cannot have a public constructor");
|
||||
@@ -728,12 +725,12 @@ static bool do_fetch_class_prepare(sp_PDOStatement stmt) {
|
||||
if (clsname.empty()) {
|
||||
stmt->fetch.clsname = "stdclass";
|
||||
}
|
||||
stmt->fetch.constructor = NULL;
|
||||
const ClassInfo *cls = ClassInfo::FindClass(clsname);
|
||||
stmt->fetch.constructor = empty_string; //NULL;
|
||||
HPHP::VM::Class* cls = HPHP::VM::Unit::loadClass(clsname.get());
|
||||
if (cls) {
|
||||
const char *constructor = cls->getConstructor();
|
||||
if (constructor) {
|
||||
stmt->fetch.constructor = constructor;
|
||||
const HPHP::VM::Func* method = cls->getDeclaredCtor();
|
||||
if (method) {
|
||||
stmt->fetch.constructor = method->nameRef();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1828,7 +1825,8 @@ static bool do_fetch(sp_PDOStatement stmt, bool do_bind, Variant &ret,
|
||||
if (!do_fetch_class_prepare(stmt)) {
|
||||
return false;
|
||||
}
|
||||
if (stmt->fetch.constructor && (flags & PDO_FETCH_PROPS_LATE)) {
|
||||
if (!stmt->fetch.constructor.empty() &&
|
||||
(flags & PDO_FETCH_PROPS_LATE)) {
|
||||
ret.asCObjRef().get()->o_invoke(stmt->fetch.constructor,
|
||||
stmt->fetch.ctor_args, -1);
|
||||
ret.asCObjRef().get()->clearNoDestruct();
|
||||
@@ -1964,7 +1962,7 @@ static bool do_fetch(sp_PDOStatement stmt, bool do_bind, Variant &ret,
|
||||
|
||||
switch (how) {
|
||||
case PDO_FETCH_CLASS:
|
||||
if (stmt->fetch.constructor &&
|
||||
if (!stmt->fetch.constructor.empty() &&
|
||||
!(flags & (PDO_FETCH_PROPS_LATE | PDO_FETCH_SERIALIZE))) {
|
||||
ret.toObject()->o_invoke(stmt->fetch.constructor, stmt->fetch.ctor_args,
|
||||
-1);
|
||||
|
||||
@@ -2007,23 +2007,16 @@ Variant c_SoapServer::t_getfunctions() {
|
||||
|
||||
static bool valid_function(c_SoapServer *server, Object &soap_obj,
|
||||
CStrRef fn_name) {
|
||||
String class_name;
|
||||
HPHP::VM::Class* cls;
|
||||
if (server->m_type == SOAP_OBJECT || server->m_type == SOAP_CLASS) {
|
||||
class_name = server->m_soap_object->o_getClassName();
|
||||
cls = server->m_soap_object->getVMClass();
|
||||
} else if (server->m_soap_functions.functions_all) {
|
||||
return f_function_exists(fn_name);
|
||||
} else if (!server->m_soap_functions.ft.empty()) {
|
||||
return server->m_soap_functions.ft.exists(StringUtil::ToLower(fn_name));
|
||||
}
|
||||
|
||||
const ClassInfo *clsInfo = ClassInfo::FindClass(class_name);
|
||||
if (clsInfo) {
|
||||
ClassInfo::MethodInfo *info = clsInfo->getMethodInfo(fn_name.data());
|
||||
if (info && (info->attribute & ClassInfo::IsPublic)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
HPHP::VM::Func* f = cls->lookupMethod(fn_name.get());
|
||||
return (f && f->isPublic());
|
||||
}
|
||||
|
||||
void c_SoapServer::t_handle(CStrRef request /* = null_string */) {
|
||||
|
||||
@@ -196,7 +196,6 @@ PDOStatement::PDOStatement()
|
||||
named_rewrite_template(NULL) {
|
||||
memset(error_code, 0, sizeof(error_code));
|
||||
fetch.column = 0;
|
||||
fetch.constructor = NULL;
|
||||
}
|
||||
|
||||
PDOStatement::~PDOStatement() {
|
||||
|
||||
@@ -590,7 +590,7 @@ public:
|
||||
struct {
|
||||
int column;
|
||||
String clsname;
|
||||
const char *constructor;
|
||||
String constructor;
|
||||
Variant ctor_args;
|
||||
String func;
|
||||
Variant fetch_args;
|
||||
|
||||
@@ -598,6 +598,11 @@ bool Class::verifyPersistent() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
const Func* Class::getDeclaredCtor() const {
|
||||
const Func* f = getCtor();
|
||||
return f->name() != sd86ctor ? f : nullptr;
|
||||
}
|
||||
|
||||
void Class::initInstanceBits() {
|
||||
assert(Transl::Translator::WriteLease().amOwner());
|
||||
if (s_instanceBitsInit.load(std::memory_order_acquire)) return;
|
||||
|
||||
@@ -722,6 +722,7 @@ public:
|
||||
}
|
||||
bool verifyPersistent() const;
|
||||
const Func* getCtor() const { return m_ctor; }
|
||||
const Func* getDeclaredCtor() const;
|
||||
const Func* getDtor() const { return m_dtor; }
|
||||
const Func* getToString() const { return m_toString; }
|
||||
const PreClass* preClass() const { return m_preClass.get(); }
|
||||
|
||||
@@ -208,6 +208,7 @@ struct Func {
|
||||
bool isNonClosureMethod() const {
|
||||
return isMethod() && !isClosureBody();
|
||||
}
|
||||
bool isPublic() const { return bool(m_attrs & AttrPublic); }
|
||||
bool isStatic() const { return bool(m_attrs & AttrStatic); }
|
||||
bool isAbstract() const { return bool(m_attrs & AttrAbstract); }
|
||||
bool isUnique() const { return bool(m_attrs & AttrUnique); }
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário