Kelson has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/296910 )
Change subject: Revert compatibility with previous API. ...................................................................... Revert compatibility with previous API. The API has changed. The behavior is different, so do not try to keep a false API compatibility. Change-Id: I174f7df03d5ad5477c6b0fd1869258a31af3366a --- M zimlib/include/zim/writer/articlesource.h M zimlib/src/articlesource.cpp M zimlib/src/zimcreator.cpp M zimwriterfs/article.cpp M zimwriterfs/article.h M zimwriterfs/articlesource.cpp 6 files changed, 15 insertions(+), 59 deletions(-) Approvals: Kelson: Verified; Looks good to me, approved diff --git a/zimlib/include/zim/writer/articlesource.h b/zimlib/include/zim/writer/articlesource.h index dbe9263..a9ecffb 100644 --- a/zimlib/include/zim/writer/articlesource.h +++ b/zimlib/include/zim/writer/articlesource.h @@ -46,26 +46,10 @@ virtual bool shouldCompress() const; virtual std::string getRedirectAid() const; virtual std::string getParameter() const; - /* Idealy this method should be pure virtual, - * but for compatibility reasons, provide a default implementation - * using the old ArticleSourc::getData. - */ - virtual Blob getData() const; + virtual Blob getData() const = 0; // returns the next category id, to which the article is assigned to virtual std::string getNextCategory(); - - /************************************************************************/ - /* For API compatibility. - * The default Article::getData call ArticleSource::getData. - * So store the source of article in article to let default API compatible - * function do its job. - * This should be removed once every users switch to new API. - */ - private: - mutable ArticleSource* __source; - friend class ZimCreator; - /************************************************************************/ }; class Category @@ -90,17 +74,6 @@ // ids. Using this list, the writer fetches the category data using // this method. virtual Category* getCategory(const std::string& cid); - - /**********************************************************************/ - /* For API compatibility. - * The default Article::getData call ArticleSource::getData. - * So keep the getData. Do not set it pure virtual cause we want new - * code to not use it. - * This should be removed once every users switch to new API. - */ - virtual Blob getData(const std::string& aid); - - /**********************************************************************/ }; } diff --git a/zimlib/src/articlesource.cpp b/zimlib/src/articlesource.cpp index a2087a7..26d33f8 100644 --- a/zimlib/src/articlesource.cpp +++ b/zimlib/src/articlesource.cpp @@ -69,22 +69,6 @@ return std::string(); } - /**************************************************************************/ - /* For API compatibility. - * The default Article::getData call ArticleSource::getData. - * This should be removed once every users switch to new API. - */ - Blob Article::getData() const - { - std::cerr << "DEPRECATED WARNING : Use of ArticleSource::getData is deprecated." << std::endl; - std::cerr << " You should override Article::getData directly." << std::endl; - return __source->getData(getAid()); - } - Blob ArticleSource::getData(const std::string& aid) { - throw std::runtime_error("This should not be called"); - } - /**************************************************************************/ - Uuid ArticleSource::getUuid() { return Uuid::generate(); diff --git a/zimlib/src/zimcreator.cpp b/zimlib/src/zimcreator.cpp index 1b528f4..0f0f6d0 100644 --- a/zimlib/src/zimcreator.cpp +++ b/zimlib/src/zimcreator.cpp @@ -202,15 +202,6 @@ } // Add blob data to compressed or uncompressed cluster. - /**********************************************************************/ - /* For API compatibility. - * The default Article::getData call ArticleSource::getData. - * So set the source of article to let default API compatible function - * do its job. - * This should be removed once every users switch to new API. - */ - article->__source = &src; - /**********************************************************************/ Blob blob = article->getData(); if (blob.size() > 0) { diff --git a/zimwriterfs/article.cpp b/zimwriterfs/article.cpp index 4aeb083..98ec882 100644 --- a/zimwriterfs/article.cpp +++ b/zimwriterfs/article.cpp @@ -24,7 +24,9 @@ extern std::string directoryPath; -Article::Article(const std::string& path, const bool detectRedirects) { +Article::Article(ArticleSource* source, const std::string& path, const bool detectRedirects): + source(source) +{ invalid = false; /* aid */ @@ -157,3 +159,7 @@ getMimeType() == "application/json" || getMimeType() == "image/svg+xml" ? true : false); } + +zim::Blob Article::getData() { + return source->getData(getAid()); +} \ No newline at end of file diff --git a/zimwriterfs/article.h b/zimwriterfs/article.h index 2585fc6..92f7ac4 100644 --- a/zimwriterfs/article.h +++ b/zimwriterfs/article.h @@ -23,6 +23,7 @@ #include <string> #include <zim/writer/zimcreator.h> +#include <zim/blob.h> extern std::string favicon; @@ -35,13 +36,13 @@ std::string title; std::string mimeType; std::string redirectAid; - std::string data; + mutable ArticleSource* source; public: Article() { invalid = false; } - explicit Article(const std::string& id, const bool detectRedirects = true); + explicit Article(ArticleSource* source, const std::string& id, const bool detectRedirects = true); virtual std::string getAid() const; virtual char getNamespace() const; virtual std::string getUrl() const; @@ -51,6 +52,7 @@ virtual std::string getMimeType() const; virtual std::string getRedirectAid() const; virtual bool shouldCompress() const; + virtual zim::Blob getData(); }; class MetadataArticle : public Article { diff --git a/zimwriterfs/articlesource.cpp b/zimwriterfs/articlesource.cpp index 6cf5f30..d2b7156 100644 --- a/zimwriterfs/articlesource.cpp +++ b/zimwriterfs/articlesource.cpp @@ -83,14 +83,14 @@ if (!metadataQueue.empty()) { path = metadataQueue.front(); metadataQueue.pop(); - article = new MetadataArticle(path); + article = new MetadataArticle(this, path); } else if (!redirectsQueue.empty()) { std::string line = redirectsQueue.front(); redirectsQueue.pop(); - article = new RedirectArticle(line); + article = new RedirectArticle(this, line); } else if (filenameQueue.popFromQueue(path)) { do { - article = new Article(path); + article = new Article(this, path); } while (article && article->isInvalid() && filenameQueue.popFromQueue(path)); } else { article = NULL; -- To view, visit https://gerrit.wikimedia.org/r/296910 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I174f7df03d5ad5477c6b0fd1869258a31af3366a Gerrit-PatchSet: 1 Gerrit-Project: openzim Gerrit-Branch: master Gerrit-Owner: Mgautierfr <mgaut...@kymeria.fr> Gerrit-Reviewer: Kelson <kel...@kiwix.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits